Bug 695151

Summary: Add BMC/EMC and BDC pdfmark support
Product: Ghostscript Reporter: Ken Sharp <ken.sharp>
Component: PDF WriterAssignee: Ken Sharp <ken.sharp>
Status: RESOLVED FIXED    
Severity: enhancement CC: a.grahn
Priority: P4 Keywords: bountiable
Version: master   
Hardware: PC   
OS: Windows 7   
Customer: Word Size: ---
Attachments: BDC, BMC, EMC implementation
BDC,BMC,EMC implementation
test case

Description Ken Sharp 2014-04-11 03:10:10 UTC
Place holder report for some bountiable work implementing the relevant pdfamrk operators.
Comment 1 Ken Sharp 2014-04-11 03:10:42 UTC
Bountiable for Alexander Grahn
Comment 2 Alexander Grahn 2014-04-11 12:16:05 UTC
The patches for gdevpdfm.c and gdevpdfx.h against the 9.14 sources implement BDC, BMC and EMC pdfmarks. These are necessary for the creation of optional content groups (OCGs, aka  PDF layers). There is support for PDF layers in poppler-based PDF viewers, such as Evince.

The BDC pdfmark accepts {object name}, even as a forward reference, as well as <<inline dict>> as the propdict argument.

A Postscript test file uses BDC and EMC pdfmarks for OCGs. It covers BDC/EMC usage in the page content as well as in XObject streams.
Comment 3 Alexander Grahn 2014-04-11 12:18:14 UTC
Created attachment 10821 [details]
BDC, BMC, EMC implementation
Comment 4 Alexander Grahn 2014-04-11 12:19:17 UTC
Created attachment 10822 [details]
BDC,BMC,EMC implementation
Comment 5 Alexander Grahn 2014-04-11 12:20:15 UTC
Created attachment 10823 [details]
test case
Comment 6 Ken Sharp 2014-04-15 01:36:56 UTC
Patch adopted in commit b90e081b8ad9b64ae4b66bd27262a9582c129cfc I did add a very small change to release the memory used by the Properties resources at the end of the job.
Comment 7 Ken Sharp 2014-04-15 02:05:35 UTC
I just discovered that several files produced by pdfwrite with this change in place fail when opened with Acrobat (they can be opened with Ghostscript).

I'm going to revert the commit until I can figure out why.
Comment 8 Ken Sharp 2014-04-15 02:11:04 UTC
The file attached to Bug #688000 exhibits a problem with Acrobat. It seems Acrobat doesn't like an empty Properties dictionary.
Comment 9 Alexander Grahn 2014-04-16 01:07:58 UTC
Perhaps, there is something wrong with the pdf_alloc_resource(...) call in the pdfmark_BDC() function. Could you please check the argument values passed to it?
Comment 10 Ken Sharp 2014-04-16 01:14:19 UTC
(In reply to comment #9)
> Perhaps, there is something wrong with the pdf_alloc_resource(...) call in
> the pdfmark_BDC() function. Could you please check the argument values
> passed to it?

I'll try and get back to this today, I have (I think) finally got transparency in annotations detected and now working with the new FreeText annotation appearance synthesis code.

It 'looks like' the marked content isn't being written properly, possibly because the file in question is an EPS and doesn't emit a showpage (it does have pdfmark operators to mark the entire content).
Comment 11 Ken Sharp 2014-04-18 03:32:23 UTC
commit 12e2eafa38a9932bb136879374423de133075a4a reinstates the patch with one very small addition to prevent us writing a duplicate (empty) object for the properties dictionary. It also addresses a bug in the ps2write header (opdfread.ps) which would cause an error if the output contained a BMC, BDC or EMC object.

As far as I'm concerned this is now completed.