Tools available: Adobe Acrobat SDK for 6.0 and .NET studio
Code written so far has been pasted below
Dim AcroExchApp As Acrobat.CAcroApp
Dim OldPdDoc As Acrobat.CAcroPDDoc
Dim NewPdDoc As Acrobat.CAcroPDDoc
Dim i As Integer
Dim outputPageCount As Integer
Dim inputPageCount As Integer
AcroExchApp = CreateObject("AcroExch.App")
OldPdDoc = CreateObject("AcroExch.PDDoc")
NewPdDoc = CreateObject("AcroExch.PDDoc")
i = OldPdDoc.Open("C:\CoreAPIOverview.PDF")
AcroExchApp.Show()
outputPageCount = NewPdDoc.GetNumPages()
inputPageCount = OldPdDoc.GetNumPages()
'i = OldPdDoc.DeletePages(1, inputPageCount - 1)
'i = OldPdDoc.Save(Acrobat.PDSaveFlags.PDSaveFull, "c:\Test.Pdf")
inputPageCount = OldPdDoc.GetNumPages()
i = NewPdDoc.InsertPages(outputPageCount - 1, OldPdDoc, 10, 10, 0)
outputPageCount = NewPdDoc.GetNumPages()
i = NewPdDoc.Save(Acrobat.PDSaveFlags.PDSaveFull, "C:\Test.pdf")
NewPdDoc.Close()
OldPdDoc.Close()
AcroExchApp.Exit()
NewPdDoc = Nothing
OldPdDoc = Nothing
AcroExchApp = Nothing
This is VB.NET. While i can delete the unwanted pages from the old PDF
and then save the remaining as the new PDF, the insertPages for adding
the required pages to a new pdf doesn't work. what am i missing in this
code. I am a newbie and i have tried googling to the max on this.
Thanks
oPDF = CreateObject("AcroExch.PDDoc")
oPDF1 = CreateObject("AcroExch.PDDoc")
szO = oPDF.Open("C:\CoreAPIOverview.PDF")
szO = oPDF1.Create()
szO = oPDF1.InsertPages(-1, oPDF, 0, 1, 1)
oPDF1.Save(Acrobat.PDSaveFlags.PDSaveFull, "C:\TestPdf.pdf")
oPDF1.Close()
oPDF.Close()
oPDF1 = Nothing
oPDF = Nothing
The one i pasted is almost similar but i don't know why it doesn't work...
Let's look how it works manual. Open Acrobat and use Doc->Insert
Pages. You will get an error, because you don't have an open Doc/PDF,
where you can insert to.
In your second example you open a PDF and then you can insert. In your
first script you try to insert to nothing. So you have to include an
if statement. If the page you want to "insert" is the first (0) page,
then use pddoc.open else pddoc.insert.
HTH, Reinhard