Creating PDFs with C# using Ghostscript
page 1 of 7
Published: 05 Nov 2007
Abstract
PDF has become a standard for secure and reliable distribution and exchange of electronic documents around the world. This article aims at using C# and Ghostscript to convert various other documents into PDF.
by Bhuban Mohan Mishra
Feedback
Average Rating: 
Views (Total / Last 10 Days): 83320/ 95

Introduction

Portable Document Format (PDF) is a file format from Adobe that enables a document to be distributed on different systems while preserving the layout. It has become a standard for secured and reliable distribution and exchange of electronic documents around the world. It preserves the fonts, images, graphics, and layout of any source document, regardless of the application and platform used to create it, thus making it cross-platform and cross-browser compatible.

With the increased use of PDF documents as a universal format for sharing documents and managing the paperless office, it has become a part of the commercial applications to be able to convert documents of different format to PDF. In this article we will discuss how we can use Ghostscript to convert various documents into PDF.


View Entire Article

User Comments

Title: Not working...   
Name: Sumit Goyal
Date: 2012-10-18 9:20:52 AM
Comment:
The code Created Ps but Not Convert in to pdf.
Title: Run Time Error : 1120   
Name: Sumit Goyal
Date: 2012-10-17 6:04:25 AM
Comment:
when I run my application it shows Error printer Error .
Run Time Error: 1120
Please help me what should i do..?
Thanks in advance..!!
Title: when i publish is not working.   
Name: Narayanan
Date: 2012-05-22 4:07:06 AM
Comment:
i've implemented ur code in web site. its working fine locally but its not working when i publish my website.

so can u figure out y so happened? is there any setting to be configuring in IIS or so???

Please kindly guide me.
Title: Recall msg from francis   
Name: Francis
Date: 2012-05-17 4:48:18 AM
Comment:
Hi i recall my posts
Title: No application is associated with the specified file for this operation   
Name: Francis
Date: 2012-05-16 6:49:39 AM
Comment:
\
\
\
Title: Getting pdf from convertToPdf() method   
Name: Francis
Date: 2012-05-16 6:47:07 AM
Comment:
Hi,
convertToPdf() method return string only. how can we get pdf using this string.
Title: Win32 exception   
Name: Deva
Date: 2012-05-16 6:42:13 AM
Comment:
\
\
\
Title: Win32 exception   
Name: Deva
Date: 2012-05-16 6:34:00 AM
Comment:
\
\
Title: Win32 exception   
Name: deva
Date: 2012-05-16 6:31:47 AM
Comment:
\
\
\
\
Title: Process hangs with winword.exe running   
Name: Bud
Date: 2012-04-21 2:32:44 PM
Comment:
Hi,
The archicle is very helpful.
The same code is used and installed in windows2003 server, the logic was working perfectly fine and expected pdf was generated.But we are now facing a problem where the process hangs at converttops() step with winword.exe session running in task manager. Only after giving an End Task it ends the process and generates .pdf file. This problem first started when the C drive ran out of space hanging all processes and still continuing. Do you have any solution to resolve this hanging of winword.exe?
Thanks in Advance.
Title: RE: Download gs856w32.exe file   
Name: Bhuban
Date: 2011-08-24 9:45:29 AM
Comment:
You would need to download and install the ghostscript for windows package.

http://www.ghostscript.com/download/gsdnld.html
http://sourceforge.net/projects/ghostscript/files/GPL%20Ghostscript/9.04/
Title: Download gs856w32.exe file   
Name: Raghvendra
Date: 2011-08-24 6:40:31 AM
Comment:
Hi,
I am not getting the gs856w32.exe file to download on the link "SourceForge" as stated above.Intead their is .tar.bz2 file present. which on extracting after downloading does not contain any bin folder or exe.
please can i get the link to download the gs856w32.exe
so that i can add the dll for GhostsScript in my project.
thanks in advance.
Title: RE: Can the script used to convert.DWG file to .PDF   
Name: Bhuban
Date: 2011-08-24 4:27:24 AM
Comment:
The logic used behind is: Open the file with the default application and print it, the printer being the installed Ghostscript printer. So if you want to print any file, you should have a default application associated with the file, that could read the file format and print the file.
Title: Can the script used to convert.DWG file to .PDF   
Name: Raghvendra
Date: 2011-08-24 3:06:46 AM
Comment:
Hi,
I want to convert the.DWG (autocad) file to PDF format.
I want to know whether this script really works for it
in C#.
Title: Problem with Deployed Application on IIS   
Name: Andreas
Date: 2010-02-23 9:51:10 AM
Comment:
@ Amjad Abdullah (sorry for the late answer) and anyone else: If someone has the problem, that on a server deployed application isn't able to create a ps file, then that may seriously be a problem with user restrictions on the server. IIS 6 starts the default application pool as user "network-service", but this user hasn't otften the rights to do what you want. Now you can assign the needed rights to the network-service or you can simply start the associated application pool as user "system" (its simply a question of security issues)
Title: Re: Convert html to pdf avoid print dailogbox   
Name: Bhuban
Date: 2010-01-13 3:49:09 AM
Comment:
if you check comments below, you will notice that HTML conversion is not that successful as it depends on the Default Browser properties.
Title: Convert html to pdf avoid print dailogbox   
Name: Rethesh
Date: 2010-01-12 7:33:58 AM
Comment:
when i give the html path to convert to pdf it poping up a print dailoge box,which i hav to avoid.if i sselect the corret printer then the pdf is converted.
My question is that can i convert that html file to pdf file with out any promt for that printer selection form.

thanks in advance
Title: How to make the converttops silent   
Name: Rethesh
Date: 2010-01-08 12:27:23 AM
Comment:
yes i have given my code like this


printProcess.StartInfo.CreateNoWindow = true;
printProcess.StartInfo.UseShellExecute = false;
printProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

even if i give that its opening up that word and excel,is there any possiable way to hide that window popuing up....
Title: RE: empty pdf outfile   
Name: Bhuban
Date: 2010-01-06 10:44:22 PM
Comment:
please check if you are getting any exception when waitforexit is called.
Title: empty pdf outfile   
Name: jd
Date: 2010-01-06 2:52:03 PM
Comment:
I am getting and empty pdf file too. I call both functions ConvertToPS and CreatePDF one folloging the other. I red the output string returned from CreatePDF and It look like the CreatePDF function start before the PS file is completed created. Here is the returned string from CreatePDF Function. Please Help!
Title: empty outputfile   
Name: Javier
Date: 2010-01-06 2:24:30 PM
Comment:
Hi andreas, How do you fix the problem with the empty output?
Title: Re: How to make the converttops silent   
Name: Bhuban
Date: 2010-01-06 2:22:46 PM
Comment:
below two lines does the trick.

printProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
printProcess.StartInfo.CreateNoWindow = true;

are you still getting the windows?
Title: How to make the converttops silent   
Name: Rethesh
Date: 2010-01-06 6:46:13 AM
Comment:
hi
i was successfully converted the all office file to pdf through the above code.now my problem is that,can i able to hide that word,excel etx opening up windows while it converting the file to ps

thanks in advance
Title: webbrowser control   
Name: Javier
Date: 2010-01-05 8:56:31 PM
Comment:
I am using a .net webbrowser control to render HTML files instead of calling IE to print them. This approach eliminate the problem with the popup when using html files.
Title: Problem when site is deployed on IIS   
Name: Amjad Abdullah
Date: 2009-12-04 11:07:50 AM
Comment:
Andreas dear,
All things are working properly,
doc, html file is converted successfully in asp.net web application in debug mode. but when this application is deployed on server then no pdf is created. and exception comes that no application is associated to it.
Plz ans now if you understand and if you have solution.
Thanks
Title: Html to PDF - a simple solution   
Name: Andreas
Date: 2009-12-04 7:10:56 AM
Comment:
I have the solution for all the people who can print .doc files with the ghostscript printer but no .html files. I had the same problem as described earlier:
Always i've tried to print .html files through the application, it throws an error saying there is no application associated with the file, while right click on a .html file choosing print with the "Ghostscript PDF" printer works perfectly.
A solution for that problem is simply to save the .html file as a .doc file and print it then again!

i solved my last problem simply with a reinstall of gs and the according printers.

For Amjad Abdullah: If the ps file is not created, i think that there is no "gswin32c.exe" in the application path. Also the ps printer has to run on the server!
Title: Mr   
Name: Amjad Abdullah
Date: 2009-12-02 8:11:55 AM
Comment:
I have a problem, when I deployed the site for creating Ps file. The ps file is not generated as the printer do not run on the server. I am unable to solve the problem. The printer is not initiated so ps file can not be produced. Plz help me!!!
Title: empty outputfile   
Name: Andreas
Date: 2009-12-01 11:16:00 AM
Comment:
Hi Bhuban,

i've just tried to put your code into my application (asp.net using c#). It seems to work (office comes up and starts to print) - so it runs without any problems - and generates some output. but the outputfile is everytimes very small 1-3kb completely empty while the gsoutput.ps has nearly 5300kb (is there a posibility to get the ps file rendered). Do you have any suggestions where there's the rub?
Title: Re: Concerning Standard Input and Output   
Name: Bhuban
Date: 2009-11-18 11:29:48 AM
Comment:
Not anything that I know. You may get some info from the latest gs documentation.
http://pages.cs.wisc.edu/~ghost/doc/svn/Readme.htm
http://pages.cs.wisc.edu/~ghost/doc/svn/Use.htm
Title: Re: Concerning Standard Input and Output   
Name: Master Prize
Date: 2009-11-18 8:50:27 AM
Comment:
I appreciate your answer. I actually had the command corrected already when I first executed it and the process does wait for further input that's why it is never completed. My puzzlement lies with the fact that this only happens when it is executed on the cmd. On the other hand, when the command is executed on the stream as your code does, it actually finishes the process just fine without requiring or waiting for further input.

One more thing, some word documents, particularly those which use tables, tend to be rendered inaccurately when it is converted to pdf. Are there any command switches that can remedy and improve the overall quality of the rendered pdf?
Title: Re: Concerining Standard Input and Output   
Name: Bhuban
Date: 2009-11-18 3:54:30 AM
Comment:
When it waits @ WaitForExit(), does it create any output? The Process might be waiting for some input if it never completes. A way to know the error is to show the gswin32c window.

You can also check the arguments. The command above is wrong due to HTML formatting issues.

The exact command is:
gs864w32 -q -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile="Pdf File Path" -fc:||gsoutput.ps

NB: Replace | with backslash.

On the streams point, the command provided has to be executed to get the output. Executing it via cmd is the easiest way to do it, as we can send the arguments as is.
Title: Concerining Standard Input and Output   
Name: Master Prize
Date: 2009-11-17 4:57:16 AM
Comment:
I tried playing with the CreatePdf method. My question is, why is there a need to execute the command on the stream? I tried doing it by removing the StreamWriter and StreamReader objects altogether by simply using info.FileName = "swin32c.exe" and the info.Arguments property. My code then would proceed to pdfProcess.Start(). However, I noticed that it hangs when the code reaches pdfProcess.WaitForExit(). It seems to be on an infinite loop or something. Could you explain the logic of why the need to utilize streams when executing the command as opposed to just executing it via console?
Title: RE: manual export   
Name: Bhuban
Date: 2009-10-19 11:15:58 AM
Comment:
Yes it will definitely retain the fonts.
Title: manual export   
Name: niidmore
Date: 2009-10-14 3:51:47 PM
Comment:
Hi Bhuban,
I have a VB.net program which uses Microsoft Words API to export Doc to PDf, however the problem is its not embedding fonts to the exported PDF. I wonder If I your tool embeds the font in the PDF? Please can you also advise if I can somehow manually export to the PDF and check the fonts?

Thanks
Sam
Title: Re: How to do through .NET Code   
Name: Dhanasekar
Date: 2009-09-18 10:45:29 AM
Comment:
Hi, How to convert as PDF with output of web page using .NET
Title: RE: Problem with html   
Name: Bhuban
Date: 2009-08-25 11:41:40 PM
Comment:
Hi wei, Please check comments "Re: html to pdf?" below...
Title: RE: Installing ghostscript in hidden manner   
Name: Bhuban
Date: 2009-08-25 11:15:47 PM
Comment:
Hi Puneet,
You can get the zip/gz file instead of the installer, and unzip it in desired location to install ghostscript.
Title: Installing ghostscript in hidden manner   
Name: Puneet
Date: 2009-08-25 2:51:12 PM
Comment:
Hello,
I want to install ghostscript without showing wizards.
Means that i want to install it using codes.

Please help, I am in big mess.

Thax in advance.
Title: Problem with html   
Name: wei
Date: 2009-08-24 3:22:08 PM
Comment:
Great article, I tried and it works with *.doc.
the problem is I can't automatically print html files directly to gs printer. the choose printer panel is always pop-up.

Any tips for this?
Title: Re: how to see output   
Name: Bhuban M Mishra
Date: 2009-06-29 6:05:22 AM
Comment:
hay boss,
just to refresh your common sense, you will be able to see the output where you store it... ;)
Title: how to see output   
Name: rupesh
Date: 2009-06-28 4:55:58 AM
Comment:
hi bhuban, how can i see the .pdf file. can u explain a bit more clearly
Title: RE: can't find the output file   
Name: Bhuban
Date: 2009-06-21 12:33:48 AM
Comment:
Hello John,

It won't be possible to achieve this directly through ASP.NET. Alternatively you can achieve this by a two way process.

1. Do what ever is needed in the web app.
2. For converting a document use a windows service, that will convert the documents by picking it from some folder and converting it to PDF.

Hope this is helpful, though the process will depend on your requirement.
Title: can't find the output file   
Name: John
Date: 2009-06-20 7:18:46 PM
Comment:
hello there nice article. i'm trying to work it out in an ASP.net application. the PS file is generated correctly but the pdf file never generated. any tips?
Title: supress file open dialog while creating PS file   
Name: Rohit
Date: 2009-02-23 10:05:19 AM
Comment:
while executing convertToPs() to create PS file, original file opens for a moment for printing and closed down. Is there any way to hide this popup? I have searched so may option, but nothing full proof.
Title: Re: How it works with gs864w32   
Name: Bhuban
Date: 2009-02-20 11:05:38 AM
Comment:
Hi Cedric,

Here is your correct syntax:

"gs864w32 -q -dNOPAUSE -sDEVICE=pdfwrite " + "-sOutputFile=|"" outputPath + "|" -fc:||gsoutput.ps";

Please replace | with backslash.
Title: Simple Method To create PDF using .net   
Name: Thomas
Date: 2008-12-18 12:46:29 AM
Comment:
To create PDF file we can use itextsharp. This is a opensource program.For more details check
http://techdotnets.blogspot.com/
Title: Re: How to set GhostPDF printer PORT programmatically   
Name: Bhuban
Date: 2008-11-29 1:23:57 AM
Comment:
Hi Shantanu,

If you have enabled printer pooling, then OS and drivers should be handling that. Though I am not an expert in this field, you can consult some Windows Administrators who knows more about Printer Pooling.

About printing to a specific port, the "printto" command actually takes 4 arguments:
1. File Name
2. Printer Name
3. Printer Driver
4. Printer Port

Check this article on MSDN (Static vs. Dynamic Verbs):
http://msdn.microsoft.com/en-us/library/bb776883.aspx

According to this, the last 2 arguments are now obsolete and were used for Windows 3.1. We are far forward, and what I know is, the OS should be handling this.

You can still try to print to the specific port by providing the 4th argument and see if it works.

Thanks,
Bhuban
Title: Re: Unable to create PDF file from PostScript file   
Name: Bhuban
Date: 2008-11-17 8:42:56 PM
Comment:
Please send exact error/problem you are facing. A code snippet would be more useful.

PS: Please write to bhuban.mishra@wipro.com for quicker response.
Title: Unable to create PDF file from PostScript file   
Name: bhuban
Date: 2008-11-17 11:27:36 AM
Comment:
Hi hey i have used this method to create a pdf file from a word file but the problem is i'm able to created Postscript file from .doc file but i'm able to create .pdf file from the postscript...... please help ASAP
Hari
Title: Re: Win32 exception   
Name: Bhuban
Date: 2008-11-03 10:03:22 AM
Comment:
I think the program is unable to find the input file. You need to provide the full path of the input file.
Title: Win32 exception   
Name: Seetha
Date: 2008-10-29 6:02:51 AM
Comment:
While using the method converttoPS win32 exception(System cannot find the specified file) error is coming.Please provide me help
Title: Re: Setting Orientation   
Name: Bhuban M. Mishra
Date: 2008-07-16 5:21:55 AM
Comment:
Hi Shihantha,

I googled a lot in the last 2 days. But, I could not find a way of setting orientation while printing a document from a Process object. It is possible by using the PrintDocument object.

You can check for that and try.

- bhuban
Title: Setting Orientation   
Name: Shihantha
Date: 2008-07-16 1:10:34 AM
Comment:
Do you know if its possible to set orientation within the code when creating the PS file. I need to print onto Landscape for certain documents.

Thanks again
Title: Setting orientation   
Name: Shihantha
Date: 2008-07-14 9:49:05 PM
Comment:
Thanks Bhuban, using IE does bring up the print dialog box which may beimpossible to get around. I was also wondering if you knew the code to assign page orientation to landcape when we define the printer process.

Thanks heaps
Title: Re: html to pdf?   
Name: Bhuban M. Mishra
Date: 2008-07-14 12:18:52 PM
Comment:
Hi,

Let me first discuss what are we doing with the functions. In the method convertToPs(), we are creating a new Process object that takes the reference of the file that we provide. Then, we are requesting the process to execute the print operation on the file. Now, this process depends entirely on the Windows OS. Each file type have been assigned some default applications to run with. The mapping can be found from Tools -> Folder Options -> File Types tab.

If any file type is not defined here, then the Operating System will not be able to open the file or do any of the operations that are desirable. In order to make a process object do some operations on a file, the file type must be registered to some application.

If HTML file are registered to be opened with some default application, then the process will be executed successfully, else will throw errors.

Some time back one of our friends came up with the same problem, where he was able to print HTML pages, but it popups the Print Dialog with IE and with FireFox, nothing happens. When I tried, I found the following:

# If default application for HTML file is Firefox, no result.
# If default application for HTML file is IE, it opens up the Print dialog.

Now these problems are more related to Windows and its browsers. I am afraid we do not have much solution to these.

But, if the default application for HTML files or HTM files are defined in the File Types, then it will definitely execute the process successfully.

Thanks,
Bhuban
Title: html to pdf?   
Name: Shihantha
Date: 2008-07-14 3:53:40 AM
Comment:
Hi,

is it possible to convert HTML documents to pdf using this app. I tried but the converttpPS section throws an error saying there is no application associated with the file. A simple double click opens the file in IE.

Thanks
Title: re: now working in publish version in web application   
Name: Bhuban M. Mishra
Date: 2008-07-08 8:06:52 AM
Comment:
Hi Sudhir,

Its good to know that it is now working. It would be great if you add the settings here, so that other can also get benefited.

The error is related to MSWord, so I think you are trying to print a word document, and the user who is trying to print do not have access to msword.

Thanks,
Bhuban
Title: now working in publish version in web application   
Name: sudhir thanki
Date: 2008-07-08 3:22:33 AM
Comment:
i'm getting this error now in my event viewer.

Detection of product '{90110409-6000-11D3-8CFE-0150048383C9}', feature
'WordUserData', component '{8ADD2C93-C8B7-11D1-9C67-0000F81F1B38}' failed.
The resource 'HKEY_CURRENT_USER|Software|Microsoft|Office|11.0| Word|UserData'
does not exist.

where | denotes backslash
Title: re: not working in publish version in web application   
Name: Bhuban M. Mishra
Date: 2008-07-07 6:02:44 AM
Comment:
http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.windowsxp.print_fax&tid=0c642741-fd06-4e6e-9ed0-6be6269656f6&cat=&lang=&cr=&sloc=&p=1

this is definitely going to be permission issues.
Title: re: not working in publish version in web application   
Name: Bhuban M. Mishra
Date: 2008-07-07 5:55:32 AM
Comment:
from my initial search on google i think it is related to some kind of permission issues. not sure what kind of.

http://www.velocityreviews.com/forums/t181341-xp-home-nonadmin-user-cant-print.html

May be, IIS do not have access to that printer, or the port. I am still looking for a solution. I will let you know as and when I get something.
Title: re: not working in publish version in web application   
Name: sudhir thanki
Date: 2008-07-07 3:58:25 AM
Comment:
and process is still going on. We have to stop that process by force in IE.

It is working fine when normal web application but when I published that application at that time I get this type of error .

Can u get what's the problem when Web application is published and configure with IIS.

Means it is run on the localhost.

Thanks.
Title: re: not working in publish version in web application   
Name: sudhir thanki
Date: 2008-07-07 3:57:53 AM
Comment:
Error is registered in the Event Viewer - > Application / System

"The document Full page print owned by ASPNET failed to print on printer Ghostscript PDF. Data type: NT EMF 1.008. Size of the spool file in bytes: 2424832. Number of bytes printed: 0. Total number of pages in the document: 1. Number of pages printed: 0. Client machine: 'Machine name'. Win32 error code returned by the print processor: 5 (0x5)."

and

"Printer Ghostscript PDF was purged."
Title: re: not working in publish version in web application   
Name: Bhuban M. Mishra
Date: 2008-07-07 3:22:14 AM
Comment:
Hi Sudhir,

I have never tried this with web applications. But, if it is working locally, then it should also work when the application is hosted. Though I am not sure, but the server where the application is hosted, should also have ghostscript installed on it.

Is it giving any kind of errors ?

Thanks,
Bhuban
Title: not working in publish version in web application   
Name: sudhir thanki
Date: 2008-07-05 8:18:41 AM
Comment:
hi,
i've implemented ur code in web site. its working fine locally but its not working when i publish my website.

so can u figure out y so happened? is there any setting to be configuring in IIS or so???
Title: Correction to CreatePdf()   
Name: Bhuban M. Mishra
Date: 2008-06-10 2:27:47 AM
Comment:
There is an error in the CreatePdf method where a command for generating Pdf file is provided. The outputPath is actually provided through the function as a parameter, and so should be appended.

string command = "gswin32c -q -dNOPAUSE -sDEVICE=pdfwrite " + "-sOutputFile=|"" + outputPath + "|" -fc:||gsoutput.ps";

NOTE: The | above is a replacement to backslash.

Thanks,
Bhuban
Title: Re: PS file wont convert to PDF   
Name: Bhuban M. Mishra
Date: 2008-06-06 3:22:08 AM
Comment:
Hi Shihantha,

can you send me the application at my mail bhuban_m_mishra@yahoo.com. It might help me to get into the problem.

Thanks,
Bhuban
Title: PS file wont convert to PDF   
Name: Shihantha
Date: 2008-06-06 2:06:55 AM
Comment:
Thanks a lot for this article. I sent you an email regarding this, my program creates the PS file but it does not create a PDF. I saw the response to a question earlier on but having the gswin32c.exe in the application path does not fix it. Would appreciate if you had any ideas on this. Thanks
Title: Re: Is it necessary to install printer First   
Name: Bhuban M. Mishra
Date: 2008-05-27 3:12:01 AM
Comment:
Hello Neha,

Yes, you will have to install both ghostscript and the virtual printer for both testing the code as well as for running the application on another system.

Thanks,
Bhuban
Title: Is it necessary to install printer First   
Name: neha gupta
Date: 2008-05-26 8:13:00 AM
Comment:
hello bhuban
tell me before desing the code first we install the printer
Title: Re: Please Guide Me   
Name: Bhuban M. Mishra
Date: 2008-05-26 3:59:31 AM
Comment:
Hello Deepak,

If you want to merge PDF files, then you can directly use the merging option of ghostscript. The command for the same would go like this:

gswin32 -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=Merged.pdf -dBATCH 1.pdf 2.pdf 3.pdf

Here Merged.pdf is the merged pdf output. 1.pdf, 2.pdf and 3.pdf are the files that needs to be merged. And for these files, you may have to provide the full path instead of just their file names.

Thanks,
Bhuban
Title: Please guide me   
Name: Deepak Kataria
Date: 2008-05-24 9:26:34 AM
Comment:
Hi Bhuban.
I am working on a live project in .net.I have to build a utility which picks pdfs from a directory merge all the pdf and generate one .ps file and print this .ps file.
Now i am merging pdf files from directory and want to create one pdf file.
After that I will convert that pdf file into .ps file.

I think that you are the right person to whom i can discuss.

Thanks and regards,
Deepak Kataria
Title: re: I got .ps file   
Name: Bhuban M. Mishra
Date: 2008-05-23 8:28:15 AM
Comment:
Hi,

Its good to know that you were able to get the .ps file.

Merging pdfs could be possible, you can go through the ghostscript help for the same. You may have to use some other tools like ps2pdf that is available with the ghostscript lib.

Thanks,
Bhuban
Title: Can we create .ps file several pdfs from a directory   
Name: Deepak Kataria
Date: 2008-05-23 7:29:14 AM
Comment:
Hi Bhuban,
Could we create 1 PostScript file from several pdfs which are store in a directory(folders and subfolders).
Please suggest me.

Thanks and regards,
Deepak Kataria
Title: Got an error   
Name: Deepak Kataria
Date: 2008-05-23 7:18:15 AM
Comment:
Hi Bhuban,
I got an like below.
//The name 'ret' does not exist in the current context.//
Please look into the matter.
Please help me.
Thanks and regards,
Deepak Kataria
Title: Re: Can we save .ps file   
Name: Bhuban M. Mishra
Date: 2008-05-22 9:39:18 AM
Comment:
The ps file is saved as gsoutput.ps, or the same file that was used to create the local port while installing the printer driver.

If you want the ps file, then you can copy it to some other location after converting the doc file to ps.

Thanks,
Bhuban
Title: Can we save .ps file   
Name: Deepak Kataria
Date: 2008-05-22 8:59:03 AM
Comment:
Hi Bhuban,

Thanks a lot for your immediate response.

Can we save the .ps file?

Thanks and regards,
Deepak Kataria
Title: Re: What should i write on the click event of both button   
Name: Bhuban M. Mishra
Date: 2008-05-22 4:09:08 AM
Comment:
Hi Deepak,

Converting a word document to PDF is a two step process.
1. Convert Word to PS.
2. Convert PS to PDF.

So, when you convert the doc to PDF, you need to first call the convertToPs method and then call convertToPdf method.

In figure 9 of this article, you will see a form with 2 buttons. One is for selecting the file to convert and the second convert calls the two functions concurrrently. First the convertToPs() and then convertToPdf().

Thanks,
Bhuban
Title: What should i write on the click event of both button.   
Name: Deepak Kataria
Date: 2008-05-22 1:45:41 AM
Comment:
Hi Bhuban,
Please tell me what should i write on the click event of both bottons(.... and Convert).
Hoping to hear from your side soon.
Waiting 4 ur reply.

Regards,
Deepak Kataria
Title: Please suggest me   
Name: Deepak kataria
Date: 2008-05-21 10:01:10 AM
Comment:
Hi Bhuban,
I have to create an utility which convert pdf to .doc from a directory.
Please suggest me what should i start from.
Please help me.

Reagrds,
Deepak Kataria
Title: Re: Re:Re: I got an error pls suggest   
Name: Bhuban M. Mishra
Date: 2008-05-20 2:42:40 AM
Comment:
Hi,

I do not have much idea about simplex / duplex printing for pdfs.

Check the following links:
http://ghostscript.com/doc/8.54/Ps2pdf.htm
http://www.ghostscript.com/~ghostgum/pdftips.htm

If you can get something from it, please let us know.

Thanks,
Bhuban
Title: Re:Re: I got an error pls suggest   
Name: Deepak Kataria
Date: 2008-05-20 12:54:30 AM
Comment:
Hi Bhuban,

Thanks a lot.

1. Could we use printing option like simplex (single side page print) or duplex (both side printing of page).

2. Could we use batch size of the printing page like for single side 500 pdfs and for duplex 200 pdfs.

Please suggest me.

Regards,
Deepak Kataria
Title: Re: I got an error pls suggest   
Name: Bhuban M. Mishra
Date: 2008-05-19 9:21:11 AM
Comment:
Hello Deepak,

The namespace to be used is: System.Diagnostics

Check this link for details.
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx

Thanks,
Bhuban
Title: I got an error pls suggest   
Name: Deepak Kataria
Date: 2008-05-19 8:38:05 AM
Comment:
Hi Bhuban,

I am making an which will print pdfs from a directory and convert it to ps.
I got an error.
Error1: The type or namespace name 'Process' could not be found (are you missing a using directive or an assembly reference?)

Error2:The type or namespace name 'Process' could not be found (are you missing a using directive or an assembly reference?)

Error3: The name 'ProcessWindowStyle' does not exist in the current context

Please take a look and suggest which reference should i use.
Thanks in advance.
Hoping to hearing from your side soon.

Regards,
Deepak Kataria
Title: Re: Can you lock the pdfs   
Name: Bhuban M Mishra
Date: 2008-04-30 2:04:42 PM
Comment:
Hello Steve,

Yes, you can lock pdf by encrypting it. But for this, you will have to use ps2pdf that is available in the lib directory of ghostscript.

Check the following links:
http://ghostscript.com/doc/8.54/Ps2pdf.htm
http://www.ghostscript.com/~ghostgum/pdftips.htm

- Bhuban
Title: Can you lock the pdfs   
Name: Steve
Date: 2008-04-30 1:31:41 PM
Comment:
I need to be able to programmatically lock the pdf as it is created so you cannot copy text. Is this possible with this tool.
Title: Re: Fine with Windows but problem in Web Application   
Name: Bhuban
Date: 2008-03-12 7:54:11 AM
Comment:
Hi Viruddhi,

Though I have not implemented this through a Web application, but it should work with both Windows Application and Web application.

The difference would be, the GhostScript should be installed on the Server and the gswin32c.exe should be present in the Virtual Directory, which is the applcation startup path.

This is just a wild guess. I will try to implement this in a Web application and will revert back if I get something.

Thanks,
bhuban
Title: Fine with Windows but problem in Web Application   
Name: Vruddhi
Date: 2008-03-12 7:20:22 AM
Comment:
Hello,
Thanks for replying to my last query. My probelm is solved. The code is working fine in Windows environmet but not in Web Environment. Is this code aplicable to Windows Application only?
Please reply...
Thanks in Advance..
Vruddhi
Title: Re: PDF To Image   
Name: Bhuban M. Mishra
Date: 2008-02-28 3:09:27 PM
Comment:
Hi Sajid,

Check my blog article:
http://techno-corner.blogspot.com/2008/02/convert-your-pdf-to-images-pdf-is-one.html

This has the details of converting a PDF file into images. You will also find a small C# application to download.

On the distribution of ghostscript, it depends on the License. Ghostscript is available both as GPL and AGPL license. You can go through them to more about distribution.

Thanks,
Bhuban
Title: PDF To Image   
Name: Sajid Shaikh
Date: 2008-02-28 5:25:26 AM
Comment:
Hi Bhuban,

Great article.

Could you please guide me on how I can use GhostScript to convert PDF file to jpg/tiff/bmp file page wise using C#. Also can I distribute ghostscript to my client free?

Thanks,
Sajid
Title: Re: Helpfull article   
Name: Vinayak Rajmane
Date: 2008-01-11 4:09:28 AM
Comment:
Hi Bhuban ,
Thanks for your quick reply .
My use is limited to .ps file :)
It will be really helpfull if you could post the code snippet.

Thanks for your g8 help
Vinayak.
Title: Re: Helpfull article   
Name: Bhuban M. Mishra
Date: 2008-01-10 12:27:09 PM
Comment:
Hi Vinayak,

No, we can not specify the path for storing the .ps file through our application.

What we are actually doing here is that we are creating a Virtual Printer that prints to a .ps file. We then programatically use the gswin32c.exe file to create pdf out of the generated .ps file.

One thing we can do is that, we can create an application that will create a printer and we can specify the .ps file over there. I will try to post a code snippet on this soon.

Thanks,
Bhuban
Title: Helpfull article   
Name: Vinayak Rajmane
Date: 2008-01-10 6:16:39 AM
Comment:
Hi bhuban ,

This is really nice article you have provided.

I have one question
Can we specify the path for storing .ps file via application ?

thanx in advance
Title: Re: Problem in conversion from PS to PDF   
Name: Bhuban
Date: 2008-01-04 4:16:25 AM
Comment:
Hi Viruddhi,

I am quoting your comment below. There seems to have a bug which replaces the message with back slashes, if the message contains one.

[QUOTE]
Hello Bhuban,

I have followed the whole process of installation of ghostScript to Adding Printer to writing the C# code. But I am facing problem in conversion of PS to PDF. I get the PS format in C:||GSOUTPUT.PS but then I have to manually double click on it and make it run to get the PDF File. Am I missing out something? Please revert back.

Thanks in advance..
Vruddhi
[/QUOTE]

Here is my answer:

One thing that comes to my mind is that, you need to have gswin32c.exe in the bin/Debug folder or the application startup path. This might be a problem, if you have not added it in your Application Startup path. If this do not work, you can send me the code at bhuban_m_mishra@yahoo.com, so that I can check.

Regards,
Bhuban
Title: Great Help   
Name: Jack Nicholson
Date: 2007-11-06 7:51:26 AM
Comment:
Dude, excellent article, really of gr8 help. stuck with lot of problems kinda this, it dissolved all my hassles.
Title: GS API   
Name: mike61079
Date: 2007-11-06 12:19:33 AM
Comment:
Just a FYI there is a GS API for this kind of thing.






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-03-28 6:33:02 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search