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

相关内容

热门资讯

透视计算"wepok... 透视计算"wepoker代打辅助"详细辅助玩家教程(智能辅助插件辅助);致您一封信;亲爱wepoke...
透视系统"拱趴大菠萝... 透视系统"拱趴大菠萝有什么挂"详细辅助2025教程(私人局俱乐部技巧)是一款可以让一直输的玩家,快速...
透视总结"xpoke... 透视总结"xpoker辅助助手"详细辅助线上教程(私人局开挂视频技巧)是一款可以让一直输的玩家,快速...
透视系统"wepok... 透视系统"wepoker私局辅助"详细辅助存在挂教程(透视脚本免费方法);支持多人共享记分板与复盘,...
透视玄学"黑侠破解w... 1、透视玄学"黑侠破解wepoker"详细辅助可靠教程(有辅助插件技巧)。2、黑侠破解wepoker...
透视游戏"aapok... 透视游戏"aapoker辅助插件工具"详细辅助新2025版(黑侠辅助器辅助);科技安装教程;1367...
透视实锤"淘宝买we... 透视实锤"淘宝买wepoker透视有用吗"详细辅助解说技巧(线上大神技巧);致您一封信;亲爱淘宝买w...
透视游戏"wepok... 透视游戏"wepoker软件靠谱么"详细辅助线上教程(辅助器安装包透视);支持多人共享记分板与复盘,...
透视苹果版"拱趴大菠... 透视苹果版"拱趴大菠萝十三水作弊"详细辅助德州教程(透视最简单三个步骤软件);支持2-10人实时对战...
透视数据"hhpok... 透视数据"hhpoker外挂靠谱吗"详细辅助专业教程(辅助器可以弄透视);支持2-10人实时对战,虚...