![]() Save the document to a PDF file using PdfDocument.saveToFile() method.Draw the PdfImage object on the first page at (0, 0) using PdfPageBase.getCanvas().drawImage() method.spreadsheets and images to PDF format with this free online PDF converter. Create a PdfImage object based on the scaled image or the original image. The Image class represents graphical images and is used for loading images from a specified URL. Open HTML to PDF is a pure-Java library for rendering arbitrary well-formed.If the image width is larger than the page (the content area) width, resize the image to make it to fit to the page width using the imgscalr library.Load an image using ImageIO.read() method, and get the image width and height.Add a page using PdfDocument.getPages().add() method.Set the page margins using PdfDocument.getPageSettings().setMargins() method.The following are the steps to add an image to PDF at a specified location using Spire.PDF for Java. It is not necessary to install it if you do not need to adjust the image’s size.Īdd an Image to PDF at a Specified Location This class allows resizing the displayed image (with or without preserving the original aspect ratio) and specifying a viewport into the source image for restricting the pixels displayed by this ImageView. ![]() If you use Maven, you can easily import the JAR file in your application by adding the following code to your project's pom.xml file.Īdditionally, the imgscalr library is used in the first code example to resize images. The ImageView is a Node used for painting images loaded with Image class. The JAR file can be downloaded from this link.
0 Comments
Leave a Reply. |