Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Non-trappable error

$
0
0
The following outputs an error on the jpegdevice.process command.

java.lang.ArrayIndexOutOfBoundsException: 3
java.lang.ArrayIndexOutOfBoundsException: 3

Can I trap this? it just spits out error to standard output.

com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(pd.finalprodpath);
                    com.aspose.pdf.Document pdf = new com.aspose.pdf.Document();
                        
                        
                        String base = "";
                        for (int pageCount = 1; pageCount <= pdfDocument.getPages().size(); pageCount++)
                        {
                            Page ppage = pdf.getPages().add();
                            Page spage = pdfDocument.getPages().get_Item(pageCount);
                            
                            String pend = String.valueOf(pd.stampstart + (pageCount-1));
                            String newbase = pd.rootname.substring(0,pd.rootname.length() - pend.length());
                            String subbase = pd.tiffpath + pd.rootname + slash;
                            File subfile = new File(subbase);
                            if(!subfile.isDirectory())
                                subfile.mkdir();
                            String stamp = newbase + pend;
                            String outpath = subbase + stamp + "."  + ext;
                            if(pageCount==1)
                                base = subbase + stamp + ".pdf";
                            ByteArrayOutputStream imageStream = new ByteArrayOutputStream();
  Resolution resolution = new Resolution(300);
                            
                            JpegDevice jpegDevice = new JpegDevice(resolution,60);
    //  THE LINE BELOW CAUSES ERROR
                            jpegDevice.process(pdfDocument.getPages().get_Item(pageCount), imageStream);
                            byte[] data = imageStream.toByteArray();
                            ByteArrayInputStream bois = new ByteArrayInputStream(data);
                            com.aspose.pdf.Rectangle rect = spage.getMediaBox();
                            ppage.setMediaBox(rect);
                            ppage.addImage(bois, rect);
                            
                    
                        }
                        pdf.convert("error.log", PdfFormat.v_1_4, ConvertErrorAction.None);
                        pdf.save(base);
                }
                          

Viewing all articles
Browse latest Browse all 3131

Trending Articles