Print Page | Close Window

PrintDocument() crashing application

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=1233
Printed Date: 11 May 25 at 5:26PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: PrintDocument() crashing application
Posted By: stakon
Subject: PrintDocument() crashing application
Date Posted: 09 Oct 09 at 10:02AM
Good day,

I have recently started to use your QuickPDF dll for C++.
I find it very friendly and contains most things i will need.

Although most features run smoothly, unfortunately i have encountered the following problem:
When using PrintDocument() my program crashes when trying to execute:

result = QuickPDFPrintDocument(instanceID, sp1, StartPage, EndPage,Options);
which is located in the QuickPDFDLL0715.cpp file.

Here is my code before invoking PrintDocument():
          
int res;//check var for returned results
           std::string selectedPrinter;
            std::string printerNames = QP.GetPrinterNames();//Printers in string seperated by comma
            std::string token;
            std::istringstream iss(printerNames);

            while ( getline(iss, token, ',') )//tokenize and get firsst printer
            {
                selectedPrinter = token;
                break;//only take the 1st printer
            }

            std::string customPrinterName;
            customPrinterName = QP.NewCustomPrinter(selectedPrinter);//create new custom printer from the one we selected
            //Setup various values of the printer...
            res = QP.SetupCustomPrinter(customPrinterName,6,1);//Color = monochrome
            res = QP.SetupCustomPrinter(customPrinterName,11,2);//Orientation = landscape
            //Setup varous print options
            int printOptions = QP.PrintOptions(0,0,"Custom Title of document");//scaling,rotation,title
             QP.PrintDocument(customPrinterName,1,2,printOptions);//print the pages within this range
           ***HERE THE PROGRAM CRASHES***

Note that all the above arguments are checked and all "res" values return success.
Any ideas?

Thanx in advance,

Stakon.





Replies:
Posted By: Ingo
Date Posted: 09 Oct 09 at 10:46AM
Hi Stakon!

Is the content of customPrinterName correct?
Is the content identical to the printer in your system?
BTW: There's a good sample for you in the brandnew "QuickPDF library demo" Rowan talked about in the general section here. Try it.

Cheers and welcome here,
Ingo



Posted By: stakon
Date Posted: 09 Oct 09 at 12:08PM
Hello again,

I have just downloaded your demo, it looks very nice.
It helped me resolve the error.I found what caused it:

When calling QP.GetPrinterNames() the Printer names are separated by commas and each one is within quotes "".
So in my above example the string tokens are within quotes.I will trimm my string from the "" and hope everything runs smoothly.

Stakon.




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