Concatenate Multiple PDF

So I know this probably isn’t technically supported but wondering if there might be a work-around. We are using the PDF product to merge multiple PDF’s together. We are writing this in IBMi RPGLE which has support for calling Java Methods but it’s limited in some ways. I am using the com.aspose.pdf.facades.PdfFileEditor.concatenate method and passing it an array. The problem is in RPGLE you have to predefine the array size at compile time. I do not know how many PDFs I might need to combine together until run time. So I made my array size 50 elements but I might only need to combine 4. I’ve tried to make all the extra elements null, empty strings, and just an invalid file name. The only way I can seem to make it work is if I pass the correct array size of 4. Is there anyway that I can make my array size 50 and still have concatenate merge the PDF’s? I would just like it to ignore any invalid/null or empty strings.

It is a complex problem, so as a workaround I thought about this crazy idea, let me know if it works.
Can you create a sample Pdf document with one blank page? And pass that one multiple times until you fill your array, then you delete the blank pages in the new document via

document.Pages[pagenumber].Remove.

It is not optimum and a waste of memory and processing time, but I was thinking about how to do that if I was you.

That was one thought I had as well, although I did find a solution that I hadn’t thought about. In RPGLE you can split an array when you pass it in as a parameter. So this fixed the issue. I had been trying to figure this out for several days. It’s always funny when you finally give up and ask for help then an answer is presented to you.

Thanks for your suggestion.

This issue is closed for me now.

1 Like