Unable to catch error when cancel is clicked on Print Dialog

The PDF Creator enables you to create secure PDF documents and to view, print and process existing PDF documents.
If you have any questions about the installation and usage of the PDF Creator please post them here.
Post Reply
anshuman82
Posts: 21
Joined: Mon Feb 12 2007
Contact:

Unable to catch error when cancel is clicked on Print Dialog

Post by anshuman82 »

I am using following code to print the current page but I am unable to catch the error when Cancel button is clicked on Print Dialog. The contol never reaches to ErrorHandler.

I am using PDFCreator Active X.

Please help me out as i don't want to application to crash

With PDFCreactiveX1
On Error GoTo ErrorHandler
.StartPrint "", True

.PrintPage .CurrentPage
.ClearPage .CurrentPage
.EndPrint
End With

Exit Sub

ErrorHandler:
Err.Raise Err.Number, Err.Source, Err.Description
Anshuman
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

I tried your below sample using version 3.01 of the PDF Creator and the control reached the error handler if I click on Cancel instead of OK on the printer selection page.

Which version of the PDF Creator are you using?

Where precisely are you clicking on 'Cancel', when selecting the printer or after printing starts?
Jose
Amyuni Team
Posts: 553
Joined: Tue Oct 01 2002
Contact:

Post by Jose »

Hello,

If the user clicks on “Cancel” there is an exception that is thrown by the control. It is up to the developer to handle this exception with example: “Try/Catch” or “On Error”

try
{
axPDF.Open (txtFileName.Text , "");
axPDF.CurrentPage = 1;
axPDF.PrintPage (1);
axPDF.EndPrint();
}
catch(Exception ex)
{
MessageBox.Show (ex.Message);
}


Hope this helps?
anshuman82
Posts: 21
Joined: Mon Feb 12 2007
Contact:

Post by anshuman82 »

I am able to catch the unhandled error.
It was VB IDE settings which was not allowing the error to be handled.

Thanks for reply
Anshuman
Post Reply