Foxit Quick PDF Library

Programmatically set initial view zoom magnification using Foxit Quick PDF Library

The PDF specification doesn’t have a simple document setting that specifies the initial page number and zoom magnification.

However it is possible to add an “open action” to the document that specifies the action to perform when the document is opened.

Foxit Quick PDF Library’s SetOpenActionDestination function allows you to set the initial page and the zoom level:

// Create a two page document with the
// page number shown on each page

QP.NewDocument();
QP.DrawText(100, 500, "Page 1");
QP.NewPage();
QP.DrawText(100, 500, "Page 2");

// Set the page layout to "Single page". This step isn't needed but
// shows the zoom effect nicely
QP.SetPageLayout(0);

// Set the open action to show page 2 at 25% zoom
QP.SetOpenActionDestination(2, 25);

// Save the file
QP.SaveToFile("C:\Page2-Zoom25.pdf");

There are two other functions that allow greater control of the open action.

The SetOpenActionDestinationFull function allows you to set the initial page and specify advanced sizing/positioning options.

A JavaScript open action can be added using the SetOpenActionJavaScript function. For this to work the user must have JavaScript enabled in their PDF viewer.

This article refers to a deprecated product. If you are looking for support for Foxit PDF SDK, please click here.

Updated on May 16, 2022

Was this article helpful?
Thanks for your feedback. If you have a comment on how to improve the article, you can write it here: