不显示文件保存对话框,将“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文件的保存路径作为方法的参数。

相关内容

热门资讯

据悉!wepoker黑侠破解,... 据悉!wepoker黑侠破解,德普之星app安卓版破解版,总是确实有挂(新版有挂)1、金币登录送、破...
目前来看!hhpoker辅助器... 目前来看!hhpoker辅助器视频,德扑之星怎么设置埋牌,一贯存在有挂(详细教程)进入游戏-大厅左侧...
黑科技插件!德普辅助软件,德扑... 黑科技插件!德普辅助软件,德扑之星怎么设置埋牌,总是确实有挂(有挂分析)1、德扑之星怎么设置埋牌免费...
昨日!哈糖大菠萝能开挂吗,德扑... 昨日!哈糖大菠萝能开挂吗,德扑之星怎么设置埋牌,一贯确实有挂(有挂透明挂)1、任何德扑之星怎么设置埋...
黑科技技巧!aapoker透视... 黑科技技巧!aapoker透视脚本下载,智星菠萝可以辅助吗,确实确实有挂(有人有挂)1、进入到智星菠...
此事引发网友热议!wepoke... 此事引发网友热议!wepoker辅助真的假的,德普之星怎么设置埋牌,真是真的有挂(有挂教程)1、德普...
日前!pokemmo手机版脚本... 日前!pokemmo手机版脚本,德普软件,确实是真的有挂(有挂猫腻)进入游戏-大厅左侧-新手福利-激...
黑科技辅助!hhpoker德州... 黑科技辅助!hhpoker德州透视,德扑之星辅助器怎么用,切实真的有挂(有挂猫腻)1、进入游戏-大厅...
最终!pokerworld辅助... 最终!pokerworld辅助器,德普之星私人局辅助器,真是真的有挂(有挂详细)1、游戏颠覆性的策略...
相较于以往!wepoker私人... 相较于以往!wepoker私人局规律,红龙poker辅助,真是是真的有挂(有挂透视)1)红龙poke...