Print Page | Close Window

ClonePages giving more copies than requested

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=3004
Printed Date: 31 Jan 26 at 11:52AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: ClonePages giving more copies than requested
Posted By: juanf
Subject: ClonePages giving more copies than requested
Date Posted: 11 Nov 14 at 1:27AM
Hi, 

I'm using ClonePage to create multiple copies, When I request 250 copies, it outputs 308 copies, if i request 57 i get 58,  is this a bug with ClonePages? Could Debenu please fix it?

Thanks





Replies:
Posted By: Ingo
Date Posted: 11 Nov 14 at 11:17AM
Hi Juan,
 
i think it's not a bug in the library ;-)
Perhaps you should post the relevant code part here?
So we can have a look telling you what's wrong with it.
 
Cheers and welcome here,
Ingo
 


-------------
Cheers,
Ingo



Posted By: juanf
Date Posted: 11 Nov 14 at 11:51AM
Hello Ingo

See code below.

Tried it by itself, without all the code... same issue.

Dim QP As New DebenuPDFLibraryAX1112.PDFLibrary
        QP = CreateObject("DebenuPDFLibraryAX1112.PDFLibrary")
        If QP.UnlockKey(My.Settings.DebenuLicence) = 1 Then 'Unlock Debenu Library
            'Debenu now unlocked - lets proceed
            'check if file exists
            If Dir(sFilename) <> "" Then 'File exists, we can proceed
                Dim Pages As Long
                Dim Copies As Integer
                Dim CopyAmount As Integer
                Dim CopyFileName As String
                Dim MissingCopies As Integer
                Dim CopiesPageCount As Integer

                'Load file
                QP.LoadFromFile(sFilename, "") 'load file
                QP.SelectPage(1) 'Select first page
                'Set Measurement Units
                QP.SetMeasurementUnits(1) ' 1=mm 0=default user space 2=inches
                'Set Origin
                QP.SetOrigin(1) 'left top
                'Set page count
                Pages = QP.PageCount()
                Copies = InputBox("How Many Copies?")

                If Copies < 500 Then ' use clone instead
                    UpdateStatus("CreateCopies: Creating Copies - Please Wait....")
                    QP.ClonePages(1, Pages, Copies)
                    QP.SaveToFile(sFilename)
                    UpdateStatus("CreateCopies: Copies Done.")
                    QP = Nothing
                    Return "Success"
                    Exit Function
                Else 'use clone multiplier and file copy and then merge
                    CopyFileName = My.Settings.ProcessingPath & "\" & Path.GetFileNameWithoutExtension(sFilename)
                    Debug.WriteLine("CopyFilename: " & CopyFileName)

                    'remove processing path files
                    If IO.Directory.Exists(My.Settings.ProcessingPath) Then
                        Dim fileListings() As String
                        fileListings = IO.Directory.GetFiles(My.Settings.ProcessingPath, Path.GetFileNameWithoutExtension(sFilename) & "*.pdf")
                        For Each File In fileListings
                            IO.File.Delete(File)
                        Next
                    End If

                    'Determine how many copies of the multiplier needs to be created
                    UpdateStatus("CreateCopies: Creating Multiplier")
                    CopyAmount = Int(Copies / 250)
                    MissingCopies = Copies - (250 * CopyAmount)
                    'createMissing copies and store it in temp folder
                    If MissingCopies = 1 Then
                        'copy sfilename to temp folder
                        FileCopy(sFilename, CopyFileName & "0.pdf")
                    ElseIf MissingCopies = 0 Then
                        'do nothing
                    Else
                        QP.ClonePages(1, Pages, MissingCopies)
                        QP.SaveToFile(CopyFileName & "0.pdf")
                    End If
                    UpdateStatus("CreateCopies: Creating Multiplier")
                    Application.DoEvents()
                    'Create Multiplier PDF
                    QP.ClonePages(1, Pages, 250) ' get 308 copies??? really
                    'Save File
                    QP.SaveToFile(sFilename)

                    UpdateStatus("CreateCopies: Creating Copies")
                    Application.DoEvents()
                    

                    'Create Copies
                    For CCopy As Integer = 1 To CopyAmount Step 1
                        FileCopy(sFilename, CopyFileName & CCopy & ".pdf")
                        UpdateStatus("CreateCopies: Copy " & CCopy & " of " & CopyAmount)
                        Application.DoEvents()
                    Next
                    UpdateStatus("Copies Created - Merging copies... please wait")
                    Application.DoEvents()

                    'Merge copy files
                    'Add files to mergelist
                    QP.ClearFileList("MergeList")
                    'populate merge list
                    Dim InFileNames As String
                    Dim Filelist As String() = Directory.GetFiles(My.Settings.ProcessingPath, Path.GetFileNameWithoutExtension(sFilename) & "*.pdf")
                    For Each InFileNames In Filelist
                        QP.AddToFileList("MergeList", InFileNames)
                    Next
                    Debug.WriteLine(QP.FileListCount("MergeList"))
                    QP.MergeFileListFast("MergeList", sFilename)

                    QP.LoadFromFile(sFilename, "")
                    CopiesPageCount = QP.PageCount()
                    If (Copies * Pages) < CopiesPageCount Then
                        QP.DeletePages(1, CopiesPageCount - (Copies * Pages))
                        QP.SaveToFile(sFilename)
                    End If
                    UpdateStatus("CreateCopies: Copies Done.")

                    QP = Nothing
                    Return "Success"
                    Exit Function
                    End If

            Else
                    'File does not exist
                    Return "Failed"
                    MsgBox("CreateCopies: File Does not Exist", vbOKOnly, "Error")
                    Exit Function

            End If
        Else
            'Debenu not active
            Return "Failed"
            MsgBox("PDF Library not active!", MsgBoxStyle.OkOnly, "Error")
            Exit Function
        End If

    End Function


Posted By: juanf
Date Posted: 11 Nov 14 at 12:03PM
Hi Ingo,

Apologies, I only realised now, its because i didnt re-load the file,  that it in fact was using the missingcopies file, instead of the inputfile 

Thanks. 



Posted By: Ingo
Date Posted: 12 Nov 14 at 9:06AM
Hi Juan,
 
it's always helpful describing the own Problem to other ones ;-)
 
Cheers, Ingo


-------------
Cheers,
Ingo




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