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

相关内容

热门资讯

黑科技中牌率!来玩app德州扑... 黑科技中牌率!来玩app德州扑克(wepokeai代打)总是真的是有挂(有挂实锤)-哔哩哔哩;小薇(...
黑科技安装!governoro... 黑科技安装!governorofpoker3有挂(微扑克如何让系统发好牌)真是有挂(有挂秘籍)-哔哩...
黑科技智能ai!wepoke有... 黑科技智能ai!wepoke有app软件(aapoker发牌机制)一贯存在有挂(有挂解惑)-哔哩哔哩...
黑科技美元局!德扑之星系统发牌... 黑科技美元局!德扑之星系统发牌机制(微扑克ai机器人)起初是真的有挂(有挂方法)-哔哩哔哩微扑克ai...
黑科技挂!fishpoker大... 黑科技挂!fishpoker大菠萝外挂(德扑ai智能机器人线上代打)先前是真的有挂(有挂助手)-哔哩...
黑科技脚本!pokerworl... 黑科技脚本!pokerworld软件(德扑ai软件靠谱吗)切实是真的有挂(有挂透视)-哔哩哔哩1、打...
黑科技有挂!aapoker有外... 黑科技有挂!aapoker有外挂(wpk到底有没有外挂)固有真的有挂(真实有挂)-哔哩哔哩,您好,w...
黑科技好友!微扑克如何让系统发... 您好,微扑克如何让系统发好牌这款游戏可以开挂的,确实是有挂的,需要了解加威信【136704302】很...
黑科技ai!德扑之星辅助工具(... 黑科技ai!德扑之星辅助工具(微扑克有挂么)从来是有挂(发现有挂)-哔哩哔哩1、微扑克有挂么ai辅助...
黑科技美元局!轰趴大菠萝十三水... 黑科技美元局!轰趴大菠萝十三水有外挂(德扑ai智能系统)总是是真的有挂(果真有挂)-哔哩哔哩1、德扑...