Bug 492968 - pdftk no longer supports standard input
Summary: pdftk no longer supports standard input
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: pdftk
Version: 10
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Jochen Schmitt
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-03-30 23:17 UTC by Raman Gupta
Modified: 2009-05-18 16:20 UTC (History)
3 users (show)

Fixed In Version: 1.41-19.fc10
Clone Of:
Environment:
Last Closed: 2009-04-13 19:37:03 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Raman Gupta 2009-03-30 23:17:15 UTC
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):

pdftk-1.41-13.fc10



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 23:30:29 UTC
Is your foo.pdf encrypted? Afaik, we dropped encrypted pdf support from pdftk.

Comment 2 Raman Gupta 2009-03-30 23:50:03 UTC
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 15:46:28 UTC
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 15:56:09 UTC
pdftk-1.41-14.fc10 has been submitted as an update for Fedora 10.
http://admin.fedoraproject.org/updates/pdftk-1.41-14.fc10

Comment 5 Raman Gupta 2009-03-31 16:16:12 UTC
Thank you, I can confirm the 1.41-14 version works!

Comment 6 Fedora Update System 2009-04-02 17:16:35 UTC
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 18:41:23 UTC
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:
   /dev/stdin
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 19:04:08 UTC
pdftk-1.41-15.fc10 has been submitted as an update for Fedora 10.
http://admin.fedoraproject.org/updates/pdftk-1.41-15.fc10

Comment 9 Fedora Update System 2009-04-13 19:36:54 UTC
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 08:55:58 UTC
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);
		fclose($pipes[0]);

		$data = "";
		while(!feof($pipes[1])) {
			$pdf_data.= fgets($pipes[1], 1024);
		}
		fclose($pipes[1]);
		// 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 08:57:23 UTC
correction of my previous post. The version use is pdftk-1.41-15.fc10.x86_64

Comment 12 Orcan Ogetbil 2009-05-18 15:35:38 UTC
Could you try the latest version available in the updates ?
(pdftk-1.41-19.fc10.x86_64)

Also could you add a real name to your profile?

Comment 13 Laurent NEGRIER 2009-05-18 16:01:56 UTC
The update works with both command line and php.

Thank you !

Comment 14 Orcan Ogetbil 2009-05-18 16:20:23 UTC
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.