Summary: | Smaller PDFs when using execform | ||
---|---|---|---|
Product: | Ghostscript | Reporter: | SaGS <sags5495> |
Component: | PDF Writer | Assignee: | Ken Sharp <ken.sharp> |
Status: | RESOLVED FIXED | ||
Severity: | enhancement | CC: | alex, christinedelight.top85, shailesh.mistry |
Priority: | P3 | Keywords: | bountiable |
Version: | master | ||
Hardware: | PC | ||
OS: | All | ||
Customer: | Word Size: | --- | |
Attachments: |
Short test file.
Suggested patch. Patch modified for OrderResources. |
Description
SaGS
2004-07-05 10:29:38 UTC
Created attachment 791 [details] Short test file. It's the one from bug 687560 "Invalid PDF if /BP pdfmarks with non-unique /_objdef", rewritten to use PostScript forms instead of /BP-/EP-/SP pdfmarks. Created attachment 792 [details]
Suggested patch.
For this patch to work fully, the patch for the aforementioned
bug must be applied too. I didn't include any changes to the docs.
Created attachment 869 [details]
Patch modified for OrderResources.
At present, OrderResources == true does not correctly handle
named objects, and these are written at the very end of the output
PDF. This makes Form XObjects unavailable when the page
referencing them is printed. For this reason, I modified
execform1_xobj to deactivate all its "caching using Form XObjects"
when OrderResources is true.
*** Bug 688001 has been marked as a duplicate of this bug. *** Here are some considerations about forms. 1. 'execform' must tell to the device interface about starting and ending a form. 2. Since the Postscript form procedutre may depend on context, each execution to be accumulated as a stream resource. Then equal resources to be merged. (This technique has been implemented for charproc variations.) 3. Doing (3), the CTM to be factored out. Consequently CTM to be passed in (1). Please don't expect a quick resolution. We're busy with higher priority projects. It needs new special PS operators for .startform amd .endform, then a signal to pdev->procs.pattern_manage, then an accumulating a substream in pdfwrite. The last is the most difficult part, so passing it to Ken whi handles pdfwrite. Enhancement still missing in Ghostscript 9.03 I believe commit c561232cf26e060b89fc4f3bd4bf5c679731d4db will resolve this. Interestingly, Adobe Acrobat Distiller cannot process this test file very efficiently. Each invocation of the form resource ends up as a separate form XObject in the PDF file. pdfwrite only emits one form XObject, so we are more efficient.... Note that any form which relies on the CTM having particular settings will fail with this commit, because we reset the CTM in order to capture the form stream without the CTM baked in. Two Quality Logic files break this, one uses setgstate inside the form to set the gstate to a stgate before the form was executed (this is of course completely barking mad). The other uses setflat and bases the value on the CTM at the time the form is executed. Because we reset the CTM for the course of the form, the setflat value is only appropriate for low resolution. For these cases a new switch -dUNROLLFORMS will prevent pdfwrite attempting to preserve the form resource. The result will be correct, at the cost of the output being larger of course. |