简体   繁体   中英

VB.NET PrintDialog Print to file

I am using .NET (VB) Graphics to print/preview reports in a pre-defined format (like tax forms), which works just fine.

I would also like to be able to have the ability to accumulate one or more different reports and save them to a file for later conversion to PDF or to use the XPS print driver to print them.

When I check the "print to file" box (for a regular laser printer or the XPS print driver), and click "Print", I do not get an Open File dialog as this article suggests I should ( http://www.functionx.com/vcnet/controls/print.htm ). The operation seems to proceed normally, but I have no idea where to find the file, if in fact one is created.

What am I missing? Can anyone offer an alternative method of accumulating Graphics reports and printing or printing to a file?

TIA for your time.

Is the print dialog actually associated with the PrintDocument instance? Code like this works well:

    private void button1_Click(object sender, EventArgs e) {
        printDocument1.PrinterSettings.PrintToFile = true;
        printDocument1.PrinterSettings.PrintFileName = @"c:\temp\test.xps";
        printDocument1.Print();
    }

Why not use a PDF Printer? On the net you will find numerous free solutions.
The one I like more is BullZip but there are other options. If you look for this kind of solution be aware of the dead ends (like adware toolbar or strange licensing terms).
However, this scenario has definite advantages, like you can define a folder as your document base and every time you print, you PDF printer remembers where to create a PDF document.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM