I know how to convert jpg to pdf. but how the reverse is possible?
is there any way to get the size of Pdf? any native c++/c code?
please help?
Printable View
I know how to convert jpg to pdf. but how the reverse is possible?
is there any way to get the size of Pdf? any native c++/c code?
please help?
There is nothing Qt to read and manipulate PDF files.
Here are some open source libraries that do various things with PDFs: Poppler and PoDoFo
Of course, Adobe offer such tools also.
Hi, did you find anything else that does the pdf-to-image conversion?
As for converting pdf to jpg, I've used an open source project a while back to turn uploaded pdfs into images for use in an online catalog. Not sure whether it helps. You may have a check.
Code:
import org.icepdf.core.exceptions.PDFException; import org.icepdf.core.exceptions.PDFSecurityException; import org.icepdf.core.pobjects.Document; import org.icepdf.core.pobjects.Page; import org.icepdf.core.util.GraphicsRenderingHints; public byte[][] convert(byte[] pdf, String format) { Document document = new Document(); try { document.setByteArray(pdf, 0, pdf.length, null); } catch (PDFException ex) { System.out.println("Error parsing PDF document " + ex); } catch (PDFSecurityException ex) { System.out.println("Error encryption not supported " + ex); } catch (FileNotFoundException ex) { System.out.println("Error file not found " + ex); } catch (IOException ex) { System.out.println("Error handling PDF document " + ex); } byte[][] imageArray = new byte[document.getNumberOfPages()][]; // save page captures to bytearray. float scale = 1.75f; float rotation = 0f; // Paint each pages content to an image and write the image to file for (int i = 0; i < document.getNumberOfPages(); i++) { BufferedImage image = (BufferedImage) document.getPageImage(i, GraphicsRenderingHints.SCREEN, Page.BOUNDARY_CROPBOX, rotation, scale); try { //get the picture util object PictureUtilLocal pum = (PictureUtilLocal) Component .getInstance("pictureUtil"); //load image into util pum.loadBuffered(image); //write image in desired format imageArray[i] = pum.imageToByteArray(format, 1f); System.out.println("\t capturing page " + i); } catch (IOException e) { e.printStackTrace(); } image.flush(); } // clean up resources document.dispose(); return imageArray; }
How is this non-C++ (Java?) code related to Qt?
A c++ based open source library is xpdf: http://www.foolabs.com/xpdf/ and its free UI based software: http://pdf-to-jpg-convert.en.softonic.com