pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tilman Hausherr <THaush...@t-online.de>
Subject Re: Problem with setting PageMode
Date Mon, 05 Feb 2018 20:50:01 GMT
Replace this line

PDDocumentCatalog pg = new PDDocumentCatalog(mergedPDF) ;

with this:

PDDocumentCatalog pg = mergedPDF.getDocumentCatalog();

Your line recreated the document root. I'll see whether the javadoc 
should warn against doing this.


Am 05.02.2018 um 21:40 schrieb William Nardone:
> ________________________________
> HI,
> We are using PDFBox to merge documents, change a few settings after the merge, then secure
and encrypt the document.  Everything is working except when we attempt to set the PageMode;
the resulting document is corrupt and cannot be opened.   We've stripped everything down to
open the source file, update the pageMode, and save to a target file with a different name.
 But we still get the same error.  The same thing happens for PageLayout, and when I try to
fetch the Page Viewer preferences I get a null pointer.  [PDViewerPreferences vp = pg.getViewerPreferences();
> The initial error is cannot open this file.  There was a problem reading this document
> Hitting ctrl-OK button gives:  Expected a dict object.
> Code snippet:
>              mergedPDF = PDDocument.load( new File(sourceFileName));
>              PDDocumentCatalog pg = new PDDocumentCatalog(mergedPDF) ;
>              PageMode pm = PageMode.USE_OUTLINES ;
>              pg.setPageMode(pm);
>              mergedPDF.save(targetFileName);
>              mergedPDF.close();
> Using PDFBox 2.0.8
> eclipse Version: Mars.2 Release (4.5.2)
> Java 8.0.73
> original pdf file has Version: 1.6 (Acrobat 7.x)
> We are trying to wrap up this project and like PDFBox, but need to get past this problem.
 Please provide any suggestions on how to fix this.
> Thanks
> Bill Nardone
> Tata Consultancy Services Limited
> Cell: +1 (609) 600-7863
> ____________________________________________
> Experience certainty.     IT Services
>                                      Business Solutions
>                                      Consulting                         .
> =====-----=====-----=====
> Notice: The information contained in this e-mail
> message and/or attachments to it may contain
> confidential or privileged information. If you are
> not the intended recipient, any dissemination, use,
> review, distribution, printing or copying of the
> information contained in this e-mail message
> and/or attachments to it are strictly prohibited. If
> you have received this communication in error,
> please notify us by reply e-mail or telephone and
> immediately and permanently delete the message
> and any attachments. Thank you

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

View raw message