Print Page | Close Window

CopyPageRanges Results in blank page

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=2378
Printed Date: 04 Apr 26 at 4:48AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: CopyPageRanges Results in blank page
Posted By: bwolfe
Subject: CopyPageRanges Results in blank page
Date Posted: 23 Aug 12 at 5:14PM
I am attempting to loop thru a PDF document and create multiple pages per PDF. My original PDF is 409 pages and has security on Document Assembly. My loop reports successful (1) on page 1 and unsuccessful (0) on subsequent pages with an error code of 412. I took an unsecured PDF with 1 page and attempted and CopyPageRanges reports successful. No matter what I try, I get a PDF with a blank page. I am fairly certain, after reviewing the forums, that I have the correct PDF selected at the time of extraction. It seems pretty straightforward.
 
Sub ConvertQuickPDF(ByVal oFile As IO.FileInfo, ByVal oFolder As IO.DirectoryInfo)
        Dim oQP As QuickPDFAX0814.PDFLibrary = Nothing
        Dim lID As Integer = 0
        Dim lNewID As Integer = 0
        Dim oNewFile As IO.FileInfo = Nothing
        Dim lPageCount As Integer = 0
        Dim i As Integer = 0
        Const SPK As String = "***********"
        Try
            oQP = New QuickPDFAX0814.PDFLibrary
            oQP.UnlockKey(SPK)
            lID = oQP.LoadFromFile(oFile.FullName, "")
            lPageCount = oQP.PageCount
'Get First Document ID
            lID = oQP.GetDocumentID(1)

            For i = 1 To lPageCount
                oQP.SelectDocument(lID)
                oQP.SelectPage(i)
'Get New Document
                lNewID = oQP.NewDocument()
'Select New Document
                oQP.SelectDocument(lNewID)
'Copy a page by number from original PDF to new pdf
                oQP.CopyPageRanges(lID, i.ToString)
'Delete blank initial page
                oQP.DeletePages(1, 1)
                oNewFile = New IO.FileInfo(oFolder.FullName & "\" & Format(i, "00000000") & ".pdf")
                IO.Directory.CreateDirectory(oNewFile.DirectoryName)
'Save new PDF  - always a blank page
                oQP.SaveToFile(oNewFile.FullName)
'Remove the New PDF from collection
                oQP.RemoveDocument(lNewID)
            Next
            oQP.RemoveDocument(lID)
        Catch ex As Exception
        End Try
    End Sub



Replies:
Posted By: Wheeley
Date Posted: 23 Aug 12 at 9:02PM
What you are not understanding is even before you load the file QuickPDF already has a blank document in memory. This is by default and intentional. So your line GetDocumentID (1) is in fact selecting the default blank document which is why CopyPageRanges is failing. So, what you should do is GetDocumentID (DocumentCount()) and it should work.

Wheeley


Posted By: bwolfe
Date Posted: 23 Aug 12 at 9:25PM
That did the trick. Thanks so much.
 
Can you tell me why CopyPageRanges takes so long on larger files?
 
I have a PDF that has 1715 pages. When I open it, it is fine. When execute CopyPageRanges and specifiy a single page, it takes quite a while. For each page, to copy to, the CopyPageRanges takes an inordinate amount of time to execute. It doesn't take a long time for 400 pages, but once you get to 1000 or so, it crawls.


Posted By: Wheeley
Date Posted: 23 Aug 12 at 11:44PM
You will have to get official support to answer that question. There were known performance issues when dealing with large files that the previous owner didn't address. I don't know if Debenu has fixed them or not. I do know they are a much better company at responding to issues in the library. So put in an official support ticket and see what they say. Go here:

http://www.debenu.com/support/contact/

Wheeley



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk