mikehaertl/php-pdftk

the produced pdf document cannot be opened in Acrobat

Closed this issue · 1 comments

Dear Michael @mikehaertl,

We are using pdftk to automatically fill pdf forms.
The produced document can be printed ok, it can be viewed in PDFsam Enhanced ok,
also in a web browser, but Adobe Acrobat fails to open it and PDF2GO validator
reports:
The font programs for all fonts used for rendering within a conforming file shall be embedded within that file, as defined in ISO 32000-1:2008, 9.9.
DeviceGray shall only be used if a device independent DefaultGray colour space has been set when the DeviceGray colour space is used, or if a PDF/A OutputIntent is present.

but I do not know if this report is related to the Acrobat problem.

Is there something we can do in the code to make the output documents readable in Acrobat?

I thought maybe it is because of the locale, so I have added also the locale setting and made sure it is installed
as you suggest in the main README, but that did not change things.

This is the code we are currently using:

use mikehaertl\pdftk\Pdf;

$pdf = new Pdf($templatePath, [ 'locale' => 'sk_SK.utf8', 'procEnv' => [ 'LANG' => 'sk_SK.utf-8', ], ]);
$pdf->fillForm($data);
$pdf->flatten();
$pdf->replacementFont(public_path('DejaVuSans.ttf'));
$pdf->needAppearances();
$pdf->saveAs($outputPath);

The DejaVuSans.ttf is found on the system in various folders, such as

/snap/gnome-3-38-2004/140/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf
/snap/gnome-3-38-2004/143/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf
/snap/gnome-42-2204/172/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf
/snap/gnome-42-2204/176/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf
/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf

but I have also copied it to almost all folders of the project, still getting the same output.

also, commenting out the line
$pdf->replacementFont(public_path('DejaVuSans.ttf'));
still does not help.

Attached is the form template that we use and the resulting document that acrobat does not read.

Many thanks in each case.
Pavel.

unreadable_result.pdf
form_template.pdf

Sorry, I can not help you with this kind of issues. It has not really to do with our library but is rather an issue with pdftk itself. You should try to reproduce the problem on the command line and then report the issue at pdftk.