These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

deleting pages of a pdf doc with VB

iluvstrats
Registered: Oct 16 2007
Posts: 19

I am able to insert pages in code but can't seen to find the code to delete pages.

I want to loop through a number of pdf docs and delete the first 6 pages of each doc.

Any help sure would be appreciated.

Thanks

George_Johnson
Online
Expert
Registered: Jul 6 2008
Posts: 1876
Assuming you're using IAC, there's the PDDoc.DeletePages method, or you can use the doc.deletePages JavaScript method, either via JSObject or Fields.ExecuteThisJavascript method.

George
iluvstrats
Registered: Oct 16 2007
Posts: 19
George_Johnson wrote:
Assuming you're using IAC, there's the PDDoc.DeletePages method, or you can use the doc.deletePages JavaScript method, either via JSObject or Fields.ExecuteThisJavascript method.George
George,

I'm using VB. Do you know of any sample code?

Thanks

Joe
George_Johnson
Online
Expert
Registered: Jul 6 2008
Posts: 1876
Well, how are you currently inserting pages with VB?

George
iluvstrats
Registered: Oct 16 2007
Posts: 19
George,

Here's my code. What I can't find is how to select the first 6 pages to delete.

Regards,

Joe

' Get the first pdf file in the directory
'strFileName = Dir(strPath + PDF_WILDCARD, vbNormal)
strFileName1 = Dir(strpath1, vbNormal)
strFileName2 = Dir(strpath2, vbNormal)

' Open the first file in the directory
AcroExchPDDoc.Open strpath1 ' + strFileName1

' Get the total pages less one for the last page num [zero based]

'If vpagesetflg = "cpi" Or vpagesetflg = "db" Then
'iLastPage = AcroExchPDDoc.GetNumPages - 6
'Else
iLastPage = 5
'End If

Set AcroExchInsertPDDoc = CreateObject("AcroExch.PDDoc")

' Open the file to insert
AcroExchInsertPDDoc.Open strpath2 '+ strFileName2

' Get the number of pages to insert
iNumberOfPagesToInsert = AcroExchInsertPDDoc.GetNumPages

' Insert the pages
AcroExchPDDoc.InsertPages iLastPage, AcroExchInsertPDDoc, 0, iNumberOfPagesToInsert, True

' Close the document
AcroExchInsertPDDoc.Close

' Get the name of the next file in the directory
'strFileName2 = Dir
'Loop

' Save the entire document as the JOIN_FILENAME using SaveFull [0x0001 = &H1]
AcroExchPDDoc.Save &H1, vdirOutput '+ recid & JOIN_FILENAME
George_Johnson
Online
Expert
Registered: Jul 6 2008
Posts: 1876
So you are using IAC (InterApplication Communications) methods with VB. Have you looked at the documentation for the PDDoc.DeletePages method?

George
iluvstrats
Registered: Oct 16 2007
Posts: 19
George_Johnson wrote:
So you are using IAC (InterApplication Communications) methods with VB. Have you looked at the documentation for the PDDoc.DeletePages method?George
George,

Where do I find the documentation?

Joe
George_Johnson
Online
Expert
Registered: Jul 6 2008
Posts: 1876
Oh, I assumed you had it:
http://www.adobe.com/devnet/acrobat/interapplication.php

George
iluvstrats
Registered: Oct 16 2007
Posts: 19
Thanks, that's what I needed.