As it stands i've a section of code which writes to the SD card. It writes 
.jpegs, and it is giving them all variable kb sizes like you'd expect from a 
pdf full of images. However, when I select them on the tablet it's 'Unable to 
open photo', and when I open them on my computer it doesn't allow it either so 
there's obviously some level of corruption that i'm missing.I've also tested 
the image.length and that seems to be working too in terms of outputting many 
different byte sizes.If anyone could point me in the right direction atleast as 
to what i'm doing wrong i'd be greatful. By the way, i've tried a few things 
with bitmap factory to try and make it work such as re-opening the file with 
bitmap factory hoping that for some reason it might fix it. It didn't. Thanks 
very much for your time.
try {
        InputStream is = this.getAssets().open("iText-40.pdf");
        PdfReader reader = new PdfReader(is);
        for (int i = 0; i < reader.getXrefSize(); i++) {
            PdfObject pdfobj = reader.getPdfObject(i);
            if (pdfobj != null && pdfobj.isStream()) {
                PdfStream stream = (PdfStream) pdfobj;
                PdfObject pdfsubtype = stream.get(PdfName.SUBTYPE);
                if (pdfsubtype != null
                        && pdfsubtype.toString().equals(
                                PdfName.IMAGE.toString())) {
                    byte[] image = PdfReader
                            .getStreamBytesRaw((PRStream) stream);
                    FileOutputStream out = new FileOutputStream(new 
File(file.getParentFile(), i + ".jpeg"));
                    Bitmap bitmap = BitmapFactory.decodeByteArray(image, 0, 
image.length);
                    System.out.println(image.length);

                    out.write(image);
                    out.flush();
                    out.close();

                }
            }
        }

    } catch (IOException e2) {
        System.out.println(e2);
        e2.printStackTrace();
    }                                     
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to