I have an application that creates a temporary postscript file.
After it runs its main routines, it tries to print the file. However, when I send RAW data to the printer, nothing comes out.
I've also tried the PrintDocument class using this example from the MSDN and that prints the postscript code instead of the resulting graphics.
Is there a way to print a postscript file from C# or would I have to use an outside program such as GhostScript?
Related
In the advanced print settings inside adobe acrobat reader, I have noticed that there is a print to file option. I am currently developing a library of functions in vb.net that prints files of various formats to print language files (postscript). I can't seem to find however a way to access this functionality programmatically, is there a way to do this without using a third party tool as I need to try and avoid using external libraries if at all possible.
You can use the PrintDocument class to print to a PostScript printer on the FILE: port. PostScript print drivers are provided with Windows by default. An example is HP LaserJet 2800 PS, which is provided with Server 2008. Generally if it has PS in the name the printer will be able to print to file.
https://learn.microsoft.com/en-us/dotnet/api/system.drawing.printing.printersettings.printtofile
...
printDocument1.PrinterSettings.PrintToFile = true
printDocument1.PrinterSettings.PrintFileName = "c:\temp\test.ps"
printDocument1.Print()
i'm creating a PDF Creator equivalent and I have to add some options to it while using C# language.
I would like to know how I can intercept data that was sent to the printer and how I can save it in a c# variable.
My printer launches the program as follows. Redmon is used as a redirection port
Program's like Redmon allow you to save the data to file. Save it as a temp file then pass in the filename as a command line argument. You could also pass it in as stdin/stdout which is how Redmon passes it into Ghostscript but temp file solution should work well and is easy to implement.
Previously I'd asked about adding my c# windows app as virtual printer. I managed to get it done with RedMon and Ghostscript. Now when I press Ctrl + P the control is transferred to my app and i need the particular job as input to my app from the job queue. It seems it is possible to convert the postscript to any format, so how do I get this postscript file of the job.
OR
My app can convert .PS files to any format with the help of GhostScript, and I need to find the postscript of a job. How can this be done? Or Where can I find these PostScript Files of a particular print job.
In my project we need to use a virtual printer and then catch the file (most of the times its bitmap) and extract data from it. and transform it into xml like so .
<document name="file://C:\DOCUME~1\ilanit\LOCALS~1\Temp\p0129600584.htm">
<lineXY x="0" y="0" height="1656" width="2275" />
Is it something like Redmon you are looking for (used in conjunction with output to file and the launch an application)? If so you can use it or there are others out there too. Redmon is a little dated and depending on the OS you might have issues. If you can, add more detail and specifics to your question as it's a bit confusing.
UPDATE (based on comments): If the source is PDF or some other document (ie: Word) that has actual text and not just graphics (scan/image) type data you could use a Postscript driver (type 1 might work best) and then extract the text after you capture the print file. If you are not going to use the print file for actual output and just need the data, you can always try the Generic Text driver in Windows as it will ignore graphcis and just put the text in the output file. As long as the output is consistent and a little Regex should be able to pull out what you need.
If the data is graphical in nature such as a scanned image that you are printing, you will need to capture the print job, turn it into a graphic image (as it will be a print file with PCL or Postscript etc.) and then run it through an OCR engine to pull out what you need.
I'm not sure if this is possible but as I was looking for a way to convert docx -> pdf serverside (Aspose is a bit expensive), I wondered if I could do this by printing my document to a Pdf Printer.
Altho, I would need a decent one then, as it shouldn't show dialogs when trying to print ofc.
Does anyone know if:
This is possible
There exists such a printer which can be easily used in a WCF Service
Thanks
Try pdfcreator.
PDFCreator is a free tool to create PDF files from nearly any Windows application.
Key Features:
Create PDFs from any program that is able to print
...
Terminal Server: PDFCreator also runs on Terminal Servers without problems
If you can read DOCX content and print from your WCF service, the pdfcreator printer driver will generate PDF from anything.