Bug 492968 - pdftk no longer supports standard input
pdftk no longer supports standard input
Product: Fedora
Classification: Fedora
Component: pdftk (Show other bugs)
All Linux
low Severity medium
: ---
: ---
Assigned To: Jochen Schmitt
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2009-03-30 19:17 EDT by Raman Gupta
Modified: 2009-05-18 12:20 EDT (History)
3 users (show)

See Also:
Fixed In Version: 1.41-19.fc10
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2009-04-13 15:37:03 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Raman Gupta 2009-03-30 19:17:15 EDT
With the old pdftk version in Fedora 7 (pdftk-1.41-5.fc7) pdftk would read files from standard input. For example, the following would work:

pdftk - bar.pdf cat output foobar.pdf < foo.pdf

With the pdftk recently released in FC10, this no longer works. It gives the error:

Error: Failed to open PDF file:
Errors encountered.  No output created.
Done.  Input errors, so no output created.

Version-Release number of selected component (if applicable):


How reproducible:

Every time.

Additional info:

I think this is due to the FC10 version being linked against a system itext rather than having it compiled together.
Comment 1 Orcan Ogetbil 2009-03-30 19:30:29 EDT
Is your foo.pdf encrypted? Afaik, we dropped encrypted pdf support from pdftk.
Comment 2 Raman Gupta 2009-03-30 19:50:03 EDT
No its not. It comes directly from a vanilla ps2pdf invocation:

# pdfinfo foo.pdf
Creator:        cairo 1.8.0 (http://cairographics.org)
Producer:       GPL Ghostscript 8.63
CreationDate:   Mon Mar 30 19:44:49 2009
ModDate:        Mon Mar 30 19:44:49 2009
Tagged:         no
Pages:          3
Encrypted:      no
Page size:      612 x 792 pts (letter)
File size:      91159 bytes
Optimized:      no
PDF version:    1.4
Comment 3 Jochen Schmitt 2009-03-31 11:46:28 EDT
Thank you for reporting this bug. This bug may occured by the migration of pdftk to iText-2. The migration to iText-2 was required because the bundled iText-1 library has severe license issues.

I was create a patch which should fix the reported issue. Teh issue should be fixed on pdftk-1.41-14.
Comment 4 Fedora Update System 2009-03-31 11:56:09 EDT
pdftk-1.41-14.fc10 has been submitted as an update for Fedora 10.
Comment 5 Raman Gupta 2009-03-31 12:16:12 EDT
Thank you, I can confirm the 1.41-14 version works!
Comment 6 Fedora Update System 2009-04-02 13:16:35 EDT
pdftk-1.41-14.fc10 has been pushed to the Fedora 10 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update pdftk'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F10/FEDORA-2009-3226
Comment 7 Raman Gupta 2009-04-04 14:41:23 EDT
Ok, I think there is now a timing issue associated with reading standard input. I use a variation on the following command line often:

scanimage --mode Gray --resolution 150 | pnmtops -imagewidth 8.5 -imageheight 11 | ps2pdf - | pdftk foo.pdf - cat output foo1.pdf

This scans a document, and uses pdftk to append the scanned page to an existing PDF (foo.pdf) and writes the result to foo1.pdf.

With the new pdftk, I get this output:

Error: Failed to open PDF file:
Errors encountered.  No output created.
Done.  Input errors, so no output created.
scanimage: received signal 13
scanimage: trying to stop scanner
scanimage: received signal 13
scanimage: aborting
Comment 8 Fedora Update System 2009-04-09 15:04:08 EDT
pdftk-1.41-15.fc10 has been submitted as an update for Fedora 10.
Comment 9 Fedora Update System 2009-04-13 15:36:54 EDT
pdftk-1.41-15.fc10 has been pushed to the Fedora 10 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 10 Laurent NEGRIER 2009-05-18 04:55:58 EDT
it still not work for me. with pdftk-1.41-15.fc10

cat my.pdf | /usr/bin/pdftk - output -  owner_pw streeteurope encrypt_40bit allow Printing ScreenReaders > result.pdf

it the same with PHP and the function proc_open

To help I use the following php function :

function encypt_pdf($pdf_data) {

	$pdftk = "/usr/bin/pdftk - output -  owner_pw titi encrypt_40bit allow Printing ScreenReaders"; //compatible acrobat 3 et superieur

	$descriptorspec = array(
	   0 => array("pipe", "r"),  // stdin est un pipe où le processus va lire
	   1 => array("pipe", "w"),  // stdout est un pipe où le processus va écrire
	   2 => array("file", "/dev/null", "a"), // stderr est un fichier
	$process = proc_open($pdftk, $descriptorspec, $pipes);
	if (is_resource($process)) {
		// $pipes ressemble à : 
		// 0 => fichier accessible en écriture, connecté à l'entrée standard du processus fils
		// 1 => fichier accessible en lecture, connecté à la sortie standard du processus fils
		// Toute erreur sera envoyées dans /dev/null

		fwrite($pipes[0], $pdf_data);

		$data = "";
		while(!feof($pipes[1])) {
			$pdf_data.= fgets($pipes[1], 1024);
		// Il est important que vous fermiez les pipes avant d'appeler
		// proc_close() afin d'éviter un verrouillage.
		$return_value = proc_close($process);
		//echo "$return_value";
	return $pdf_data;

Comment 11 Laurent NEGRIER 2009-05-18 04:57:23 EDT
correction of my previous post. The version use is pdftk-1.41-15.fc10.x86_64
Comment 12 Orcan Ogetbil 2009-05-18 11:35:38 EDT
Could you try the latest version available in the updates ?

Also could you add a real name to your profile?
Comment 13 Laurent NEGRIER 2009-05-18 12:01:56 EDT
The update works with both command line and php.

Thank you !
Comment 14 Orcan Ogetbil 2009-05-18 12:20:23 EDT
Changed "Fixed in version" to 1.41-19.fc10

Note You need to log in before you can comment on or make changes to this bug.