1

A little problem i'm having right now with my app. I've found solutions in Java, using Ghost4J... But it uses java.awt.Image, that I can't import in Android. I java, I have something like that :

PDFDocument document = new PDFDocument();
                document.load(file);

                SimpleRenderer renderer = new SimpleRenderer();
                renderer.setResolution();

                List<Image> images = renderer.render(document);
                for (int i = 0; i < images.size(); i++) {
                    ImageIO.write((RenderedImage) images.get(i), "png", new File((i + 1) + ".png"));
                }

So, my problem is that I have a picture in pdf format, and I need to convert it in png, cause I use a printer that can't handle pdf...

Hope you guys, will find a way... Thanks a lot, and sorry for my english!

1 Answers1

2

PdfRenderer is what you are looking for. More precisely: the method render in the PdfRender.Page class.

void    render(Bitmap destination, Rect destClip, Matrix transform, int renderMode)

it runders the PDF page to a bitmap. And then from bitmap to PNG use the method bitmap.compress

  • Thanks for your answer, didn't know that... But it appears that it needs api 21, my current min in 15... Is there a way for earlier versions? Thx –  Dec 29 '15 at 17:08
  • There is a 2012 topic here: http://stackoverflow.com/questions/8814758/need-help-to-convert-a-pdf-page-into-bitmap-in-android-java – Mohamed Amjad LASRI Dec 30 '15 at 15:26