Hello, I am using Leadtools for .NET (Document Imaging, PDF Read/Save) version 15.0.1.0
I am having a problem loading multiple PDF files and saving (merging) them into a single .tif file.
I have built a demo application to let you guys see what is going on and it is attached to this post.
Here is how to reproduce...
1) Unzip the attached .zip file. You will find the following files in the first directory...
40pages.pdf - this is the test file I have been using to reproduce this issue. Note: It is not a big file.. only 90K.
Bin Directory.JPG - This is just a picture of what Leadtools files I had in my Bin directory. Note: The exact version numbers are present in this photo. You will need to have the Leadtools.dll and Leadtools.Codecs.dll referenced in your project. The codecs and PDF folder will just need to be placed in your bin.
LT PDF Merge Demo.sln - VB.Net solution file for the demo application
LT PDF Merge Demo (Folder) - Project files for the demo application.
2) Re-add the LT unlock codes. You will find the sub that unlocks the licenses in Common.vb under the namespace 'Initialization' and the Sub 'Initialize_Licenses'
3) Re-add the missing LT references in your project. Take a look at Bin Directory.jpg as described above for exact version numbers.
4) Re-add your codec files as well as the PDF directory.
5) Build and run the demo application.
6) Use the 'source files' list box to select the 40pages.pdf file that is included in this demo. NOTE: Depending on how much RAM you have on your machine you may need to take additional steps as outlined below in 'Additional Info'
7) You may leave the destination file name alone or select a new name.
8) Click on the merge button. All controls will be disabled until the merge is complete. Once all controls are enabled again, you can then go check your destination file.
9) Check the number of pages in your destination file. You can do this either by 'right-clicking' on the image file, choosing properties, selecting the summary tab and then clicking the 'advanced' button, or you can open the image up in a viewer that supports multiple pages.
If you used the 40pages.pdf file included in this demo and the resulting file still has 40 pages, please read 'additional info' below to see how to reproduce this, if you have less than 40 pages, you have already reproduced the issue.
ADDITIONAL INFO:
While trouble shooting this problem, I have uncovered a few things...
1) The number of source files needed to reproduce this issue seems to vary depending on the amount of RAM you have on your machine. For example, I have run this on a machine that only has a half a Gig of RAM and I was able to reproduce this using only the 40 page pdf provided. However, on a machine with a full Gig of RAM I had to make a copy of the 40 page pdf and then input '40pages.pdf' and 'Copy of 40pages.pdf' as my source files to reproduce. If you are having trouble reproducing this, I suggest making 3 or 4 additional copies and inputing them all as the source files.
2) The problem here seems to be with the
RasterCodecs object.
Note: This example assumes I am on a machine with 1 gig of RAM and I have two input files... 40pages.pdf and Copy of 40pages.pdf
On line 57 of Form1.vb in the MergeFiles function I load each individual source image like this....
' Load the image
RasImage = MergeCodecs.Load(LocalPath)
Well for the FIRST image, if I check the pagecount of the RasImage object the codecs returned, the pagecount is correct and is 40. However, when the loop returns to load the SECOND image, the merge codecs does load the file (or part of it) and returns a RasImage object, but the pagecount is off. In my testing it would repeatedly return a pagecount of 12 even though I knew the source image was 40 pages.
To me it seems the RasterCodecs object may be running out of memory.
3) If you do not close the demo application before running another test, it seems that the RasterCodecs object will eventually run out of memory no matter how many source files you started with.
Note: This may be due to me not calling the RasterCodecs.Shutdown method, however, I have been able to reproduce losing pages on the first run of the demo repeatedly.
4) This only seems to be happening when using PDFs as my source files, I have been able to run successful tests using this same code and having .tif files as my source files with no problems.