Search code examples
pdfghostscriptvirtual-printer

How to get Microsoft Word print docx right with my virtual printer using ghostscript?


I am implementing a program that is the same as google cloud printer. It is a virtual printer using postscript class driver. As the picture shows(I add the 64 suffix). The chinese translating to english is Helpfile, ConfigurationFile DataFile DriverFile Dependency.enter image description here

I use redmon to catch the standard input and use ghostscript to convert it to pdf. At the same time I get the job infomation from printer queue. With the pdf and job infomation, I can send them to my server. Then my server can print the document. I invoke ghostscript as the picture shows.enter image description here

When I use WPS(a chinese application which is the same as Microsoft Word) to print docx document, the job infomation in job queue is correct. For example, when I print test.docx and select three copies, collate, color, I get the right result from job queue. Things get weird when it comes to Microsoft Word. When I use Microsoft Word to print docx, I get the job infomation from queue. No matter how much copies the user specifies, the copies is always one. At the same time, the converted pdf contains one copy too. This means that I have no way to achieve my goal(get pdf and job infomation like copies. Then send them to my server). Does anyone know how I can get the right number of copies, or at least it should behave as Microsoft Print to Pdf printer(as the ps illustrates). My written english is not good. Thanks!

ps: I also have tested Microsoft Print to PDF. If I select three copies in Word, the job infomation in job queue is always one. However, the destination pdf file contains three copies(If the docx is one page, the destination pdf is three pages).


Solution

  • It seems like you've asked two questions here, and only one of them relates to Ghostscript. Your first question seems to be regarding what the Windows print subsystem displays when you print a job, I can't help you with that. In fact I doubt anyone other than the developers of the applications (WPS and Word) can tell you why they drive the print subsystem differently.

    Your second question seems to be 'why do I only get one copy of the PDF file'. The first question I have to ask, then, is what you expect ? Do you expect one PDF file with three copies of the content, or 3 PDF files each containing one copy of the content ?

    There are two possible ways to get multiple copies; firstly send the content three times and alternatively (in the PostScript program) set /#Copies to the number of required copies. I can't tell (because you have not supplied the PostScript program in either case) which approach is being used by each application.

    If your problem is that you are getting three copies from WPS and one copy from Word, then my guess would be that WPS is sending the content 3 times, and Word is sending it once, but setting the number of copies to 3. The pdfwrite device in Ghostscript ignores /#Copies, and only produces one copy of the cotnent in the output.

    You can't change that.