Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Extract some pages out of PDF in to a new PDF

502 views
Skip to first unread message

Karthik Seetharaman

unread,
Feb 12, 2005, 8:02:56 PM2/12/05
to
Mission: To extract some pages out of a PDF and create a new PDF

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

Karthik Seetharaman

unread,
Feb 12, 2005, 9:01:23 PM2/12/05
to
The code below works
Dim oPDF As Acrobat.CAcroPDDoc
Dim oPDF1 As Acrobat.CAcroPDDoc
Dim szO As Integer

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...

Reinhard Franke

unread,
Feb 15, 2005, 10:58:29 AM2/15/05
to
> 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

lorr...@gmail.com

unread,
May 20, 2016, 1:33:39 AM5/20/16
to
Here is the link for you to vb.net add and delete pages from pdf. Hope this gives you a start on rasteredge page http://www.rasteredge.com/how-to/vb-net-imaging/pdf-delete/

rpresser

unread,
May 20, 2016, 11:27:19 AM5/20/16
to
On Friday, May 20, 2016 at 1:33:39 AM UTC-4, lorr...@gmail.com wrote:
> Here is the link for you to vb.net add and delete pages from pdf. Hope this gives you a start on rasteredge page http://www.rasteredge.com/how-to/vb-net-imaging/pdf-delete/

Here is the complaint you have earned: Don't try to sell your product by
replying to decade-old newsgroup postings.
0 new messages