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

相关内容

热门资讯

2026版方法!werplan... 2026版方法!werplan有挂吗,德扑之星辅助器怎么用,切实是有挂(有挂攻略)1、德扑之星辅助器...
近日!哈糖大菠萝可以开挂吗,智... 近日!哈糖大菠萝可以开挂吗,智星菠萝辅助,都是真的是有挂(有挂透视)1、全新机制【智星菠萝辅助ai辅...
最强版aapoker万能辅助器... 最强版aapoker万能辅助器,扑克之星辅助,切实有挂(真是有挂)1、让任何用户在无需安装教程第三方...
黑科技辅助挂!hhpoker俱... 黑科技辅助挂!hhpoker俱乐部是干嘛的,德普之星怎么设置埋牌,总是确实有挂(有挂详情)德普之星怎...
最强版hh poker辅助器先... 最强版hh poker辅助器先试用,破解辅助插件wepoker,果然真的是有挂(有挂详情);1、下载...
最强版wpk模拟器多开,wep... 最强版wpk模拟器多开,wepoker透视苹果系统,总是是真的有挂(有挂助手)最强版wpk模拟器多开...
此事引发网友热议!wepoke... 此事引发网友热议!wepoker开辅助能查到吗,德扑圈有透视吗,切实是真的有挂(真的有挂)运德扑圈有...
最强版德普之星透视辅助插件,w... 最强版德普之星透视辅助插件,werplan免费挂下载,切实真的有挂(有挂分享)1)辅助插件:进一步探...
经核实!德州局怎么透视,智星菠... 经核实!德州局怎么透视,智星菠萝有挂吗,原来是真的有挂(有挂分析)1、实时智星菠萝有挂吗透视辅助更新...
最强版steampokerma... 最强版steampokermaster辅助,hhpoker透视脚本,切实是有挂(竟然有挂)1、这是跨...