不显示文件保存对话框,将“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... 一款 AI 游戏攻略黑科技工具上线,查攻略效率直接开挂。它整合版本更新、装备搭配、BOSS 打法、牌...
重大通报!!we poker辅... we poker辅助器v3.3AI 游戏攻略黑科技上线本地缓存功能,离线查阅能力开挂。提前下载对应游...
查到实测辅助!破解辅助插件we... 您好,查到实测辅助!破解辅助插件wepoker,德普之星软件下载教程(起初是有辅助)这款游戏可以开挂...
一分钟了解!德普辅助app,w... 『标题:当前标题』主打赛后复盘的 AI 游戏攻略黑科技走红,对局总结能力开挂。上传对局回放或者战绩截...
总算清楚!htx矩阵wepok... 您好,总算清楚!htx矩阵wepoker辅助,微扑克能不能开挂助手(本然存在有透视挂)这款游戏可以开...
大家学习交流!wepoker开... 您好,大家学习交流!wepoker开脚本视频,德普之星怎么开挂助手(一贯真的是有辅助挂)这款游戏可以...
今日重大通报!wepoker模... 您好:wepoker模拟器哪个这款游戏可以开挂的,确实是有挂的,很多玩家在这款游戏中打牌都会发现很多...
每日必看教程!wepoker有... 『标题:当前标题』主打赛后复盘的 AI 游戏攻略黑科技走红,对局总结能力开挂。上传对局回放或者战绩截...
推荐一款!wpk是真的还是假的... AI 黑科技赛道又上新,这款智能处理工具堪称效率开挂,专门面向短视频创作者打造。它打通脚本撰写、AI...
一分钟揭秘!!wepoker怎... 一分钟揭秘!!wepoker怎么看牌型,WPK可以开挂吗安装(一贯是有开挂)AI 是一款可以让一直输...