Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

In my code i have to generate postscript file using a word word document and finally it converts to PDF document using the postscript file(Using Acrobat Distiller).

I have one issue here while it converts word document to postscript file it is taking time to generate postscript file. Issue is with out completing the generated of the postscript file my code moves to next statement to generated PDF file using postscript file as Input parameter. Here i want to put a check whether a postscript file generation completed and then it should move to the next statement to generate PDF.

Here is my code:-

Code to Convert Word to PostScript file

C#
public Word.Application objWordApp = null;
public Word.Document objWordDoc = null;
object objMissing = System.Reflection.Missing.Value;
if (Convert.ToString(objWordApp.ActivePrinter) != AdobePDF)
{
   SetDefaultPrinter(AdobePDF);
}
objWordDoc.PrintOut(ref objMissing, ref objMissing, ref objMissing, objWordOutputPath, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing);
 
//Code Which converts Postscript file to PDF
private PdfDistiller objPDFMaker;
public void ConvertToPDF(string psfile, string outputName)
{
objPDFMaker.FileToPDF(psfile, outputName, "");
}


Could you please help me out how can i check whether a Postscript file generation Completed ?

Thanks in Advance Dilip.
Posted
Updated 28-Jan-14 0:27am
v2
Comments
TnTinMn 28-Jan-14 21:54pm    
Are you targeting MS Word 2003 and earlier? If not, why not save the document in PDF format directly from Word?
Member 8645356 29-Jan-14 4:47am    
yeah i am using Word 2003 the point here is we are using some fonts loaded in acrobat distiller.

I tried using PDFMaker which converts word to PDF directly but we are not getting the exact pdf which contains images and text on it. To avoid this issue we are using some fonts loaded in Acrobat Distiller and we are converting word to .ps and then .ps to PDF.
TnTinMn 29-Jan-14 17:46pm    
I do not have Abode, so I have no idea if any of these hacks would work. The first one probably is the safest method.

1. If the PS file exists before printing delete it. Print to PS file. Run a loop where you check in the file exists and you can open it with exclusive access. Sleep on failure. Once you have an exclusive lock, close the file and proceed. Put in some type of maximum iteration control.

2. Assuming that AdobePDF uses the print queue, create an instance of System.Printing.PrintQueue and check that the NumberOfJobs property. If zero, I would assume that objWordDoc.PrintOut has finished and that the file is created.

3. If the AdobePDF driver spawns a new process each time you print (big assumption), you may be able to use WMI and a WqlEventQuery to capture the __InstanceCreationEvent and __InstanceDeletionEvent events for that process. The __InstanceDeletionEvent would signal that the file has been created.



This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900