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

相关内容

热门资讯

玩家必备攻略!hhpoker到... 玩家必备攻略!hhpoker到底可以作弊码(辅助挂)其实存在有挂(确实有挂辅助app)1、进入游戏-...
六分钟了解!wepoker安装... 六分钟了解!wepoker安装教程(辅助挂)竟然有挂(有挂规律辅助脚本)1、透视辅助软件激活码多个强...
一分钟了解!pokerworl... 一分钟了解!pokerworld修改器(辅助挂)好像是真的有挂(有挂功能辅助技巧)1、实时透视辅助更...
带你了解!hhpoker买挂(... 带你了解!hhpoker买挂(辅助挂)切实是有挂(详细教程辅助脚本)在进入软件靠谱后,参与本局比赛的...
我来向大家传授!wepoker... 我来向大家传授!wepoker俱乐部辅助(辅助挂)总是是有挂(有挂教程辅助脚本)1、脚本辅助下载、免...
免费测试版!约局吧德州真的存在... 免费测试版!约局吧德州真的存在透视吗(辅助挂)原来存在有挂(有挂详细辅助软件)1、用户打开应用后不用...
玩家必看教程!wpk俱乐部有没... 玩家必看教程!wpk俱乐部有没有辅助(辅助挂)总是是有挂(有挂总结辅助器)1、点击下载安装,脚本分类...
揭秘真相!wepoker辅助是... 揭秘真相!wepoker辅助是真的假的(辅助挂)一直存在有挂(有挂神器辅助攻略)1、在插件功能辅助器...
记者揭秘!xpoker辅助控制... 记者揭秘!xpoker辅助控制(辅助挂)确实是真的有挂(有挂实锤辅助器)1、记者揭秘!xpoker辅...
教学盘点!德普之星透视辅助软件... 教学盘点!德普之星透视辅助软件(辅助挂)一贯真的有挂(有挂猫腻辅助技巧)1)辅助插件:进一步探索辅助...