Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merge two or more pdf documents into one 1

Status
Not open for further replies.

amutinu

Programmer
Oct 19, 2001
50
US
Hello All,
I have a web page where users can select multiple check boxes (where each checkbox is a pdf document link) and i want to be able to merge the selected document into so that i can print multiple copies collately. I would really appreciate it if someone can provide with the sample code or maybe guide me in the right direction.

thanks,
 
if you have say two saved pdf files, you can combine them together using adobe full version application by
[1] open one pdf file
[2] with adobe select document\insert pages
[3] open the 2nd file
[4] save the current file into a new pdf file

hope this helps
 
Hi sncheong,
thanks for your feedback but i was looking more in terms of merging the two pdf documents using ASP or VB. I am trying to write a program that will merge two documents that are on the web server and then print them.

Let me know if you have any suggestions for this,

thanks,
 
Hello,
Do you happen to know the ASP code (vbscript) to put a PDF document link on a web page? I would appreciate it your reply. Thank you.
 
If you are using VB, references de "Acrobat Type Lybrary" in you project, then add an CAcroApp object, this is the Acrobat application class. Use this Object do open the two files to be merged, in the first document use the method "InsertPages" to add the second file. Now just save the document. For more information go to they have an VB6 example, it's not complete, but it will be helpful.
 
This information may be of help to some of your questions. Of course its all previous postings so you will have to dig out what you want. Thre is a October 18, 2000 post entitled "Acrobat Automation is there such a thing", and there is also a Sept 12,2001 post entitled "Merging/Appending Pages to PDF".

I have been looking for a solution that would also allow me to insert pages programmatically. I find that Adobe allows you do specify a folder of Pdf documents and then it will merge these for you; however the order gets all jumbled up. Our needs require that these documents are inserted in the order that we specify. I have found some useful information in those documents. In the meantime, if you know of anything that might be helpful for us, please let me know.

Thanks,

GM
 
Acrobat will insert the pages in the same order that they are selected. (ex. If you select a group of files by dragging a window from right to left, it will insert the files starting with the file that is furthest to the right, and vice versa.) If you can figure out a way to control what order it selects the files in a folder, then that should solve your problem.
 
Hi amutinu,

If you're still interested...

I was asked to combine two or more PDF files myself recently (prior to E-mailing the resulting PDF).
had to do this quickly (deadline) but it works.

cFiles is just a collection of filenames in the order I want the PDF files to be combined.
You'll have to set a references to the Acrobat Type library but you might already know that.

Code:
Private Sub Combine(ByVal cFiles As Collection)
  Dim i As Long
  Dim oPDF As Acrobat.CAcroPDDoc
  Dim oTemp As Acrobat.CAcroPDDoc
  Dim sDir As String
  Dim nPagesTo As Long
  Dim nPagesFrom As Long
  
  On Error GoTo ERRHANDLER
  
  sDir = File1.Path
  If Right$(sDir, 1) <> &quot;\&quot; Then sDir = sDir & &quot;\&quot;
  
  Set oPDF = CreateObject(&quot;AcroExch.PDDoc&quot;)
  If Not oPDF.Open(sDir & cFiles(1)) Then
    Err.Raise vbObjectError + 1001, &quot;Combine&quot;, &quot;Unable to open &quot; & cFiles(1)
  End If
  
  nPagesTo = oPDF.GetNumPages
  
  For i = 2 To cFiles.Count
    Set oTemp = CreateObject(&quot;AcroExch.PDDoc&quot;)
    If Not oTemp.Open(sDir & cFiles(i)) Then
      Err.Raise vbObjectError + 1001, &quot;Combine&quot;, &quot;Unable to open &quot; & cFiles(i)
    End If
    nPagesFrom = oTemp.GetNumPages
    If Not oPDF.InsertPages(nPagesTo - 1, oTemp, 0, nPagesFrom, True) Then
      Err.Raise vbObjectError + 1001, &quot;Combine&quot;, &quot;Unable to add &quot; & cFiles(i)
    End If
    nPagesTo = oPDF.GetNumPages
  Next i
  
  If Not oPDF.Save(PDSaveFull, sDir & Text1.Text) Then
    Err.Raise vbObjectError + 1001, &quot;Combine&quot;, &quot;Unable to save &quot; & Text1.Text
  End If
  
  Set oPDF = Nothing
  Exit Sub
  
ERRHANDLER:
  MsgBox Err.Description & vbCrLf & _
         Err.Source, vbExclamation
  Set oPDF = Nothing
  Set oTemp = Nothing
End Sub
 
I need to be able to take a dynamically created PDF and append a 10-page PDF to the end of it to be displayed in a browser.

Is this possible in ASP? Is the full version of Acrobat need to be installed on the web server or is there more that has to be installed for this to work?

Thnaks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top