We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Arrayindexoutofboundsexception in class if

Dear Aspose,

I am trying to print a pdf. This pdf is a pdf that has been edited by your software aspose.pdf.kit for Java. When I try to print I get this stacktrace:

java.lang.ArrayIndexOutOfBoundsException: 0
at com.aspose.pdf.kit.ek.if(Unknown Source)
at com.aspose.pdf.kit.g2.a(Unknown Source)
at com.aspose.pdf.kit.rm.do(Unknown Source)
at com.aspose.pdf.kit.rm.a(Unknown Source)
at com.aspose.pdf.kit.rm.a(Unknown Source)
at com.aspose.pdf.kit.rm.do(Unknown Source)
at com.aspose.pdf.kit.rm.a(Unknown Source)
at com.aspose.pdf.kit.rm.a(Unknown Source)
at com.aspose.pdf.kit.it.a(Unknown Source)
at com.aspose.pdf.kit.gr.print(Unknown Source)
at com.aspose.pdf.kit.PdfViewer.print(Unknown Source)
at sun.print.RasterPrinterJob.printPage(Unknown Source)
at sun.print.RasterPrinterJob.print(Unknown Source)
at sun.print.RasterPrinterJob.print(Unknown Source)

As you can see an error occures in the class if but since I can’t read the source I don’t know what is going on. Could you please investigate what could be going wrong?

The code I use to print the pdf is as following:

PdfViewer pdfViewer = new PdfViewer( );
pdfViewer.openPdfFile( new ByteArrayInputStream( pdfContentAsByteArray ) );
// initialize the Pdf show.
pdfViewer.showPdf( );

// If you want to print the Pdf file, the follow code is an example. The SimplePdfViewer shows the usage in detail.
// sets the default print scale - false.
pdfViewer.enableScalePrint( false );
// gets a printjob object.
PrinterJob printJob = PrinterJob.getPrinterJob( );
// gets the default page.
PageFormat pf = printJob.defaultPage( );
// sets the Paper object for this PageFormat.
Paper paper = new Paper( );
double margin = 36; // half inch
paper.setImageableArea( margin, margin, paper.getWidth( ) - margin * 2, paper.getHeight( ) - margin * 2 );
pf.setPaper( paper );

// allows user to edit settings and select printing
printJob.setPrintable( pdfViewer, pf );

// creates the printDialog.
printJob.print( );

// close the Pdf file.
pdfViewer.closePdfFile( );

Yours sincerly,
Martyn Hiemstra

Hello Martyn,

I have tested the code snippet with one of my sample Pdf file and its working fine. Please share the Pdf file that you are using, so that we can test the issue at our end.

Sorry for your inconvenience.

Hallo Aspose,

Unfornately I haven’t got the original pdf anymore but the pdf, that I have attached to this message, throws a nullpointerexception in the H class if I try to print.

This pdf was created in adobe lifecycle designer and saved as a dynamic pdf. I don’t know if that is a problem?

Thanks,
Martyn Hiemstra

Dear Aspose,

I would like to apologize. I discovered a bug in my software. I have corrected the error and now I can print.

I do have a question about printing the pdf directly to the printer. I get strange characters and some text fields are replaced with strange text. I can imagine that the printer can’t understand pdf’s and therefore prints some strange characters. Is there a solution to this problem? If I save the pdf to my harddisk and print from adobe acrobat I can print perfecly.

Thanks,
Martyn Hiemstra

Hello Martyn,

We apologize for your inconvenience.

Could you please attach the Pdf file, so that we can test the issue at our end.