LibrePDF / OpenPDF

OpenPDF is a free Java library for creating and editing PDF files, with a LGPL and MPL open source license. OpenPDF is based on a fork of iText. We welcome contributions from other developers. Please feel free to submit pull-requests and bugreports to this GitHub repository.
Other
3.52k stars 581 forks source link

Convert pdf pages to images #616

Open bhupendersinghh opened 2 years ago

bhupendersinghh commented 2 years ago

Does openPdf support conversion of pdf file pages to images or a way to generate thumbnails for pdf files?

alesky78 commented 2 years ago

I investigate the same issue time ago... actually this functionalit is not supported then I'm forced to use also the PDFBox lib in my application to support this feature

ObsisMc commented 2 years ago

hello, is there anyone working on this enhancement? I am interested in it and want to try it.

bhupendersinghh commented 2 years ago

hello, is there anyone working on this enhancement? I am interested in it and want to try it.

I'm not sure anyone is. I had to use pdfbox because of this

ObsisMc commented 2 years ago

@asturio hello, is there anyone working on this issue? If not, I can have a try.

bk1991 commented 2 years ago

Here is a one way to create a thumbnail of pdf page - PdfReader reader = new PdfReader("HelloWorldToImport.pdf"); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("HelloWorldImportedPages.pdf")); document.open(); System.out.println("Tampered? " + reader.isTampered()); document.add(new Paragraph("This is page 1:")); PdfImportedPage page = writer.getImportedPage(reader, 1); Image image = Image.getInstance(page); image.scalePercent(15f); image.setBorder(Rectangle.BOX); image.setBorderWidth(3f); image.setBorderColor(new GrayColor(0.5f)); document.add(image); System.out.println("Tampered? " + reader.isTampered()); document.close(); image

alesky78 commented 2 years ago

Hello @bk1991 thank you for your update, this is an interesting approach but doesn't solven the problem of this topic. The point here is to convert a pdf page in a immage: jpeg, png, etc....

andreasrosdal commented 2 years ago

Any help on this issue would be welcome. Please submit a pull request.