Print Page | Close Window

Page extraction problem

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: General Discussion
Forum Description: Discussion board for Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=1379
Printed Date: 23 Nov 24 at 7:49AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Page extraction problem
Posted By: SlyJay
Subject: Page extraction problem
Date Posted: 22 Mar 10 at 9:19AM
Hi everybody,
I have a problem during extraction process.
 
Given a source pdf file "source.pdf" if I call "QP.ExtractFilePages" for a certain range let's say 1-2 it crates a file with the 2 pages correctly, but if a call it a second time lats say with a range like 1-3 it generates a file with page 1,2,1 instead of 1,2,3. It copies allways the first page at the end after calling it a second time.
 
To clarify better, the forst time works correctly extracting the right pages but the second time it seems to append allways the fisrt page to the previous extracted range as many times as the current range exeeds the first range (1,2,1,1,1.......).
 
I've also tried to create a new istance of quickPdf for each extraction process but the behaviour is the same.
 
Any clue???
 
If you need more information just ask, I didn't post the code since we all use different languages but my code is in VB.net.
 
Thanks in advance
 
Sly 



Replies:
Posted By: Rowan
Date Posted: 22 Mar 10 at 9:54AM
Hi Sly, it would be helpful if you posted your code. It doesn't really mater what language it's in, the important thing is that everyone gets to see the functions that you have used and the sequence in which they were called... 


Posted By: SlyJay
Date Posted: 22 Mar 10 at 10:25AM
Here is my code:
    Private Sub PDFInsertPagesFromFile(ByVal destFile As String, ByVal insertFile As String, ByVal position As Integer)

 

        Dim tmpQP As New QuickPDFAX0718.PDFLibrary

        tmpQP.UnlockKey("my_code")

 

        tmpQP.LoadFromFile(destFile)

        Dim mainDoc As Integer = tmpQP.SelectedDocument

        Dim LastPart As Integer = 0

        Dim FirstPart As Integer = 0

 

        FirstPart = tmpQP.ExtractFilePages(destFile, My.Application.Info.DirectoryPath & "\1.pdf", "1-" & position)

        If FirstPart = 0 Then

            Exit Sub

        End If

 

        If tmpQP.PageCount > position Then

            tmpQP.DeletePages(1, position)

            tmpQP.SaveToFile(My.Application.Info.DirectoryPath & "\3.pdf")

            LastPart = 1

        End If

 

        tmpQP.MergeFiles(My.Application.Info.DirectoryPath & "\1.pdf", insertFile, My.Application.Info.DirectoryPath & "\2.pdf")

        IO.File.Delete(destFile)

        If LastPart > 0 Then

            tmpQP.MergeFiles(My.Application.Info.DirectoryPath & "\2.pdf", My.Application.Info.DirectoryPath & "\3.pdf", destFile)

            IO.File.Delete(My.Application.Info.DirectoryPath & "\3.pdf")

        Else

            IO.File.Move(My.Application.Info.DirectoryPath & "\2.pdf", destFile)

        End If

 

        IO.File.Delete(My.Application.Info.DirectoryPath & "\1.pdf")

        IO.File.Delete(My.Application.Info.DirectoryPath & "\2.pdf")

 

    End Sub

 
Consider that exept from the rest of the code witch is not the best due to multiple tries the problems resides in this line:
 
FirstPart = tmpQP.ExtractFilePages(destFile, My.Application.Info.DirectoryPath & "\1.pdf", "1-" & position)
 
when you call the SUB the secondtime the extraction process  fails doing the problem 1,2,1,1,1....
 
Hope this helps.
 
Thanks
 
Sly



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