Print Page | Close Window

Removing document from QuickPDF

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: Sample Code
Forum Description: Share Debenu Quick PDF Library sample code with other forum members
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3619
Printed Date: 22 Nov 24 at 1:10PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Removing document from QuickPDF
Posted By: kumarp11
Subject: Removing document from QuickPDF
Date Posted: 12 Oct 18 at 6:53PM
Hi,
I am using the below code to print a PDF file. I am printing multiple tickets one after another. When I try to issue quickPDF.RemoveDocument(DocID) after issuing quickPDF.PrintDocument(), print is always coming out blank, even though print function is returning 1 and when I comment out quickPDF.RemoveDocument(DocID) print is coming out fine. I am using quickPDF.SelectedDocument() after quickPdf.LoadFromString() to get the documentID of document just loaded. I want to remove old document which has already been printed before loading new document using quickPdf.LoadFromString()

PDFLibrary quickPdf = _objQuickPdf as PDFLibrary;
                int result = quickPdf.LoadFromString(data, null); - Data here is a UTF-8 byte stream
                if (result != 1)
                {
                    //Log statement
                }
                if (quickPdf.NewPage() == 0)
                {
                    Log("The page could not be added");
                }
                int captureID = quickPdf.CapturePage(1);
                if (captureID == 0)
                {
                    Log("QuickPDF: The specified page does not exist, or it is the only page in the document");
          
                }
                if (quickPdf.SetOrigin(1) != 1)
                {
                    Log("QuickPDF: Failed to set origin for the new page");
                }
                quickPdf.SetMeasurementUnits(1);
                if (pageScaling.ToUpper() == "TRUE")
                {
                    double scaleFactor = scalePercentage;
                    double horizBorder = width * (1.0 - scaleFactor) / 2;
                    double vertBorder = height * (1.0 - scaleFactor) / 2;
                    if (quickPdf.DrawCapturedPage(captureID, horizBorder, vertBorder, width - 2 * horizBorder, height - 2 * vertBorder) == 0)
                    {
                        Log("QuickPDF: An invalid CaptureID was specified");
                    }
                }
                else
                {
                    if (quickPdf.DrawCapturedPage(captureID, xPosition, yPosition, width, height) == 0)
                    {
                        Log("QuickPDF: An invalid CaptureID was specified");
                    }
                }
                int iPrintOptions = quickPdf.PrintOptions(0, 0, ticketName);
                int printreturnvalue = quickPdf.PrintDocument(PrinterName, 1, 1, iPrintOptions);



Replies:
Posted By: Ingo
Date Posted: 13 Oct 18 at 12:19PM
What's before and after your code?
Is it a loop?
There's no free...?
Do you use the one instance for each print job?
If yes: I would free it starting a new instance for each printing.
What's about the pdf-content... encrypted or not?
If yes: Do the unencryption first...



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



Posted By: kumarp11
Date Posted: 15 Oct 18 at 6:19AM
It is not a loop. We are just picking the data from dependent system and processing it. We are just getting the data and printing it.
We are not using one instance for each printing. 
We are just creating the Debenu instance once in our project during project startup. while printing for each print  ,we are using
 PDFLibrary quickPdf = _objQuickPdf as PDFLibrary;
which is nothing but the assignment ,not creating the new instance and using this for printing as mentioned in the code snippet.

PDF content is in UTF-8 byte stream


Posted By: Ingo
Date Posted: 15 Oct 18 at 8:58PM
mmmmh... i can't see a code snippet ;-)
Try it with new instances for each printout and let us see if it works then.



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



Posted By: kumarp11
Date Posted: 15 Oct 18 at 9:00PM
Thanks. Here is the code snippet again for your kind reference..

PDFLibrary quickPdf = _objQuickPdf as PDFLibrary;
                int result = quickPdf.LoadFromString(data, null); - Data here is a UTF-8 byte stream
                if (result != 1)
                {
                    //Log statement
                }
                if (quickPdf.NewPage() == 0)
                {
                    Log("The page could not be added");
                }
                int captureID = quickPdf.CapturePage(1);
                if (captureID == 0)
                {
                    Log("QuickPDF: The specified page does not exist, or it is the only page in the document");
          
                }
                if (quickPdf.SetOrigin(1) != 1)
                {
                    Log("QuickPDF: Failed to set origin for the new page");
                }
                quickPdf.SetMeasurementUnits(1);
                if (pageScaling.ToUpper() == "TRUE")
                {
                    double scaleFactor = scalePercentage;
                    double horizBorder = width * (1.0 - scaleFactor) / 2;
                    double vertBorder = height * (1.0 - scaleFactor) / 2;
                    if (quickPdf.DrawCapturedPage(captureID, horizBorder, vertBorder, width - 2 * horizBorder, height - 2 * vertBorder) == 0)
                    {
                        Log("QuickPDF: An invalid CaptureID was specified");
                    }
                }
                else
                {
                    if (quickPdf.DrawCapturedPage(captureID, xPosition, yPosition, width, height) == 0)
                    {
                        Log("QuickPDF: An invalid CaptureID was specified");
                    }
                }
                int iPrintOptions = quickPdf.PrintOptions(0, 0, ticketName);
                int printreturnvalue = quickPdf.PrintDocument(PrinterName, 1, 1, iPrintOptions);


Posted By: Ingo
Date Posted: 15 Oct 18 at 10:41PM
Try it with new instances for each printout and let us see if it works then.

-------------
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