Developer Tools
|
Office Productivity Applications
|
Platform-Agnostic APIs
|
Home | Online Demos | Downloads | Buy Now | Support | About Us | News | Working Together | Contact Us
The DocumentConverter class is used to convert DOCX and PDF documents and images to other formats. In this article, we will see how to convert documents to images and also use the various conversion settings in the process.
This code snippet converts a DOCX document to an image. It is aligned to the top of the page. The content from the original document is not resized. The pixel density of the image is 96.
public class ConvertToImage { public static void main(String[] args) { DocumentConverter dc = new DocumentConverter(); try { ImageEncoderSettings ies = (ImageEncoderSettings) dc.getPreferences().getEncoderSettings("image/png"); ies.setPageAlignment(new PageAlignment(Horizontal.CENTER, Vertical.CENTER)); ies.setPageScaling(com.gnostice.documents.image.PageScaling.NONE); ies.setPageSizingMode(PageSizingMode.USE_PAGE_SIZE); dc.getPreferences().getRenderingSettings().getResolution().setDpi(96); dc.convertToFile("./ad.pdf", "./sample.png"); } catch (FormatNotSupportedException e) { e.printStackTrace(); } catch (ConverterException e) { e.printStackTrace(); } catch (XDocException e) { e.printStackTrace(); } } }
The image looks unwieldy. Some changes...
ies.setPageScaling(com.gnostice.documents.image.PageScaling.NONE); ies.setPageSize(new PageSize(PaperSize.A4)); ies.setPageSizingMode(PageSizingMode.USE_RELATIVE_SIZE); dc.getPreferences().getRenderingSettings().getResolution().setDpi(150);
---o0O0o---
Our .NET Developer Tools | |
---|---|
Gnostice Document Studio .NETMulti-format document-processing component suite for .NET developers. |
PDFOne .NETA .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications. |
Our Delphi/C++Builder developer tools | |
---|---|
Gnostice Document Studio DelphiMulti-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms. |
eDocEngine VCLA Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools. |
PDFtoolkit VCLA Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents. |
Our Java developer tools | |
---|---|
Gnostice Document Studio JavaMulti-format document-processing component suite for Java developers. |
PDFOne (for Java)A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications. |
Our Platform-Agnostic Cloud and On-Premises APIs | |
---|---|
StarDocsCloud-hosted and On-Premises REST-based document-processing and document-viewing APIs |
Privacy | Legal | Feedback | Newsletter | Blog | Resellers | © 2002-2024 Gnostice Information Technologies Private Limited. All rights reserved. |