I'm trying to do a PDF merge in CFScript.
So far I have:
pdfService = new pdf();
pdfService.addParam(source='#source1#');
pdfService.addParam(source='#source2#');
writedump(pdfService);
pdfService.merge(destination="#getTempDirectory()#myfile.pdf";
But seems like the addParam is not working. When the pdfService is dumped after the addParams, the source is not set. What is the correct way of setting it using addParams? If there is only one source then it works fine by using
pdfService.addSource(source1);
But in the case of multiple sources, the addParam is not working and when it tries to do the merge an error comes up saying that the source is empty.
Note that the source is not a path in the file system, it is a binary PDF object. It works fine when I do it in the usual CF way:
<cfpdf action="merge" destination="#getTempDirectory()#myfile.pdf">
<cfpdfparam source="source1" />
<cfpdfparam source="source2" />
</cfpdf>
But I need to get it to work in CFScript.
It might be to do with the way you're reading in the sources (your code doesn't show that). Try the following which works on CF9.01
and assumes the pdf files are in the same directory as the script(EDIT: source PDFs are read from URLs):Incidentally I'd recommend always specifying the full dot-path to the CF script "tags as cfcs", in case you have any similarly named components anywhere else (i.e.
New com.adobe.coldfusion.pdf()
rather than justNew pdf()
).