What is initial view?
A PDF document may have an initial view which determines how the document opens in PDF viewing software like Adobe Acrobat or JPedal Viewer.
The initial view can dictate which page the document should be opened on, the layout of the pages, and even which interactive panels should be open (e.g. the page thumbnails panel).
What is JPedal?
JPedal is our Java PDF library which we have been developing for over 20 years! It comes with a rich feature set and robust support for all kinds of PDF files.
How to set the initial view with JPedal?
First, you will need to download a JPedal jar and add it to your Java project. You can get a trial copy from our website.
Next, you need to create an instance of PdfManipulator, load the desired PDF, and use the set initial view command.
The example code below sets the initial view of a PDF to open on page 3, using a two page view mode, with the thumbnails panel open.
final PdfManipulator pdf = new PdfManipulator();
pdf.loadDocument(new File("inputFile.pdf"));
pdf.setInitialView(3, new Destination.Fit(),
PageLayout.TWO_PAGE_LEFT,
PageMode.USE_THUMBS);
pdf.apply();
pdf.writeDocument(new File("outputFile.pdf"));
pdf.closeDocument();
Download JPedal
You can get a JPedal trial jar to test setting the initial view of PDF files.
Resources
Learn more about the PDF Manipulator API.
We can help you better understand the PDF format as developers who have been working with the format for more than 2 decades!