A COMException when I tried to conver a big .doc file to pdf

If you are a C/C++/C# developer and have any questions about using our products from your application here is the place to post them.
Post Reply
nzhong
Posts: 2
Joined: Mon May 12 2003

A COMException when I tried to conver a big .doc file to pdf

Post by nzhong »

I'm trying the DocConerter2.1 Dev version on Window2000. My target is to convert a .doc to a .pdf in my application.

I wrote a little test program (in C# .net) to open a word document, then printed it to the PDF printer, it generated a pdf file beautifully.

However, I encountered a problem later. When I tried it with a bigger .doc file (actually it is not too big, it is about 10+ pages with some tables inside the .doc, 90KB), it failed with a COMException:
“An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in PDFAmyuniTester.exe.
Additional information: Windows cannot print due to a problem with the current printer setup.
Try one or more of the following:
* Check the printer by printing a test page from Windows.
* Make sure the printer is turned on and online.
* Reinstall the printer driver. “

When I try it with a small .doc file, it always works. However when I try it with a big file, sometimes it works, sometimes it doesn’t. Does anyone know what is going on here? Any suggestion on how to solve the problem?

Btw, I also tested the EndUser version, it works beautifully even when I print a 2MB .doc file which contains a lot of image files. How come I just can’t get it working in the developer version?

Thanks
-Nancy

P.S. If you need to know how I used the developer version, here is the details:
“I followed the step-by-step instruction listed in page 5 of "Common Drinver Interface 210.pdf" developer manual.
In Step 2, I choosed running install.exe to install "My PDF Printer". In step 4, I registered CDINF210.dll as a COM object.

Then in my application(C# .net), I refrenced the "Common Driver" COM object, and did the following steps:
CDIntfExClass _pdfPrinter = new CDIntfExClass();
_pdfPrinter.DriverInit("My PDF Driver");
_pdfPrinter.EnablePrinter(….);
_pdfPrinter.FileNameOptionsEx = 1 + 2;
_pdfPrinter.DefaultFileName = outputFileName;
..... // Do a print job, E.g, calling wordApplication.print() to print a .doc to the PDF printer.
_pdfPrinter.FileNameOptions = 0;
_pdfPrinter.DriverEnd();”

All the steps above are pretty-much following the instruction in page5, except for I added a call to EnablePrinter(), since it seems not working without the call.
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hi Nancy,

EnablePrinter will enable the printer for a limited time, this is why you need to call EnablePrinter right before printing and not only after DriverInit or before setting the printer properties.

Hope this helps.

I will move your post to our C / C++ / C # forum as it can be helpful for other developers.
Guest

Thanks Joan

Post by Guest »

I added EnablePrinter(...) right before printing doc to pdf, it works great now.

Thank you for your quick response!
Post Reply