不显示文件保存对话框,将“Print FixedDocument / XPS”转换为PDF。
创始人
2025-01-10 09:00:22
0

要实现不显示文件保存对话框,将"Print FixedDocument / XPS"转换为PDF,可以使用PdfSharp库。以下是一个示例代码:

using PdfSharp.Xps;
using PdfSharp.Pdf;

public void ConvertToPdf(string xpsFilePath, string pdfFilePath)
{
    // Load the XPS document
    var xpsDocument = new PdfSharp.Xps.XpsDocument(xpsFilePath, System.IO.FileAccess.Read);

    // Create the PDF document
    var pdfDocument = new PdfDocument();

    // Iterate through each page of the XPS document and add it to the PDF document
    for (int pageIndex = 0; pageIndex < xpsDocument.PageCount; pageIndex++)
    {
        var xpsPage = xpsDocument.GetPage(pageIndex);
        var pdfPage = pdfDocument.AddPage();
        var pdfRenderer = new PdfSharp.Xps.Rendering.XpsRenderer(xpsPage, pdfPage);
        pdfRenderer.RenderVisual(xpsPage.Visual);
    }

    // Save the PDF document to the specified file path
    pdfDocument.Save(pdfFilePath);

    // Close the XPS document and the PDF document
    xpsDocument.Close();
    pdfDocument.Close();
}

你可以使用上述代码的ConvertToPdf方法,将一个XPS文件转换为PDF文件。你需要提供XPS文件的路径和PDF文件的保存路径作为方法的参数。

相关内容

热门资讯

重大来袭!德普之星私人局透视,... 您好,这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多玩家在这款游戏中打...
据悉!约局吧德州透视,德普之星... 据悉!约局吧德州透视,德普之星透视辅助软件,都是是真的有挂(有人有挂)小薇(辅助器软件下载)致您一封...
今日百科!aapoker辅助插... 今日百科!aapoker辅助插件工具,pokemomo辅助工具,原来是真的有挂(有挂教程)1、玩家可...
最新消息!智星菠萝辅助,德普辅... 最新消息!智星菠萝辅助,德普辅助软件,真是是真的有挂(真是有挂)1、每一步都需要思考,不同水平的挑战...
如何分辨真伪!hardrock... 如何分辨真伪!hardrock透视工具,hh poker透视器下载,原来真的是有挂(果真有挂)1、完...
于此同时!德州局透视脚本免费版... 于此同时!德州局透视脚本免费版下载手机版,德扑软件,原来真的是有挂(有挂功能)在进入德扑软件软件靠谱...
今日公布!aapoker破解侠... 今日公布!aapoker破解侠是真的吗,微扑克游戏辅助器,原来真的是有挂(有挂助手)1、进入游戏-大...
攻略辅助挂!wpk有辅助器吗,... 攻略辅助挂!wpk有辅助器吗,德普之星透视辅助软件是真的吗,一贯真的是有挂(竟然有挂)1)德普之星透...
传递经验!wepoker辅助是... 传递经验!wepoker辅助是真的假的,wepoker免费透视脚本,一直有挂(果真有挂)1、wepo...
经核实!哈糖大菠萝开挂,德普之... 经核实!哈糖大菠萝开挂,德普之星透视辅助,其实存在有挂(有挂教程)1、不需要AI权限,帮助你快速的进...