android - iText bytearray not giving a workable output -


I'm very new here so ask if you need more information.

I have a piece of code that writes to the SD card. It writes jpegs, and it's giving all the variable KB sizes as you would expect from a PDF full of images. However, when I select them on the tablet then this is 'unable to open the photo', and when I open them on my computer, it does not allow it, so obviously I do not remember some level of corruption.

I also tested the image. Length and it is also working in the case of outputs of many different byte sizes.

  try {InputStream = this.getAssets (). Open ("Birds-40.pdf"); PDF Reader Reader = New PDF Reader (is); (Int i = 0; i & lt; reader.getXrefSize (); i ++) {PDF object pdfobj = reader.getPdfObject (i); If (pdfobj! = Null & pdfobj.isStream ()) {PDF stream stream = (PDF stream) pdfobj; Pdfobact pdfsubtype = stream.get (pdfName.SUBTYPE); If (pdfsubtype! = Null & amp; pdfsubtype.toString (.) Equal (pdfName.IMAGE.toString ())) {byte [image] image = pdfReader .getStreamBytesRaw (stream stream (PRS)); FileOutputStream Out = New FileOutputStream (new file (file.getParentFile (), I + ".jpeg")); Bitmap bitmap = bitmapfender Esadabiteere (image, 0, image lamp); Println (image.length); Out.write (image); Out.flush (); Out.close (); }}}} Hold (IOException e2) {System.out.println (e2); e2.printStackTrace (); }   

If someone tells me in the right direction at least what I am doing, then I am very happy. By the way, I tried to do some things with the bitmap factory and tried and hope to open the file again with the bitmap factory to do such a thing that it could fix it for some reason it was not your time Thanks a lot for

I came to know how i want to do iText with a different method:

You need the iTextG library (itextg-5.5.3.jar), scpkix-jdk15on.1.47.0.1.jar & amp; Scprov-jdk15on-1.47.0.2.jar

inside where you want to call it:

  public static final string RESULT = "/ storage / sdcard0 / dirAtExtStorage / Img % S. Public Zero Extracting Images (string filename) throws IOException, DocumentException {PdfReader Reader = new PDF Reader (filename); PdfReaderContentParser parser = New PdfReaderContentParser (Reader); MyImageRenderListener listener = new MyImageRenderListener (RESULT); (Int i = 1; i & lt; = reader.getNumberOfPages (); i ++) {Parser. Process content (i, listener); }}   

Inside MyImageRendererListener.java:

  The public class implements MyImageRenderListener RenderListener {Private string path; Public MyImageRenderListener (string path) {this.path = Path; } @ Override Public Wide StartTextBlock () {// Tudo Auto-Generated Stub} @ Override Public Wide Identity Block (// Todo Auto-Generated Method Stub} Public Voided Render Images {try {System.out. print} ("renderImage"); String filename; FileOutputStream OS; PdfImageObject image = renderInfo.getImage (); If return (image == empty); filename = String.format (path, renderInfo.getRef (). getNumber (), image.getFileType ()); OS = new FileOutputStream (filename); os.write (image.getImageAsBytes ()); Os.flush (); Os.close (); } Hold (IOException e) {System.out.println (e.getMessage ()); }} @ Override Public Wide Render Text (Texter Infra Arg 0) {// Tudo Auto-Generated Method Stub}}   

Enjoy People < / Html>

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -