Thanks a lot, that did the trick! And if someone is reading this and wants to do the same to the Magnification setting (ie, set it to Default), you can just set the document's OpenAction to null.
On Mon, Mar 6, 2017 at 10:51 PM, Tilman Hausherr <[email protected]> wrote: > Am 06.03.2017 um 22:37 schrieb Gilad Denneboom: > >> When I select the "Default" option in Acrobat it doesn't behave the same >> as >> the "Single Page" option, though, and when I examine the file's internal >> structure I can see that the Default option basically means that the >> PageLayout parameter is missing from the Root. So should it not be >> possible >> to reset this setting using PDFBox? >> > > sure, just do this: > > doc.getDocumentCatalog().getCOSObject().removeItem(COSName.PAGE_LAYOUT); > > > > Tilman > > >> On Mon, Mar 6, 2017 at 9:48 PM, Tilman Hausherr <[email protected]> >> wrote: >> >> Am 06.03.2017 um 20:21 schrieb Gilad Denneboom: >>> >>> It was this: >>>> doc.getDocumentCatalog().setPageLayout("Default"); >>>> >>>> There is no such layout. It is kindof a bug that 1.8 allowed you to pass >>> an invalid value. Valid values: >>> >>> SinglePageDisplay one page at a time >>> OneColumnDisplay the pages in one column >>> TwoColumnLeftDisplay the pages in two columns, with odd-numbered pages on >>> the left >>> TwoColumnRightDisplay the pages in two columns, with odd-numbered pages >>> on >>> the right >>> TwoPageLeft(PDF 1.5) Display the pages two at a time, with odd-numbered >>> pages on the left >>> TwoPageRight(PDF 1.5) Display the pages two at a time, with odd-numbered >>> pages on the right >>> Default value: SinglePage. >>> >>> >>> So this works: >>> >>> public class SetLayout >>> { >>> public static void main(String[] args) throws IOException >>> { >>> try (PDDocument doc = new PDDocument()) >>> { >>> PDPage page = new PDPage(); >>> doc.addPage(page); >>> page = new PDPage(); >>> doc.addPage(page); >>> doc.getDocumentCatalog().setPageLayout(PageLayout.TWO_PAGE_LEFT); >>> doc.save(new File("layout.pdf")); >>> } >>> } >>> } >>> >>> >>> >>> >>> Tilman >>> >>> >>> >>> >>> On Mon, Mar 6, 2017 at 6:26 PM, Tilman Hausherr <[email protected]> >>>> wrote: >>>> >>>> Am 06.03.2017 um 16:53 schrieb Gilad Denneboom: >>>> >>>>> Hi all, >>>>> >>>>>> I'm setting various Initial View settings, including the Page Layout >>>>>> setting which I want to set as Default, but this does not seem to be >>>>>> one >>>>>> of >>>>>> the options of the PageLayout enum, nor does it accept it when I use >>>>>> the >>>>>> fromString method and supply "Default", "" or null as the input >>>>>> parameter. >>>>>> This works in PDFBox 1.x... >>>>>> Any ideas how to achieve it with the new version? >>>>>> >>>>>> Could you please post the code you used in 1.8 ? >>>>>> >>>>> Tilman >>>>> >>>>> >>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: [email protected] >>>>> For additional commands, e-mail: [email protected] >>>>> >>>>> >>>>> >>>>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [email protected] >>> For additional commands, e-mail: [email protected] >>> >>> >>> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >

