Hi,

It's not supported. Supporting it would be a bit of work, i.e. making a (partial?) clone of the OCG stuff (not just assign it) for each split document and then find and remove "orphans".

Same for the structure tree (which is probably 10x more complicated).

Tilman

On 31.07.2023 19:15, Stefan Wurzinger wrote:
Hi,

when using the org.apache.pdfbox.multipdf.Splitter the resulting documents 
don't contain any information about the optional content (OC) blocks in the 
document (see chapters 4.10 and 10.5 in the PDF 1.6 Spec) anymore, which 
results in making all optional content visible.

Example (Kotlin):

         URL("https://www.pdfill.com/example/pdf_layer_new.pdf";).openStream().use 
{ inputStream ->
             PDDocument.load(inputStream).use { inputDoc ->
                 val resultDocs = Splitter().apply {
                     setStartPage(1)
                     setEndPage(1)
                 }.split(inputDoc)
                 val resultDoc = resultDocs.first()
                 // resultDoc.documentCatalog.ocProperties = 
inputDoc.documentCatalog.ocProperties
                 resultDoc.save(File("pdf_layer_new-split.pdf"))
             }
         }

One can copy the ocProperties from the original document (see commented line in 
example above) which seems to fix the issue, but doesn't remove unused OCGs 
when they're not referenced on the split page(s).

Is this intended behaviour and is copying the original ocProperties a proper 
workaround?

Thanks for your suggestions.

Best Regards,
Stefan Wurzinger

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org

Reply via email to