I hope i will get an answer this time
So far i have been able to pass the directory and file information to a <cfpdf> tag which will merge the files in each directory using the directory name as the final file output for each directory.
However, the tag throws up an error:
Here is the code:
<cfdirectory action="list" directory="D:\Dox" name="filelist">
<cfset tempPath=""> <cfloop query="filelist">
<cfpdf action="merge" directory="#fpath#" destination="D:\dox\#filelist.name#\#filelist.name#.pdf" overwrite="yes"> </cfloop>
and i get the error below, i have tried to, store and retrieve the directory and filename in a database, still the same problem. Can anyone tell me what i am missing
The error is below:
The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code. Null Pointers are another name for undefined values.
The error occurred in C:\wamp\www\codex\tesk.cfm: line 14
12 : <cfloop query="filelist">
13 : <cfset fPath="#directory#\#filelist.name#">
14 : <cfpdf action="merge" directory="#fpath#" destination="D:\pdfgen\#filelist.name#\#filelist.name#.pdf" overwrite="yes">
15 : </cfloop>
Just for the sake of debugging, in your <cfloop> can you output (or log) all the variables that you're passing to <cfpdf> and check they hold what you expect them to hold. At the same time, it'll give you an idea if the process is failing outright, or whether, say, the PDFs in some specific subdir are giving you a problem.
What does this code do if you try to merge PDFs in an empty subdir, btw?
>Just for the sake of debugging, in your <cfloop> can you output (or log) all the variables that you're passing to <cfpdf> and check they hold what you > >expect them to hold.
They certainly hold what i expected, I used the code below to output the variables
<cfdirectory action="list" directory="D:\dox" name="filelist">
and i got the directories and subdirectories which is now passed to <cfpdf>
> What does this code do if you try to merge PDFs in an empty subdir, btw?
It simply goes through without generating any error at all, i tried it on an empty directory.
Cool. So, back to the other question I asked: is it halting on a particular subdir, or is it just faceplanting on the very first one?
it merges the files in the first directory and outputs them to the required file, then it stops.
OK. Can you try to run the process just on that second dir? Why I ask is perhaps <cfpdf> might not clear up after itself properly, and be failing as a matter of course on the second call. Or it could be something in that second dir <cfpdf> doesn't like.
If - when you just run on the second dir - it still crashes, check for any obvious differences between the two dirs? How many PDFs are we talking? Is it viable to omit each one, one at a time from the merge (renaming a file to .dud or something should omit it... or to be on the safe side move it right out of the dir)? I've of some PDFs not working so well with CF's PDF ops.
If none of that crashes, can you re-try the entire process, but move that second dir out of the way first (so the third dir becomes the second dir, if you see what I mean).
In the mean time, I'll set up a similar rig here and see what I get.
What i did was to start moving out each directory and running the code, I ended up moving out three directories out, the code worked successfully through the remaining 4 directories without any problem.
Initially I thought that that the issue had to do with the compatibility of the pdf files. But again I copied the contents of the directories that i moved out into some of the directories and ran the code and it worked perfectly, which left me confused as to what the problem could really be. I'm glad though that the code is working in some directories. Many thanks for your time, please let me know your findings with the one you set up. thanks
I didn't manage to get any errors like yours, but I found it pretty easy for my server instance to run out of heap space when merging a few non-very-big PDF files. Which doesn't impress me too much.