none
Solution for a v4 Print Driver to File (Virtual) RRS feed

  • Question

  • Hey guys,

    is there a way to develop a vritual v4 print driver that can print to a local file without dialog (static path)?

    I read the Microsoft documentations for v4 but i don't understand how can i grab the document stream and put it as PS or XPS to a specific location.

    Thank you for your ideas!

    Sven

    Wednesday, October 23, 2019 8:32 AM

All replies

  • Hi Sven!

    Any driver can print to static file. What determines where the content goes to is not the driver, it's the port. When you create a printer that uses your driver, do the following:

    1) Go to Settings > Devices > Printers & scanners, click "Add a printer or scanner" and wait until the "The printer that I want isn't listed" link shows up.

    2) Click that link. The Add Printer Wizard will show up. Choose "Add a local printer or network printer with manual settings". Click Next

    3) On the next page, choose "Create a new port", choose Local. Click Next

    4) The port name should be the path to the file. Click Next

    5) Choose your driver and follow the rest of the steps. That will create a printer that prints to a specific file using your driver.

    Wednesday, October 23, 2019 7:50 PM
  • Hey Luiz,

    thank you for the response.

    You solution does not work for me. Also i need to disturb the printing driver and v4 does not support third-party ports-monitors.

    My idea was to grab the XPS document int the render filter and write it to a local file. In samples they handle Print Tickets there and i don't now how to get instead the XPS-Document from the stream.

    Thursday, October 24, 2019 7:21 AM
  • FAIK you already know
    https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/14f551f7-0f8a-4d0d-876b-09fa42077888/port-monitor-for-printer-driver-inf?forum=wdk#c4d8f6ba-fb54-46f4-871e-b0abc43b0dbd
    Would think, you can dump the data in e.g.
    StreamFilter::StartOperation
    https://github.com/microsoft/Windows-driver-samples/tree/master/print/SimplePipelineFilter
    But for the filter is as a default running in context of 'Local Service', which has its limitations maybe it helps to 'impersonate' see code in above sample:
    StreamFilter::InitializeFilter
    But in general, would agree with the proposal of Luiz.
    Could even imagine writing a simple socket server, say listening on default port 9100 to use 'standard TCP/IP port monitor' gives more lexibility or even using
    https://github.com/istopwg/ippsample/tree/master/server

    With kind regards


    Thursday, October 24, 2019 9:52 AM
  • Hey Maybe,

    first: Thank you.

    I tried SimplePipelineFilter at StartOperation (in the v4-driver render-filter). But the data getting read from the stream there (IPrintReadStream) are just the PrintTicket data.

    <?xml version="1.0" encoding="UTF-8"?>
    <psf:PrintTicket xmlns:psf="http://schemas.microsoft.com/windows/2003/08/printing/printschemaframework" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1" xmlns:ns0000="Your private namespace URI goes here" xmlns:psk="http://schemas.microsoft.com/windows/2003/08/printing/printschemakeywords"><psf:ParameterInit name="ns0000:PageDevmodeSnapshot"><psf:Value xsi:type="xsd:string">SwBEAE8AIABQAHIAaQBzAGUAIAAoAEMAbwBwAHkAIAAzADQAKQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEEAwbcAHADAzcBAAEAAQDqCm8IZAABAAEAWAIBAAEAWAIDAAEATABlAHQAdABlAHIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAgAAAAEAAAD/////R0lTNAAAAAAAAAAAAAAAAERJTlUiAPgAVAMcADJXDaYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD4AAAAU01USgAAAAAQAOgAewA0ADYANQBkADcAMgAyADEALQBhAGQANQBjAC0ANAAwADkAYwAtADkAZgA4ADUALQBmADUAZQA0ADQAMwA1AGUAMQBlADUAOQB9AAAASW5wdXRCaW4AVVBQRVIAUkVTRExMAFVuaXJlc0RMTABPcmllbnRhdGlvbgBQT1JUUkFJVABSZXNvbHV0aW9uAE9wdGlvbjEAUGFwZXJTaXplAExFVFRFUgBEdXBsZXgATk9ORQBJSFZTdGFwbGluZwBPZmYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAAABWNERNAQAAAAAAAAAAAAAAAAAAAAAAAAA=</psf:Value></psf:ParameterInit><psf:ParameterInit name="psk:JobCopiesAllDocuments"><psf:Value xsi:type="xsd:integer">1</psf:Value></psf:ParameterInit><psf:Feature name="psk:PageMediaSize"><psf:Option name="psk:NorthAmericaLetter"><psf:ScoredProperty name="psk:MediaSizeWidth"><psf:Value xsi:type="xsd:integer">215900</psf:Value></psf:ScoredProperty><psf:ScoredProperty name="psk:MediaSizeHeight"><psf:Value xsi:type="xsd:integer">279400</psf:Value></psf:ScoredProperty></psf:Option></psf:Feature><psf:Feature name="psk:JobInputBin"><psf:Option name="ns0000:UPPER"/></psf:Feature><psf:Feature name="psk:PageOrientation"><psf:Option name="psk:Portrait"/></psf:Feature><psf:Feature name="psk:PageResolution"><psf:Option name="ns0000:Option1"><psf:ScoredProperty name="psk:ResolutionX"><psf:Value xsi:type="xsd:integer">600</psf:Value></psf:ScoredProperty><psf:ScoredProperty name="psk:ResolutionY"><psf:Value xsi:type="xsd:integer">600</psf:Value></psf:ScoredProperty></psf:Option></psf:Feature><psf:Feature name="psk:JobDuplexAllDocumentsContiguously"><psf:Option name="psk:OneSided"/></psf:Feature><psf:Feature name="psk:JobStapleAllDocuments"><psf:Option name="psk:None"/></psf:Feature></psf:PrintTicket>

    But i want the "raw" print document data.

    A port solution is not a good way for my situation. The Microsoft "Print to PDF" and "Print to XPS" print driver also handle this in a unknown way without extra port.

    Greetings

    //Edit

    Bidi, Filter and GDL give no solution for saving the data as file. V4 don't support port monitors so i think it is not possible. Back to the roots and write an v3 driver....



    Thursday, October 24, 2019 11:49 AM
  • Printing from Notepad/Paint I get different result:

    Also XPS-Viewer does not complain, when opening the written files.

    (Windows Server 2019)

    With kind regards


    Edit: Substituted the render filter of V4 printer-template with the stream-filter of SimplePipeLineFilter 
    Thursday, October 24, 2019 2:04 PM