Print Page | Close Window

Merge Problem

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=2388
Printed Date: 29 Jun 24 at 2:55AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Merge Problem
Posted By: Supertension
Subject: Merge Problem
Date Posted: 29 Aug 12 at 1:20PM

Hi,

 

Can someone help please?  I’m new to all this so please bear with me if I’m doing something daft. I’m running Windows 7 64 bit.

 

I downloaded the trial version and registered the ActiveX dll file called “QuickPDFAX0816.dll” without any problems.

 

I then opened Microsoft Access and entered the following VBA code (which is based on the code given on http://www.quickpdflibrary.com/help/getting-started-activex.php - ) and, to my delight, it all ran perfectly and I created my first pdf. The VBA code is:

 

Public Sub TestQpdf()

 

Set PDFLibrary = CreateObject("QuickPDFAX0816.PDFLibrary")

 

If PDFLibrary.UnlockKey("insert_license_key_here") = 1 Then

    Call PDFLibrary.DrawText(100, 500, "Test Text")

    Call PDFLibrary.SaveToFile("C:\users\DAN\DeskTop\Test.pdf")

End If

  

Set PDFLibrary = Nothing

  

End Sub

 

I then tried the code below (which is based on the code given on http://www.quickpdflibrary.com/tutorials/merge-pdf.php) but it crashes at the line PDFLibrary.LoadFromFile (Doc1) and the VBA error message is run-time error’450’: Wrong number of arguments or invalid property assignment.

 

Public Sub TestQpdfMerge()

 

Set PDFLibrary = CreateObject("QuickPDFAX0816.PDFLibrary")

 

If PDFLibrary.UnlockKey("insert_license_key_here") = 1 Then

 

    Doc1 = "C:\users\DAN\DeskTop\PDF1.pdf"

    Doc2 = "C:\users\DAN\DeskTop\PDF2.pdf"

    Doc3 = "C:\users\DAN\DeskTop\PDF3.pdf"

   

    PDFLibrary.LoadFromFile (Doc1)

    MainDocID = PDFLibrary.SelectedDocument()

   

    PDFLibrary.LoadFromFile (Doc2)

    AppendID = PDFLibrary.SelectedDocument()

   

    PDFLibrary.SelectDocument (MainDocID)

    PDFLibrary.MergeDocument (AppendID)

   

    PDFLibrary.SaveToFile (Doc3)

 

End If

 

End Sub

 

I suspect I’m missing the point somewhere and should be grateful if someone could point me in the right direction, ideally with a few lines of VBA that will work.

 

Thank you.




Replies:
Posted By: jpbro
Date Posted: 29 Aug 12 at 2:04PM
The "wrong number of arguments" error message is a clue - the LoadFromFile documentation mentions that a second argument is required (password). If your PDF file doesn't have a password, then use pass "" as the second parameter (e.g. PDFLibrary.LoadFromFile(Doc1, ""))

The LoadFromFile method changed to include the password parameter when 8.x was released, so the sample code that you have is out of date. There may be other changes too, so it is a good idea to review the documentation for any methods that you are calling.


Posted By: Supertension
Date Posted: 29 Aug 12 at 3:16PM
Thanks.  I've tried what you suggested, i.e. PDFLibrary.LoadFromFile(Doc1, ""), but the line immediately turns red indicating a syntax error.  I've read through the documentation but can't see anything to help. 


Posted By: Rowan
Date Posted: 29 Aug 12 at 3:50PM
Hi Supertension,

Just in case you're wondering -- I made a small edit to your post to remove the license key from the sample code.

Cheers,
- Rowan.


Posted By: Supertension
Date Posted: 29 Aug 12 at 3:53PM
Rowan,  Noted.  I'll make sure I don't include it in any future posts.
 
Can you help me solve my problem?  Thanks


Posted By: AndrewC
Date Posted: 29 Aug 12 at 3:56PM
Maybe you could try

  Password = ""
  PDFLibrary.LoadFromFile(Doc1, Password);

or

  PDFLibrary.LoadFromFile(Doc1, NullString);


This is a VBA problem but I don't have any experience in VBA.  

Andrew.


Posted By: Supertension
Date Posted: 29 Aug 12 at 4:01PM
Andrew,  Thanks but no joy.  I still get the syntax error.


Posted By: AndrewC
Date Posted: 29 Aug 12 at 4:15PM
It seems that you need to store the return value.   The VBA error message didn't help much.  What a strange language.

Andrew.

Sub Help()
 
Set PDFLibrary = CreateObject("QuickPDFAX0816.PDFLibrary")
 
If PDFLibrary.UnlockKey("put your key here") = 1 Then
 
    Doc1 = "f:\downloads\1.pdf"
    Doc2 = "f:\downloads\2.pdf"
    Doc3 = "f:\downloads\vba.pdf"
   
    ret = PDFLibrary.LoadFromFile(Doc1, NullString)  // Works
    MainDocID = PDFLibrary.SelectedDocument()
   
    ret = PDFLibrary.LoadFromFile(Doc2, "")    // Works
    AppendID = PDFLibrary.SelectedDocument()
   
    PDFLibrary.SelectDocument (MainDocID)  // strange it doesn't need the return value here.
    PDFLibrary.MergeDocument (AppendID)
   
    PDFLibrary.SaveToFile (Doc3)
 
End If
 
End Sub


Posted By: Supertension
Date Posted: 29 Aug 12 at 6:48PM
Andrew,  Perfect.  Many thanks for your help.  I would never have worked that one out for myself.


Posted By: isyscorp
Date Posted: 30 Aug 12 at 1:31AM
Hi Rowan,

Been reading and testing most of your Delphi Sample how to merge Multiple PDF files into one. I am now using a trial version of the Quick PDF Library. Regarding your PDF Merging via Stream, i cannot make it work.

uses ***QuickPDF0816;

function MergeStreamsViaMergeDocument(FirstStream, SecondStream,
    OutputStream: TMemoryStream): Integer;
  var
    doc1, doc2: Integer;
  begin
    with TQuickPDF.Create do
    try
      FirstStream.Seek(0, soFromBeginning);
      LoadFromStream(FirstStream);
      doc1 := SelectedDocument;
      SecondStream.Seek(0, soFromBeginning);
      LoadFromStream(SecondStream);
      doc2 := SelectedDocument;
      SelectDocument(doc1);
      MergeDocument(doc2);
      OutputStream.Seek(0, soFromBeginning);
      SaveToStream(OutputStream);
    finally
      Free;
    end;
  end;


ERROR MESSAGE APPEARED ON: " LoadFromStream(FirstStream);"
ERROR MESSAGE: "NOT ENOUGH ACTUAL PARAMETERS."

Please help. Thank you in advance.

Vid, MULTISYSCORP


Posted By: AndrewC
Date Posted: 30 Aug 12 at 3:27AM

A quick read of the "Quick PDF Library 8.16 Reference Guide.pdf" will reveal that LoadFromStream also requires a password parameter as of QPL 8.xx.  The PDF file can be found in the Quick PDF installation directory.

http://www.quickpdflibrary.com/help/quickpdf/LoadFromStream.php - http://www.quickpdflibrary.com/help/quickpdf/LoadFromStream.php

  LoadFromStream(FirstStream, Password);  // add the password parameter - can be blank ie. ""

It would also be helpful to know what development system you are using.

Andrew.


Posted By: isyscorp
Date Posted: 31 Aug 12 at 12:28AM
Hi Andrew, thank for your help. It runs without error now. I want to put the merge command to a BUTTON? Thanks again...


Posted By: Ingo
Date Posted: 31 Aug 12 at 7:53PM
..."to a BUTTON"...

You'll find it here:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2391&PID=10058&title=merging-2-or-more-pdf-files-into-One-pdf-file#10058

 Cheers, Ingo


Posted By: AndrewC
Date Posted: 02 Sep 12 at 8:07AM
"to a BUTTON" is a Delphi problem and not a Quick PDF Library.  This is one of the very first things that is taught in any Delphi Basics 101 course. ie  http://www.delphibasics.co.uk/Article.asp?Name=FirstPgm - http://www.delphibasics.co.uk/Article.asp?Name=FirstPgm

1. Add a button to your form
2. Double click the button and the following code is shown

procedure TForm1.Button1Click(Sender: TObject);
begin

end;

3. Paste the Quick PDF Library code we have given you between the 'begin' and 'end' statements.

Andrew.


Posted By: isyscorp
Date Posted: 02 Sep 12 at 12:35PM
Thanks Andrew, it works now... you're a life saver... 

Vid.



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