How to print a PDF with C#

前端 未结 11 570
抹茶落季
抹茶落季 2020-12-14 17:58

I´ve trying to solve this problem for nearly 2 days. There are a lot of more or fewer good solutions on the net, but not a single one fits my task perfectly.

11条回答
  •  -上瘾入骨i
    2020-12-14 18:46

    I tried many things and the one that worked best for me was launching a SumatraPDF from the command line:

    // Launch SumatraPDF Reader to print
    String arguments = "-print-to-default -silent \"" + fileName + "\"";
    System.Diagnostics.Process.Start("SumatraPDF.exe", arguments);
    

    There are so many advantages to this:

    1. SumatraPDF is much much faster than Adobe Acrobat Reader.
    2. The UI doesn't load. It just prints.
    3. You can use SumatraPDF as a standalone application so you can include it with your application so you can use your own pa. Note that I did not read the license agreement; you should probably check it out yourself.

提交回复
热议问题