ExtractPages
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=220
Printed Date: 16 May 24 at 6:16AM Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com
Topic: ExtractPages
Posted By: GreatPyr
Subject: ExtractPages
Date Posted: 22 Dec 05 at 4:54PM
Everytime I execute the VB code below, ExtractPages always returns 1 in lngDoc2. The documentation said it would return the ID of the new document containing the extracted pages. Any ideas what I'm doing wrong?
Thanks.
WorkingPDF.LoadFromFile ("MainDoc.pdf")
lngDoc1 = WorkingPDF.SelectedDocument
WorkingPDF.LoadFromFile ("IA-004405.pdf")
lngDoc3 = WorkingPDF.SelectedDocument
lngDoc2 = WorkingPDF.ExtractPages(1, 4)
WorkingPDF.SelectDocument (lngDoc1)
WorkingPDF.MergeDocument (lngDoc2)
|
Replies:
Posted By: GreatPyr
Date Posted: 22 Dec 05 at 5:39PM
Do I need to merge the extracted pages? If I take the last two lines off the code, it seems to work. Somehow the extracted pages find their way to lngDoc1, even though it's not the selected document. I'm just not comfortable with it until I know why it's working.
I wish there was some documentation for this stuff.
|
Posted By: chicks
Date Posted: 22 Dec 05 at 6:32PM
Haven't tested it, and the doc does say that SelectDocument() returns an ID, but maybe it's returning the doc's index instead? Put some debug code in to print out exactly what it's returning. If it's 1 or 2 or 3, it's the index, and you'll need to use DocumentID() to get the actual ID, which is usually a multi-digit number.
|
Posted By: Michel_K17
Date Posted: 22 Dec 05 at 11:02PM
I used the ExtractPages for nearly 2 years without any problems. I think you are correct: the documentation is wrong. Here is my code but note that I use "SelectedDocument" to get the Doc ID.
Private Function PDF_Extract_Page(InFile As String, OutFile As String, page As String) As Long
Dim hDoc1Page As Long
' Trap Errors
On Error GoTo Error_Handler
' Get rid of ".pdf"
If Len(OutFile) > 4 Then
OutFile = Left$(OutFile, Len(OutFile) - 4) & "_"
Else
Exit Function
End If
' Create a new single page document
rtn = oPDF.SelectDocument(hDoc)
hDoc1Page = oPDF.ExtractPages(Val(page), 1)
hDoc1Page = oPDF.SelectedDocument()
' Save it
rtn = oPDF.SaveToFile(OutFile & Format$(Val(page), "0000") & PDF)
' Get rid of single page doc
rtn = oPDF.RemoveDocument(hDoc1Page)
' Job Complete
PDF_Extract_Page = True
Exit Function
Error_Handler:
olog.LogError False, Err.Number, Err.Description, Err.LastDllError, "PDF_Extract_Page"
End Function
|
|