Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Merging pdf files produces unexpected results
  FAQ FAQ  Forum Search   Register Register  Login Login

Merging pdf files produces unexpected results

 Post Reply Post Reply
Author
Message
Mel View Drop Down
Beginner
Beginner
Avatar

Joined: 30 Aug 13
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mel Quote  Post ReplyReply Direct Link To This Post Topic: Merging pdf files produces unexpected results
    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 ?

Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
Mel View Drop Down
Beginner
Beginner
Avatar

Joined: 30 Aug 13
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mel Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 25 Sep 13 at 8:08PM
Hi Mel!

Have a look at the StoreCustomDataFrom...-functions:
They're offering personal metadata for you.

Cheers, Ingo
Cheers,
Ingo

Back to Top
Wheeley View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 Oct 05
Location: United States
Status: Offline
Points: 146
Post Options Post Options   Thanks (0) Thanks(0)   Quote Wheeley Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Mel View Drop Down
Beginner
Beginner
Avatar

Joined: 30 Aug 13
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mel Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
HNRSoftware View Drop Down
Senior Member
Senior Member


Joined: 13 Feb 11
Location: Washington, USA
Status: Offline
Points: 88
Post Options Post Options   Thanks (0) Thanks(0)   Quote HNRSoftware Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Mel View Drop Down
Beginner
Beginner
Avatar

Joined: 30 Aug 13
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mel Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store