Click or drag to resize
Pdf Library for .NET

Pdf Viewer Preferences

A pdf document can control the way it will be displayed when opened in a pdf viewer. When the pdf document is generated as a result of an html to pdf conversion, these properties can be set using ViewerPreferences property of the HtmlToPdfOptions object.

The following customizations can be done using the HtmlToPdfViewerPreferences object:

Property

Description

HideToolbar

A flag specifying whether to hide the pdf viewer application's tool bars when the document is active

HideMenuBar

A flag specifying whether to hide the pdf viewer application's menu bar when the document is active.

HideWindowUI

A flag specifying whether to hide user interface elements in the document's window (such as scroll bars and navigation controls), leaving only the document's contents displayed.

FitWindow

A flag specifying whether to resize the document's window to fit the size of the first displayed page.

CenterWindow

A flag specifying whether to position the document's window in the center of the screen.

DisplayDocTitle

A flag specifying whether the window's title bar should display the document title.

PageMode

The document page mode when the pdf document is opened in a pdf viewer. Possible values:

UseNone

Neither document outline (bookmarks) nor thumbnail images are visible.

UseOutlines

Document outline (bookmarks) are visible.

UseThumbs

Thumbnail images are visible.

FullScreen

Full-screen mode, with no menu bar, window controls or any other window visible.

UseOC

Optional content group panel is visible.

UseAttachments

Document attachments are visible.

PageLayout

The page layout to be used when the document is opened. Possible values:

SinglePage

Displays one page at a time.

OneColumn

Displays the pages in one column.

TwoColumnLeft

Displays the pages in two columns, with odd-numbered pages on the left.

TwoColumnRight

Displays the pages in two columns, with odd-numbered pages on the right.

NonFullScreenPageMode

The document page mode when the pdf viewer application exits the full screen mode. Possible values:

UseNone

Neither document outline (bookmarks) nor thumbnail images are visible.

UseOutlines

Document outline (bookmarks) are visible.

UseThumbs

Thumbnail images are visible.

UseOC

Optional content group panel is visible.

Code Sample

This sample code shows how to convert from html to pdf using Select.Pdf and set the pdf viewer preferences.

// instantiate a html to pdf converter object
HtmlToPdf converter = new HtmlToPdf();

// set converter options
converter.Options.ViewerPreferences.CenterWindow = true;
converter.Options.ViewerPreferences.DisplayDocTitle = true;
converter.Options.ViewerPreferences.FitWindow = true;
converter.Options.ViewerPreferences.HideMenuBar = true;
converter.Options.ViewerPreferences.HideToolbar = true;
converter.Options.ViewerPreferences.HideWindowUI = true;

converter.Options.ViewerPreferences.PageLayout = PdfViewerPageLayout.SinglePage;
converter.Options.ViewerPreferences.PageMode = PdfViewerPageMode.UseNone;
converter.Options.ViewerPreferences.NonFullScreenPageMode = PdfViewerFullScreenExitMode.UseNone;

// create a new pdf document converting an url
PdfDocument doc = converter.ConvertUrl(url);

// save pdf document
doc.Save(Response, false, "Sample.pdf");

// close pdf document
doc.Close();
See Also