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()
Related
I searched houres about, how I can print a pdf silently from C# including AcroJs.
I know there are solutions for it, like starting AdobeReader as Process by CommandLine and Print the document. (http://www.codeproject.com/Tips/598424/How-to-Silently-Print-PDFs-using-Adobe-Reader-and)
But this solutions always open the Reader. Even if you can hide the window,depending on the speed of your computer, you can see the adobe reader window a few seconds. I need a workaround which doesn't open the reader but process the AcroJS forms in pdf jut like the normal reader.
Do you konw any alternatives oder libs, that I can use?
How do I print PDFs silently with procesing AcroJS and wthout open the Adobe Reader process in c#?
Thanks :)
Your application need to be built using the Adobe Reader OCX or some PDF library. Then, the application needs to be configured to use a default printer. It can then be issued commands to print documents without showing a window.
I have made an desktop application using C# to make ID card .And i am required to add functionality of printing an ID card .Basically i just make an image in a win form which will be eventually printed using.
But as i have no printer,i can't test my code to see if it prints something.
Is there any emulator or software that emulates a printer in windows,so that i cant test my application?
This is a sample what i need to print.It wiil be in a win form.
And another thing. How can i maintain size of the id card while printing. Say id card size should be in 2inch * 3.5inch. How can i make sure it will print same size?
You can use the Microsoft XPS printer driver that ships with Windows (since Vista, but available for Windows XP)
The XPS Document Writer allows you to create .xps files using any
program that you can print from in Windows. Print to the XPS Document
Writer when you want to create, send, and share or publish documents
that you do not want other people to modify, or when you want to print
a document or display it online exactly as it appears on your screen.
It's also a good idea to create an XPS document for files that contain
graphics or illustrations that might otherwise display differently in
print than online or on computers with different monitors.
Once you click OK, you're prompted for the file path to save it to.
Try print to PDF file to check that Your application works. For example You can use "PDF Creator" under Windows OS's. It is the easiest way.
I need to take a PDF file url, send it as a parameter to a web service that will print it on a network printer. It has to be done server side without any user interaction.
Do you know some libraries that we can use to acheive that ? We look at different options like iTextSharp but it looks like there's no way to print from that library.
Thanks.
If you can download the file and save it as a PDF and have Acrobat Reader installed you can use a command line to print it (shell it).
http://www.robvanderwoude.com/commandlineswitches.php#Acrobat
Print a PDF file silently:
AcroRd32.exe /N /T PdfFile PrinterName [ PrinterDriver [ PrinterPort ] ]
It would be nice to know what commercial component you used...
I had to something like that, but using PCL. We used winspool.drv to open the printer, start a document then a page, write out the bytes, then end the page & document and close the printer. We installed PCL drivers for the printer on the local machine to print to a network printer.
You might be able to do something like that with Postscript drivers. A quick test would be to to a binary copy of a PDF to the printer using the command prompt and the /B switch on copy. I think you specify the PDF and the printers network share as source/destination. Use a small PDF to avoid getting a ream of random characters in case it doesn't work.
We'll finally use a commercial component that does all this by itself.
Thanks for your help.
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.
If I have adobe reader installed, is it possible to programmatically print the document to a specific printer without having adobe reader or the printer dialog display (no user intervention)? Any code snippets or sugestions are helpful. I can use any version of the .net framework to accomplish this
No, it is not. IIRC, you can tell acrobat reader to print the document for you via the command line. But when you do it's going to prompt you via the gui to tell it what printer to use.
Edit:
Hmm, maybe you can do it almost silently. Check this link:
http://support.adobe.com/devsup/devsup.nsf/docs/52080.htm
Found via this old answer:
Send document to printer with C#
Used to do this back in the novell print queue days so it should at least work in theory. If you can figure out a way to convert the PDF into postscript you can then stream it to a postscript printer and print that way.