Note that this is part of a series where we use Adobe PDF Library (APDFL) to extract or recreate the information contained in the Adobe Acrobat’s Document Properties tab.
If you have never used the full version of Adobe Acrobat, just Reader, then you might not be familiar with the Initial View tab, which is missing from Reader’s Document Properties window because it allows you to see and modify some aspects of how the PDF document is presented in Acrobat or Reader.
There are 11 pieces of information shown in this tab. So let’s go through recreating this information piece by piece.
This piece is relatively straightforward to extract via the PDDocGetPageMode call, which returns an enumeration value, which you switch off of and you’re done; Except that the PDDontCare value seems to be handled the same as PDUseNone.
Essentially handled the same as the navigation Tab, but with the PDDocGetLayoutMode call.
Here the code starts getting a little bit more interesting. The key information is in the document’s OpenAction, from which you extract a ViewDestination with a page and a Fit Type. We will need the ViewDestination page in a bit, but the XYZ Fit Type requires special handling to match Acrobat. If the Zoom factor in a View destination is null or zero, then the magnification factor is inherited from the viewer (aka ‘Default’), but otherwise, the zoom factor is displayed in the Initial View’s Magnification entry as a percentage.
Open To Page:
This is where we use the page information from the openAction viewDestination. This code is a little bit tricky because the InitialView does not show raw page numbers but page numbers formatted with the page labels and there is an additional wrinkle in that if the endpage label does not correspond to the raw page count, then Acrobat will tack on a page count in parentheses.
Most of these options can be read directly from the ViewerPreferences dictionary entry in the root catalog, at the cos level as shown below, as there is no high-level function for reading these values, with the exception of the PDDocGetFullScreen call, which is a bit of an odd duck because the fullscreen flag is actually part of the layout mode.
User Interface Options:
Extracting the last group of options is almost identical to the previous group, but there is a security restriction in that Acrobat will not allow you to turn off all of the UI components. If it detects that all of the UI components are to be turned off, then it will re-enable the Menu bar.
The full code is available here.