Bug 687125 - location of %PDF header
Summary: location of %PDF header
Status: NOTIFIED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Interpreter (show other bugs)
Version: 8.11
Hardware: PC All
: P3 minor
Assignee: Alex Cherepanov
URL:
Keywords:
: 687601 688630 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-11-06 09:05 UTC by James Quirk
Modified: 2008-12-19 08:31 UTC (History)
3 users (show)

See Also:
Customer:
Word Size: ---


Attachments
test of PDF floating header (488.64 KB, application/pdf)
2003-11-10 07:36 UTC, James Quirk
Details
patch (2.81 KB, patch)
2007-04-08 11:29 UTC, Alex Cherepanov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description James Quirk 2003-11-06 09:05:41 UTC
GhostScript requires that a PDF file start with ``%PDF-n.m''  but
Adobe's PDF Reference stipulates: ``Acrobat viewers require only that the header
appear somewhere within the first 1024 bytes of the file.'' A similar
stipulation exists for ``%%EOF'' appearing in the last 1024 bytes of a file.
Now some applications generate PDF's that are wrapped in a GPG signature or
include a header that turns the document into a self-extracting archive.
They can be read by both Acroread and Xpdf, but not by GhostScript.
The obvious workaround is to filter such files before they are fed
to GhostScript for viewing. But the best long term solution 
would be to make GhostScript adhere to Adobe's notion of a floating header.
The required bug-fix would likely impact on past fixes that dealt with
problems where a PS file was incorrectly identified as a PDF file.
Comment 1 Dan Coby 2003-11-09 23:18:40 UTC
Please attach an example file.
Comment 2 James Quirk 2003-11-10 07:36:25 UTC
Created attachment 354 [details]
test of PDF floating header

The bug can be reproduced with any PDF file. Simply prepend a PDF by a blank
line,
or a few lines of text, then try viewing the modified file with Acroread, Xpdf
and Ghostscript. 
This attachment, for example, prepends four lines to the file ``annots.pdf''
shipped
with GhostScript v8.11. It can be viewed with Acroread and Xpdf, but not by
Ghostsript.
For a realistic example of a PDF file with text before the document header,
see:

 http://www.amrita-ebook.org/download/AMRITAv2.25
Comment 3 Ray Johnston 2004-09-01 23:12:27 UTC
*** Bug 687601 has been marked as a duplicate of this bug. ***
Comment 4 Ray Johnston 2006-04-04 09:34:17 UTC
*** Bug 688630 has been marked as a duplicate of this bug. ***
Comment 5 Alex Cherepanov 2007-04-08 11:29:49 UTC
Created attachment 2868 [details]
patch

Increase the size of %stdin buffer to support larger lookahead requests and
look for for %PDF- tag in the first 1024 bytes of the file.

Ignore annotations without /Subtype hey to process one of the samp[le files.

DIFFERENCES:
No CET or Comparefiles differences.
Comment 6 Alex Cherepanov 2007-04-08 11:47:22 UTC
The patch is committed as rev. 7835 and 7835.