none
Building a custom Virtual Printer Driver RRS feed

  • Question

  • My objective is to develop a custom printer driver. The functionality of the driver will be to convert the document into PDF and upload it into a database. I have my Visual Studio 2017 and WDK10 installed. How should I proceed further?
    Thursday, June 7, 2018 5:05 AM

All replies

  • Consider the LEADTOOLS Virtual Printer SDK (https://www.leadtools.com/sdk/print/virtual-printer) which you can use to create a virtual printer that captures the EMF file from printing from any valid Windows application. You can then use this EMF output to generate your desired PDF output.

    (Disclaimer: I am an employee of this toolkit’s vendor)

    The code for handling the captured EMF and saving it as PDF would look like this:

    // Write the EMF as file to disk as PDF.
    static void VirtualPrinter_EmfEvent( object sender, EmfEventArgs e )
    {
       string pdfPath = "Output.pdf";
    
       // Create an instance of the LEADTOOLS DocumentWriter
       DocumentWriter docWriter = new DocumentWriter();
       docWriter.BeginDocument( pdfPath, DocumentFormat.Pdf );
    
       DocumentEmfPage page = new DocumentEmfPage() 
       {
          EmfHandle = new Metafile( e.Stream ) )
             .GetHenhmetafile()
       };
       docWriter.AddPage( page );
       docWriter.EndDocument();
    }
    

    Thursday, June 21, 2018 5:46 PM