The function convertToPdf() in Listing 2 takes one argument: Provided by Ghostscript and are converting the postscript file created by the Then we are using the gswin32c.exe the Command line utility Here, we are creating a process and opening the WindowsĬommand window. This method is the final step of our application whichĬonverts the postscript file generated by the Ghostscript printer in the above Need to catch this exception and ignore it for the normal operation of our job. In this case we get an InvalidOperationException. Print job completes, the process does not get disposed as the Application was Same process that was running is used to open the new word document. In this case, no new process is invoked rather the Say for instance, Microsoft Word is running on our system and we are editing aĭifferent document on it. Here, the OS will invoke Microsoft Word to open the document for printing. But we haveĪlso used a try block where we are catching the InvalidOperationException, butĭocument, the associated application is invoked by the Operating System as a Used the WaitForExit() method to wait until the process completes. The time taken toĬonvert the document to PDF depends on the size of the document. These are the required properties that are to be set, toĬonvert our document to postscript. The installed "Ghostscript PDF" printer, if it has not been set as aĭefault printer, we need to pass "printto" as the Verb and the The default verb for printing any document is "print."īut, this will use the default printer to print the document. This is converted to postscript in this method.Īs the Process Verb. Then we create a new Process, with theīe converter to PDF. This method takes in one argument, the full path of the file Wait until the PostScript file is created try Ghost PDF printer is a postscript printer, it will create the printable format Know that we are using the installed PDF printer to print the file. ![]() If we look closely at the code in Listing 1, we will get to ![]() So, we will have 2 functions,convertToPs()Īnd convertToPDF(), that actually depicts these two process. Process, one that converts the document to postscript and the other thatĬonverts the postscript file to PDF. So, we will need this file toīe copied to the bin\Debug folder of the project.Īs stated earlier, the conversion process is a two step That helps to convert the postscript file to PDF. That initiates the PDF conversion process.Īnother important part of the process is the gswin32c.exe To a document that we wish to convert to PDF. First, put a Textbox and a Button to browse and point Let us create a small Windows application in C# to make this Print Add To Favorites Email To Friend Rate This Article ASP.NET Tutorials » Creating PDFs with C# using Ghostscript
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |