Print Page | Close Window

Printing PDF via DLL from service causing Hang

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=1352
Printed Date: 18 May 24 at 6:41PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Printing PDF via DLL from service causing Hang
Posted By: GField
Subject: Printing PDF via DLL from service causing Hang
Date Posted: 01 Mar 10 at 9:17PM
Hi
I'm using the DLL to print PDFs created via a merge process.  The Service (Metastorm BPM) is a workflow tool running an web application. I have create a fascade class with static members to perform a number of methods including GetPrinters and Print Document.
 
The web page calls via the service to the methods below. The printer name is correct and the process works most of the time.  Once I have pruinted a PDF, if I wait 20 minutes or so, the Metatsorm service hangs with a message, failed to read address.
 
Faulting application dllhost.exe, version 5.1.2600.5512, stamp 48025165, faulting module unknown, version 0.0.0.0, stamp 00000000, debug? 0, fault address 0x09c87b9c.
 
Is this because I haven't released the library. I have looked through various examples and none appear to release the library after instantiating, although your Getting started documentation mentions it, I'm not instantiating the DLL that way and can't get the release to run.
 
I'm running XP Pro, with IIS running in .net 2.0. Can you check if the class is ok? The Metastorm service and application has been working fine until I implemented the PDF printing section this morning. I've run the code through nunit individually with successful.  When I attempt to request 100 prints of the same PDF i get the following error (after requesting 38 copies)

TestQuickPDFFascade.TestPrintPDFToPrinter : Failed

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at QuickPDFDLL0717.DLL.DelegateII.Invoke(Int32 P1)
at QuickPDFDLL0717.DLL.Release() in about:file%3A%2F%2FBE6CB011-9384-41D9-94A0-F961B1F56144%2Fd%3ACorresAction%2Ff%3AQuickPDFDLL0717.cs%3Fline%3D1187%26column%3D1 - QuickPDFDLL0717.cs: line 1187
at QuickPDFDLL0717.DLL.Finalize() in about:file%3A%2F%2FBE6CB011-9384-41D9-94A0-F961B1F56144%2Fd%3ACorresAction%2Ff%3AQuickPDFDLL0717.cs%3Fline%3D1178%26column%3D1 - QuickPDFDLL0717.cs: line 1178
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at QuickPDFDLL0717.DLL.DelegateI.Invoke()
at QuickPDFDLL0717.PDFLibrary..ctor(String dllFileName) in about:file%3A%2F%2FBE6CB011-9384-41D9-94A0-F961B1F56144%2Fd%3ACorresAction%2Ff%3AQuickPDFDLL0717.cs%3Fline%3D1906%26column%3D1 - QuickPDFDLL0717.cs: line 1906
at FieldConsultancy.Correspondence.CorresAction.QuickPDFFascade.GetQpLibrary(String quickPdflibraryFile) in about:file%3A%2F%2FBE6CB011-9384-41D9-94A0-F961B1F56144%2Fd%3ACorresAction%2Ff%3AQuickPDFFascade.cs%3Fline%3D129%26column%3D1 - QuickPDFFascade.cs: line 129
at FieldConsultancy.Correspondence.CorresAction.QuickPDFFascade.PrintPDFFileToPrinter(String quickPdflibraryFileString fileNameString printerNameNullable`1 startPageNullable`1 endPage) in about:file%3A%2F%2FBE6CB011-9384-41D9-94A0-F961B1F56144%2Fd%3ACorresAction%2Ff%3AQuickPDFFascade.cs%3Fline%3D101%26column%3D1 - QuickPDFFascade.cs: line 101
at FieldConsultancy.CorrespondenceTest.TestQuickPDFFascade.TestPrintPDFToPrinter() in about:file%3A%2F%2FEBFA656D-AE31-41B7-B1D1-A452AFE40753%2Ff%3ATestQuickPDFFascade.cs%3Fline%3D97%26column%3D1 - TestQuickPDFFascade.cs: line 97
 
If you need any more information, let me know
Thanks
Graham Field
 
 
 
The Nunit code is:
 

[Test]

public void TestPrintPDFToPrinter()

{

for (var i = 0; i < 100;i++ )

{

Assert.AreEqual(1,

QuickPDFFascade.PrintPDFFileToPrinter(_pdfLibraryFile, "tempHtml2.PDF",

"Auto EPSON Stylus Photo RX640 Series on CAS02", 1, 1));

}

}

Code from Fascade is:-
 

public static int PrintPDFFileToPrinter(string quickPdflibraryFile, string fileName,

string printerName, int? startPage, int? endPage)

{

if (!File.Exists(fileName))

{

throw new FileNotFoundException("pdf File not found", fileName);

}

if (!fileName.ToLower().EndsWith(".pdf"))

{

throw new FileLoadException("Not a PDF File", fileName);

}

PDFLibrary qp = GetQpLibrary(quickPdflibraryFile);

if (qp.LoadFromFile(fileName) == 0)

{

throw new FileLoadException("Cannot load PDF file", fileName);

}

if (startPage == null)

{

startPage = 1;

}

if (endPage == null)

{

endPage = qp.PageCount();

}

if (printerName == "")

{

printerName = GetDefaultPrinter(qp);

}

int printOptions = qp.PrintOptions(0, 0, fileName);

return qp.PrintDocument(printerName, (int)startPage, (int)endPage, printOptions);

}

 

public static string GetPrinters(string quickPdflibraryFile)

{

PDFLibrary qp = GetQpLibrary(quickPdflibraryFile);

string printers = qp.GetPrinterNames();

return printers.Replace("\"", "");

}

private static PDFLibrary GetQpLibrary(string quickPdflibraryFile)

{

PDFLibrary qp = new PDFLibrary(quickPdflibraryFile);

if (qp.LibraryLoaded())

{

if (qp.UnlockKey("My Evaluation key here") != 1)

{

throw new ApplicationException("******* QuickPDF Key not Working ***********");

}

}

return qp;

}



-------------
Cheers
Graham Field

Field Consultancy Ltd



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