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

Free Support Forum - aspose.com

PDFileEditor.concatenate() produces zero byte output PDF

I am trying the sample code to merge PDFs using PDFFileEditor.concatenate() method. Below is the sample code I have and i always get the return code as false. I tried almost all overloaded methods of concatenate() and same result. I am 100% sure that the soruce pdfs (PDF1.pdf and PDF2.pdf) are in the correct locations as I don't get any exceptions when I use the FileInputStreams.

I do have the eval license for ASPose.PDF library.

Is there anything that I am doing wrong. I am using the latest versions of ASPose.PDF library on JDK1.6.

Rgds,

Raj.

public class MergePDFs

{

/**

* @param args

*/

public static void main( String[] args )

{

OutputStream output = null ;

InputStream inStream1 = null ;

InputStream inStream2 = null ;

try

{

// // initialize ASPose.pdf license.

// License pdfLicense = new License() ;

// pdfLicense.setLicense( "C:\\Temp\\TestPDFs\\Aspose.Pdf.lic" ) ;

// List inStreams = new ArrayList() ;

//

// inStream1 = getFileInputStream( "C:\\Temp\\TestPDFs\\PDF1.pdf" ) ;

// inStream2 = getFileInputStream( "C:\\Temp\\TestPDFs\\PDF2.pdf" ) ;

//

// inStreams.add( inStream1 ) ;

// inStreams.add( inStream2 ) ;

// Concatenate two files

PdfFileEditor editor = new PdfFileEditor();

// output = new BufferedOutputStream(

// getFileOutputStream( "C:\\Temp\\TestPDFs\\MergedPDF.pdf" ) );

// editor.concatenate( inStream1, inStream2, output);

// boolean code = editor.concatenate( inStreams.toArray( new InputStream[0] ), output ) ;

// boolean code = editor.concatenate(

// new String[] {

// "C:\\Temp\\TestPDFs\\PDF1.pdf",

// "C:\\Temp\\TestPDFs\\PDF2.pdf"

// } ,

// "C:\\Temp\\TestPDFs\\MergedPDF.pdf"

// ) ;

boolean code = editor.concatenate(

"C:\\Temp\\TestPDFs\\PDF1.pdf",

"C:\\Temp\\TestPDFs\\PDF2.pdf",

"C:\\Temp\\TestPDFs\\MergedPDF.pdf"

);

System.out.println( code ) ;

}

catch(Throwable ex)

{

ex.printStackTrace();

}

finally

{

try { output.close() ; } catch (Throwable t) { ; } ;

try { inStream2.close() ; } catch (Throwable t) { ; } ;

try { inStream1.close() ; } catch (Throwable t) { ; } ;

}

return ;

}

private static InputStream getFileInputStream( String filePath ) throws Exception

{

return new FileInputStream( filePath ) ;

}

private static OutputStream getFileOutputStream( String filePath ) throws Exception

{

return new FileOutputStream( filePath ) ;

}

}

I googled around and found about this flag.

editor.setAllowConcatenateExceptions(true) ;

WIth this flag set, I was able to see the below exception. Seems like something wrong with the PDFs I was using. I tried the program with PDFs generarted from Word docs, using ASPose.Words library and the program worked like a charm.

java.lang.RuntimeException: com.aspose.ms.System.ab: Object not found
at com.aspose.pdf.facades.APdfFileEditor.a(Unknown Source)
at com.aspose.pdf.facades.APdfFileEditor.concatenate(Unknown Source)
at com.aspose.pdf.facades.PdfFileEditor.concatenate(Unknown Source)
at com.aspose.pdf.facades.APdfFileEditor.concatenate(Unknown Source)
at com.aspose.pdf.facades.PdfFileEditor.concatenate(Unknown Source)
at lab.pdf.MergePDFs.main(MergePDFs.java:79)
Caused by: com.aspose.ms.System.ab: Object not found
at com.aspose.pdf.a.a.d.a(Unknown Source)
at com.aspose.pdf.a.a.d.a(Unknown Source)
at com.aspose.pdf.a.c.aa.K_(Unknown Source)
at com.aspose.pdf.a.c.aa.E(Unknown Source)
at com.aspose.pdf.a.c.aa.U(Unknown Source)
at com.aspose.pdf.Copier.a(Unknown Source)
at com.aspose.pdf.Copier.duplicate(Unknown Source)
at com.aspose.pdf.Copier.a(Unknown Source)
at com.aspose.pdf.Copier.a(Unknown Source)
at com.aspose.pdf.Copier.duplicate(Unknown Source)
at com.aspose.pdf.Copier.a(Unknown Source)
at com.aspose.pdf.Copier.a(Unknown Source)
at com.aspose.pdf.Copier.duplicate(Unknown Source)
at com.aspose.pdf.Copier.a(Unknown Source)
at com.aspose.pdf.Copier.a(Unknown Source)
at com.aspose.pdf.Copier.duplicate(Unknown Source)
at com.aspose.pdf.Copier.duplicate(Unknown Source)
... 6 more

Rgds

Raj.

Hi,

I am trying to merge PDFs generated by our document creation technology, HP Extream (aka, Dialog). PDFs generated by this system always produces this error.

Would anyone happen to know when the below error can happen? I am still using the same test program listed in my original post that started this thread.

FYI:- My test programs works fine with PDFs created by ASPose.Words java library, which I used to convert MSWord docs to PDFs.

Our company's decision to purchase depends on reliabily combining PDFs generated by HP Extream system, via Java api. The below error is currently blocking us .

java.lang.RuntimeException: com.aspose.ms.System.ab: Object not found

Hi Raj,


Thanks for your inquiry. Can you please share your source documents here? So we will investigate the issue and will provide you more information accordingly.

We are sorry for the inconvenience caused.

Best Regards,

Thank you for your prompt reply. I will upload the PDFs in this post as soon as I get approval to share the PDFs. I need to find test PDFs that I can share.

Attached are couple of PDFs which fails with concatenate method.

Hi Rajalingam,


Thanks
for sharing the sample files.
<o:p></o:p>

I have tested the scenario and I am able to notice the same problem. For the sake of correction, I have logged this issue as PDFNEWJAVA-33826 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.

tilal.ahmad

Hi,

I got an email from Tilal Ahmad to point the code that is causing the problem with PDF concatenate. Below method is the one that I am using in my sample code. I have uploaded the PDFs too that I was using to test the java libraries.

editor.setAllowConcatenateExceptions(true) ;

boolean code = editor.concatenate( "C:\\Temp\\TestPDFs\\PDF1.pdf", "C:\\Temp\\TestPDFs\\PDF2.pdf", "C:\\Temp\\TestPDFs\\MergedPDF.pdf" );

THis method throws the below exception.

java.lang.RuntimeException: com.aspose.ms.System.ab: Object not found
at com.aspose.pdf.facades.APdfFileEditor.a(Unknown Source)
at com.aspose.pdf.facades.APdfFileEditor.concatenate(Unknown Source)
at com.aspose.pdf.facades.PdfFileEditor.concatenate(Unknown Source)

Rgds,
Raj.

Hi Raj,


Thanks for sharing the source code. Definitely, it will help us in issue investigation and resolution. We will update you as soon issue is resolved.

We are sorry for the inconvenience caused.

Best Regards,

Hi,


I am still waiting to hear back from someone on the issue I reported. Any help is much appreciated.

Rgds,
Raj.

Hi Raj,


Thanks for your patience.

As shared earlier by Tilal, we have managed to reproduce this issue while using the code snippet which you have shared earlier but as we recently have been able to notice this issue, and until
or unless we have investigated and have figured out the actual reasons of this
problem, we might not be able to share any timelines by which this problem will
be resolved.

However, as soon as we have made some significant progress towards the resolution of this issue, we would be more than happy to update you with the status of correction. Please be patient and spare us little time. Your patience and comprehension is greatly appreciated in this regard.

Hi Raj,


Thanks for your patience.

The development team has further investigated the issue reported earlier and as per our current estimates, we plan to get this issue resolved in Aspose.Pdf for Java 4.7.0 (which will be published in Q1-2014). Please be patient and spare us little time.

The issues you have found earlier (filed as PDFNEWJAVA-33826) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.