Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created February 9, 2021 04:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/032de2b87650c56a000bbcc55535f8e5 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/032de2b87650c56a000bbcc55535f8e5 to your computer and use it in GitHub Desktop.
Convert GIF to PDF in Java
// Load GIF image
com.aspose.imaging.Image image = com.aspose.imaging.Image.load("image.gif");
// Set image options
com.aspose.imaging.imageoptions.PdfOptions options = new com.aspose.imaging.imageoptions.PdfOptions();
// Convert first frame of GIF to PDF
options.setMultiPageOptions(new com.aspose.imaging.imageoptions.MultiPageOptions(1));
// Save PDF
image.save("gif-to-pdf.pdf", options);
// Load GIF image
com.aspose.imaging.Image image = com.aspose.imaging.Image.load("image.gif");
// Set image options
com.aspose.imaging.imageoptions.PdfOptions options = new com.aspose.imaging.imageoptions.PdfOptions();
// Create PdfDocumentInfo object and add information
PdfDocumentInfo docInfo = new PdfDocumentInfo();
docInfo.setAuthor("Aspose");
docInfo.setKeywords("GIF to PDF");
docInfo.setSubject("GIF to PDF Convesion");
docInfo.setTitle("Converting GIF Image to PDF File");
// Set document info
options.setPdfDocumentInfo(docInfo);
// Save PDF
image.save("gif-to-pdf.pdf", options);
// Load GIF image
com.aspose.imaging.Image image = com.aspose.imaging.Image.load("image.gif");
// Set image options
com.aspose.imaging.imageoptions.PdfOptions options = new com.aspose.imaging.imageoptions.PdfOptions();
// Set size of the page
options.setPageSize(new SizeF(50, 100));
// Save PDF
image.save("gif-to-pdf.pdf", options);
// Load GIF image
com.aspose.imaging.Image image = com.aspose.imaging.Image.load("image.gif");
// Set image options
com.aspose.imaging.imageoptions.PdfOptions options = new com.aspose.imaging.imageoptions.PdfOptions();
// Save PDF file
image.save("gif-to-pdf.pdf", options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment