• <legend id='1K86d'><style id='1K86d'><dir id='1K86d'><q id='1K86d'></q></dir></style></legend>

  • <small id='1K86d'></small><noframes id='1K86d'>

      <bdo id='1K86d'></bdo><ul id='1K86d'></ul>
      1. <i id='1K86d'><tr id='1K86d'><dt id='1K86d'><q id='1K86d'><span id='1K86d'><b id='1K86d'><form id='1K86d'><ins id='1K86d'></ins><ul id='1K86d'></ul><sub id='1K86d'></sub></form><legend id='1K86d'></legend><bdo id='1K86d'><pre id='1K86d'><center id='1K86d'></center></pre></bdo></b><th id='1K86d'></th></span></q></dt></tr></i><div id='1K86d'><tfoot id='1K86d'></tfoot><dl id='1K86d'><fieldset id='1K86d'></fieldset></dl></div>

        <tfoot id='1K86d'></tfoot>

        如何使用 Windows 10 附带的 Microsoft Print To PDF 打印机以编程方式打印到 PDF 文

        时间:2023-09-15

          <legend id='EIU9K'><style id='EIU9K'><dir id='EIU9K'><q id='EIU9K'></q></dir></style></legend>
          • <bdo id='EIU9K'></bdo><ul id='EIU9K'></ul>

              <tbody id='EIU9K'></tbody>

            <small id='EIU9K'></small><noframes id='EIU9K'>

              1. <tfoot id='EIU9K'></tfoot>
                <i id='EIU9K'><tr id='EIU9K'><dt id='EIU9K'><q id='EIU9K'><span id='EIU9K'><b id='EIU9K'><form id='EIU9K'><ins id='EIU9K'></ins><ul id='EIU9K'></ul><sub id='EIU9K'></sub></form><legend id='EIU9K'></legend><bdo id='EIU9K'><pre id='EIU9K'><center id='EIU9K'></center></pre></bdo></b><th id='EIU9K'></th></span></q></dt></tr></i><div id='EIU9K'><tfoot id='EIU9K'></tfoot><dl id='EIU9K'><fieldset id='EIU9K'></fieldset></dl></div>
                • 本文介绍了如何使用 Windows 10 附带的 Microsoft Print To PDF 打印机以编程方式打印到 PDF 文件而不提示 C# 中的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  Microsoft Windows 10 附带 Microsoft Print To PDF 打印机,可以将内容打印到 PDF 文件.它会提示下载文件名.

                  Microsoft Windows 10 comes with a Microsoft Print To PDF printer which can print something to a PDF file. It prompts for the filename to download.

                  如何通过 C# 以编程方式对此进行控制,使其不提示输入 PDF 文件名,而是保存到我提供的某个文件夹中的特定文件名?

                  How can I programmatically control this from C# to not prompt for the PDF filename but save to a specific filename in some folder that I provide?

                  这用于以编程方式将大量文档或其他类型的文件打印到 PDF 的批处理.

                  This is for batch processing of printing a lot of documents or other types of files to a PDF programmatically.

                  推荐答案

                  要使用 Microsoft Print to PDF 打印机打印 PrintDocument 对象而不提示输入文件名,请点击此处是纯代码的方式来做到这一点:

                  To print a PrintDocument object using the Microsoft Print to PDF printer without prompting for a filename, here is the pure code way to do this:

                  // generate a file name as the current date/time in unix timestamp format
                  string file = (DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds.ToString();
                  
                  // the directory to store the output.
                  string directory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                  
                  // initialize PrintDocument object
                  PrintDocument doc = new PrintDocument() {
                      PrinterSettings = new PrinterSettings() {
                          // set the printer to 'Microsoft Print to PDF'
                          PrinterName = "Microsoft Print to PDF",
                  
                          // tell the object this document will print to file
                          PrintToFile = true,
                  
                          // set the filename to whatever you like (full path)
                          PrintFileName = Path.Combine(directory, file + ".pdf"),
                      }
                  };
                  
                  doc.Print();
                  

                  您也可以将此方法用于其他另存为文件类型的打印机,例如Microsoft XPS打印机

                  You can also use this method for other Save as File type printers such as Microsoft XPS Printer

                  这篇关于如何使用 Windows 10 附带的 Microsoft Print To PDF 打印机以编程方式打印到 PDF 文件而不提示 C# 中的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:C# MessageBox 对话框结果 下一篇:如何从 Windows 10 UWP 应用程序连接到 SQL Server 数据库

                  相关文章

                  1. <tfoot id='LRWNp'></tfoot>
                      <bdo id='LRWNp'></bdo><ul id='LRWNp'></ul>
                  2. <small id='LRWNp'></small><noframes id='LRWNp'>

                    <legend id='LRWNp'><style id='LRWNp'><dir id='LRWNp'><q id='LRWNp'></q></dir></style></legend>
                    <i id='LRWNp'><tr id='LRWNp'><dt id='LRWNp'><q id='LRWNp'><span id='LRWNp'><b id='LRWNp'><form id='LRWNp'><ins id='LRWNp'></ins><ul id='LRWNp'></ul><sub id='LRWNp'></sub></form><legend id='LRWNp'></legend><bdo id='LRWNp'><pre id='LRWNp'><center id='LRWNp'></center></pre></bdo></b><th id='LRWNp'></th></span></q></dt></tr></i><div id='LRWNp'><tfoot id='LRWNp'></tfoot><dl id='LRWNp'><fieldset id='LRWNp'></fieldset></dl></div>