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

相关内容

热门资讯

透视挂透视!德普之星辅助功能如... 透视挂透视!德普之星辅助功能如何设置,wpk私人局辅助是真的吗,透明教程(一向是真的有挂);一、德普...
透视了解!wpk有脚本吗,aa... 透视了解!wpk有脚本吗,aapoker有脚本吗,来一盘(有挂教程)1、玩家可以在aapoker有脚...
透视有挂!德普之星透视辅助软件... 透视有挂!德普之星透视辅助软件是真的吗,aapoker安装包怎么使用,扑克教程(本然是真的有挂)1、...
透视中牌率!红龙poker有辅... 1、透视中牌率!红龙poker有辅助吗,wepoker透视,一分钟教你(有挂教程);详细教程。2、红...
透视有挂!智星德州有脚本吗,菠... 相信很多朋友都在电脑上玩过智星德州有脚本吗吧,但是很多朋友都在抱怨用电脑玩起来不方便。为此小编给大家...
透视ai代打!wpk透视辅助方... 透视ai代打!wpk透视辅助方法,智星菠萝辅助,新手必备(有挂详情)是一款可以让一直输的玩家,快速成...
透视辅助!德普之星透视辅助,智... WePoker透视辅助工具核心要点解析‌,透视辅助!德普之星透视辅助,智星菠萝可以辅助吗,扑克教程(...
透视智能ai!hhpoker辅... 透视智能ai!hhpoker辅助器,hhpoker免费透视脚本,玩家分享(有挂攻略)(1)透视智能a...
透视工具!德普之星app安卓版... 透视工具!德普之星app安卓版破解版,aapoker透视插件,爆料教程(好像是有挂);亲,其实确实真...
透视透视!wepoker辅助器... 透视透视!wepoker辅助器下载,智星菠萝辅助,技术分享(有挂规律);一、wepoker辅助器下载...