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:

  • Format - desired result document type. Available options are: Pdf, Epub, Xps, Tex, Ps, Pcl
  • Width - desired image width after conversion
  • Height - desired image height after conversion
  • Dpi - desired page DPI after conversion
  • Password - if set the converted document will be protected with specified password
  • MarginTop - desired page top margin after conversion
  • MarginBottom - desired page bottom margin after conversion
  • MarginLeft - desired page left margin after conversion
  • MarginRight - desired page right margin after conversion
  • PdfOptions - PDF specific convert options
  • Rotate - page rotation. Available options are: None, On90, On180, On270

Following code snippet shows how to convert to PDF with advanced options.

using (Converter converter = new Converter("sample.docx"))
{
    PdfConvertOptions options = new PdfConvertOptions
    {
        PageNumber = 2,
        PagesCount = 1,
        Rotate = Rotation.On180,
        Dpi = 300,
        Width = 1024,
        Height = 768
    };
    converter.Convert("converted.pdf", options);
}

PdfOptions

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

  • PdfFormat - sets pdf format of the converted document. Available options are: Default, PdfA_1A, PdfA_1B, PdfA_2A, PdfA_3A, PdfA2B, PdfA_2U, PdfA_3B, PdfA_3U, v1_3, v1_4, v1_5, v1_6, v1_7, PdfX_1A, PdfX_3
  • RemovePdfACompliance - removes Pdf-A compliance
  • Zoom - specifies the zoom level in percentage
  • Linearize - linearizes PDF document for web
  • Grayscale - convert to grayscale PDF
  • OptimizationOptions - PDF optimization options
  • FormattingOptions - PDF formatting options

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.

  • CenterWindow - specifies whether position of the document’s window will be centered on the screen
  • Direction - sets reading order of text: L2R (left to right) or R2L (right to left). Available options are: L2R, R2L
  • DisplayDocTitle - specifies whether document’s window title bar should display document title
  • FitWindow - specifies whether document window must be resized to fit the first displayed page
  • HideMenuBar - specifies whether menu bar should be hidden when document is active
  • HideToolBar - specifies whether toolbar should be hidden when document is active
  • HideWindowUI - specifies whether user interface elements should be hidden when document is active
  • NonFullScreenPageMode - specifying how to display the document on exiting full-screen mode. Available options are: UseNone, UseOutlines, UseThumbs, FullScreen, UseOC, UseAttachments
  • PageLayout - sets page layout which shall be used when the document is opened. Available options are: Default, SinglePage, OneColumn, TwoColumnLeft, TwoColumnRight, TwoPagesLeft, TwoPagesRight
  • PageMode - specifying how document should be displayed when opened. Available options are: UseNone, UseOutlines, UseThumbs, FullScreen, UseOC, UseAttachments

More resources

Examples and Demos

Please find more use-cases and complete C# sources of our backend and frontend examples and try them for free!