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 - desired result document type. Available options are: Pdf, Epub, Xps, Tex, Ps, Pcl
- setWidth - desired image width after conversion
- setHeight - desired image height after conversion
- setDpi - desired page DPI after conversion
- setPassword - if set the converted document will be protected with specified password
- setMarginTop - desired page top margin after conversion
- setMarginBottom - desired page bottom margin after conversion
- setMarginLeft - desired page left margin after conversion
- setMarginRight - desired page right margin after conversion
- setPdfOptions - PDF specific convert options
- setRotate - page rotation. Available options are: None, On90, On180, On270
Following code snippet shows how to convert to PDF with advanced options
WordProcessingLoadOptions loadOptions = new WordProcessingLoadOptions();
loadOptions.setPassword("12345");
Converter converter = new Converter("sample.docx");
PdfConvertOptions options = new PdfConvertOptions();
options.setPageNumber(2);
options.setPagesCount(1);
options.setRotate(Rotation.On180);
options.setDpi(300);
options.setWidth(1024);
options.setHeight(768);
converter.convert("converted.pdf", options);
PdfOptions
PdfOptions class provides specific options when converting document to different versions of PDF format.
- setPdfFormat - 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
- setRemovePdfACompliance - removes Pdf-A compliance
- setZoom - specifies the zoom level in percentage
- setLinearize - linearizes PDF document for web
- setGrayscale - convert to grayscale PDF
- setOptimizationOptions - PDF optimization options
- setFormattingOptions - PDF formatting options
PdfOptimizationOptions
PdfOptimizationOptions class allows to specify options for adjusting PDF conversion process and improve its speed.
- setLinkDuplicateStreams - link duplicate streams
- setRemoveUnusedObjects - remove unused objects
- setCompressImages - if set to true, all images in the document are re-compressed. The amount of compression and image quality are defined by the setImageQuality
- setImageQuality - value in percent where 100% is unchanged quality and image size. To decrease the image size set this property to less than 100
- setUnembedFonts - make fonts not embedded
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 - specifying 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
More resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples:
- GroupDocs.Conversion for .NET examples, plugins, and showcase
- GroupDocs.Conversion for Java examples, plugins, and showcase
- Document Conversion for .NET MVC UI Example
- Document Conversion for .NET App WebForms UI Modern Example
- Document Conversion for Java App Dropwizard UI Modern Example
- Document Conversion for Java Spring UI Example
Free Online Document Converter Apps
Along with full-featured Java library we provide free Apps and free services for document conversion.
In order to see a full potential of GroupDocs.Conversion, you are welcome to convert DOC to PDF, DOC to XLSX, PDF to DOC, PDF to XLSX, PPT to DOC and more with Free Online Document Converter App or get a full advantage of Free Online Document Converter Suite with advanced conversion settings and many more enterprise built-in features.
Please note that more premium features, advanced options and enhanced document management experience is available for signed-in users at conholdate.app for FREE.
If you don’t own an account yet, register it now for free! No credit card is required!