Print Page | Close Window

Merging pdf files produces unexpected results

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2723
Printed Date: 08 May 24 at 7:03PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Merging pdf files produces unexpected results
Posted By: Mel
Subject: Merging pdf files produces unexpected results
Date Posted: 02 Sep 13 at 9:31AM
Hi,
we have a VB6 application that merges a series of invoice pdf files with their corresponding delivery notes.
Both invoice and delivery note information are stored in sql server tables along with their file names.
We recently found out that the content of some pdf files resulting from the merge operation are not related to
the supplier the invoice record refers to. It seems like the merge operation has failed to merge the correct files.
Here's the pseudo-code we use with the ActiveX v.7.21 of the library:

<Open resultset RS>

If RS.EOF Then
   <Exit Function>
End If

On Error Resume Next
Set QuickPDF = CreateObject("QuickPDFAX0721.PDFLibrary")
If err.Number <> 0 Then
   <Error handling>
End If
On Error GoTo 0

If QuickPDF.UnlockKey("...") = 0 Then
   <Error handling>
End If
...
If QuickPDF.AddToFileList(FileListName, <FileName>) = 0 Then
   <Error handling>
End If
...
If QuickPDF.AddToFileList(FileListName, <FileName>) = 0 Then
   <Error handling>
End If

RS.MoveNext
While Not RS.EOF

   If <Key changes> Then
      MergedFilesCount = QuickPDF.MergeFileList(FileListName, <FileName>)
      If MergedFilesCount < QuickPDF.FileListCount(FileListName) Then
         If MergedFilesCount = 0 And QuickPDF.FileListCount(FileListName) > 1 Then
            ...
         Else
            ...
         End If
         <Error handling>
      End If
      
      If QuickPDF.ClearFileList(FileListName) = 0 Then
         <Error handling>
      End If
      
      If QuickPDF.AddToFileList(FileListName, <FileName>) = 0 Then
         <Error handling>
      End If
      
   End If
   
   If QuickPDF.AddToFileList(FileListName, <FileName>) = 0 Then
      <Error handling>
   End If

   RS.MoveNext
Wend

MergedFilesCount = QuickPDF.MergeFileList(FileListName, <FileName>)
If MergedFilesCount < QuickPDF.FileListCount(FileListName) Then
   If MergedFilesCount = 0 And QuickPDF.FileListCount(FileListName) > 1 Then
      ...
   Else
      ...
   End If
   <Error handling>
End If

Do you know of any situation where the methods AddToFileList, MergeFileList, ClearFileList do not work properly ?




Replies:
Posted By: AndrewC
Date Posted: 12 Sep 13 at 11:07AM
1. Firstly I would suggest downloading the 7.26 version to see if the problem resolves itself.  7.26 is a free upgrade for all 7.xx license key holders.

http://www.quickpdflibrary.com/downloads/binaries/qp/oldversions/0726/quick_pdf_library726.exe


2. I have seen some very corrupt PDF files where even Acrobat displays the wrong page.  The PDF has copies of data for 3 pages but only reports 1 page existing in the file.  

If you still have a problem you would need to manually extract the problem PDF files to disk and create a support ticket by emailing the files and a problem description to support@debenu.com

Andrew.



Posted By: Mel
Date Posted: 25 Sep 13 at 11:13AM
Hi Andrew,
 
we are trying to add some code to our application to check the pdf files resulting from a merge operation. We are thinking of attaching a sort of tag to all individual files to be merged
before the actual merge operation takes place and looking for these tags in the resulting pdf file. Do you know what kind of tag (information) we can write in the original pdf files ?
Or do you have a better idea on how to check the resulting pdf file for the content of the original files ?
 
We really look forward to your help.
Regards



Posted By: Ingo
Date Posted: 25 Sep 13 at 8:08PM
Hi Mel!

Have a look at the StoreCustomDataFrom...-functions:
http://www.quickpdflibrary.com/help/quickpdf/StoreCustomDataFromString.php" rel="nofollow - http://www.quickpdflibrary.com/help/quickpdf/StoreCustomDataFromString.php
They're offering personal metadata for you.

Cheers, Ingo


-------------
Cheers,
Ingo



Posted By: Wheeley
Date Posted: 26 Sep 13 at 3:16AM
I you looked at MergeFileListFast. It gives back a list which states which files could be merged.

Wheeley


Posted By: Mel
Date Posted: 26 Sep 13 at 10:39AM
Thank you for your suggestions,
but I need to write some information on all files to be merged that I would find in the resulting pdf file.
For instance

Set Info1 on File1
Set Info2 on File2
MergeFileList File1 & File2 into FileMerge
Get Info1 from FileMerge would succeed
Get Info2 from FileMerge would succeed

Is there any information I can write into File1 & File2 that MergeFileList retains in FileMerge ?
I tested the Set/GetCatalogInformation functions and, unfortunately, the resulting file preserves
catalog information from the first file only.


Posted By: HNRSoftware
Date Posted: 01 Oct 13 at 10:10PM
one possible trick is to write a string of identifiable characters in white text on white background and then extract the text of the resulting file and see if it is there.  It should not be visible to the person viewing the document, but yet be fetchable.


Posted By: Mel
Date Posted: 02 Oct 13 at 9:01AM
Thank you for your suggestion,
we have already applied such a technique and are testing it. We wrote some fully transparent tags/text
(SetTransparency(100)) on the original files and looked for them in the resulting pdf file.
However, we were looking for a solution that would have avoided the physical writing of the original file pages.
We haven't found one yet.



Posted By: AndrewC
Date Posted: 02 Oct 13 at 1:44PM
Mel,

You could try the following ideas which I have not tested but in theory they should work well.

int id = NewContentStream();

QP.SelectContentStream(id);
SetContentStreamFromString("%% Custom Comment" + " \r");

This will add a PDF comment to a new content stream.   You can then extract the content contents using

id = QP.GetContentStreamCount();
QP.SelectContentStream(id);

QP.GetContentStreamToSting;

You can then check the first few characters of the comment string to see if it matches your comment format.

I haven't had time to try this but if for some reason the merge process combines the content streams then you would have to put the comment at the very front.

QP.MoveContentStream(id, 1);  // Move to the first position.

Andrew.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk