Convert to PDF with advanced options

GroupDocs.Conversion provides PdfConvertOptions to give you control over conversion result when convert to PDF. Along with common convert options  PdfConvertOptions has the following additional options:

  • setFormat specifies desired result document type. Available options are: Pdf, Epub, Xps, Tex, Ps, Pcl.
  • setWidth specifies desired image width after conversion.
  • setHeight specifies desired image height after conversion.
  • setDpi specifies desired page DPI after conversion.
  • setPassword whether set the converted document will be protected with specified password.
  • setMarginTop specifies desired page top margin after conversion.
  • setMarginBottom specifies desired page bottom margin after conversion.
  • setMarginLeft specifies desired page left margin after conversion.
  • setMarginRight specifies desired page right margin after conversion.
  • setPdfOptions specifies PDF specific convert options.
  • setRotate specifies page rotation. Available options are: None, On90, On180, On270.

The following code snippet shows how to convert to PDF with advanced options

const loadOptions = new groupdocs.conversion.WordProcessingLoadOptions()
loadOptions.setPassword("12345");

const converter = new groupdocs.conversion.Converter('sample.docx')
const convertOptions = new groupdocs.conversion.PdfConvertOptions();

convertOptions.setPageNumber(2);
convertOptions.setPagesCount(1);
convertOptions.setRotate(groupdocs.conversion.Rotation.On180);
convertOptions.setDpi(300);
convertOptions.setWidth(1024);
convertOptions.setHeight(768);

converter.convert("converted.pdf", convertOptions);

PdfOptions

PdfOptions class provides specific options when converting document to different versions of PDF format.

PdfOptimizationOptions

PdfOptimizationOptions class allows to specify options for adjusting PDF conversion process and improve its speed.

PdfFormattingOptions

PdfFormattingOptions class provides different options to change PDF document look.

  • setCenterWindow specifies whether position of the document’s window will be centered on the screen.
  • setDirection sets reading order of text: L2R (left to right) or R2L (right to left). Available options are: L2R, R2L.
  • setDisplayDocTitle specifies whether document’s window title bar should display document title.
  • setFitWindow specifies whether document window must be resized to fit the first displayed page.
  • setHideMenuBar specifies whether menu bar should be hidden when document is active.
  • setHideToolBar specifies whether toolbar should be hidden when document is active.
  • setHideWindowUI specifies whether user interface elements should be hidden when document is active.
  • setNonFullScreenPageMode specifies how to display the document on exiting full-screen mode. Available options are: UseNone, UseOutlines, UseThumbs, FullScreen, UseOC, UseAttachments.
  • setPageLayout sets page layout which shall be used when the document is opened. Available options are: Default, SinglePage, OneColumn, TwoColumnLeft, TwoColumnRight, TwoPagesLeft, TwoPagesRight.
  • setPageMode - specifying how document should be displayed when opened.