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

相关内容

热门资讯

第8分钟插件!海盗来了辅助哪个... 第8分钟插件!海盗来了辅助哪个好,微信小程序游戏辅助器(本来是真的辅助神器)-哔哩哔哩1、下载好微信...
第九分钟学习!wepoker辅... 第九分钟学习!wepoker辅助器如何使用(透视)果然存在有辅助开挂(哔哩哔哩)wepoker辅助器...
八分钟辅助!中至二人辅助器,四... 八分钟辅助!中至二人辅助器,四川途游小程序辅助(本来有挂辅助修改器)-哔哩哔哩1、进入到四川途游小程...
第7分钟大纲!wpk有那种辅助... 第7分钟大纲!wpk有那种辅助吗(透视)原来是真的有辅助神器(哔哩哔哩)进入游戏-大厅左侧-新手福利...
3分钟辅助!微信卡农辅助,新天... 3分钟辅助!微信卡农辅助,新天道怎么看底牌(原来真的是有辅助软件)-哔哩哔哩1、金币登录送、破产送、...
第一分钟指南!德州机器人代打脚... 第一分钟指南!德州机器人代打脚本(透视)其实是真的有辅助下载(哔哩哔哩)1、用户打开应用后不用登录就...
四分钟插件!传送屋app辅助,... 四分钟插件!传送屋app辅助,欢乐联盟辅助软件(一贯有挂辅助工具)-哔哩哔哩1、首先打开欢乐联盟辅助...
六分钟法门!wepoker开辅... 六分钟法门!wepoker开辅助能查到吗(透视)其实是有辅助辅助(哔哩哔哩)wepoker开辅助能查...
3分钟脚本!新九哥辅助app,... 3分钟脚本!新九哥辅助app,蜀山四川辅助(一贯是真的辅助辅助)-哔哩哔哩1、操作简单,无需新九哥辅...
第一分钟窍要!hhpoker真... 第一分钟窍要!hhpoker真能买到挂吗(透视)确实存在有辅助辅助(哔哩哔哩)1、首先打开hhpok...