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

相关内容

热门资讯

第六分钟讲义!wepoker插... 第六分钟讲义!wepoker插件功能辅助器(透视)一直是有辅助辅助(哔哩哔哩)所有人都在同一条线上,...
七分钟举措!pokemmo脚本... 七分钟举措!pokemmo脚本辅助(透视)竟然有辅助脚本(哔哩哔哩)1、这是跨平台的pokemmo脚...
第五分钟绝活!wepoker辅... 第五分钟绝活!wepoker辅助器软件下载(透视)其实是有辅助安装(哔哩哔哩)1、下载好wepoke...
第四分钟阶段!德州透视hhpo... 第四分钟阶段!德州透视hhpoker(透视)真是真的是有辅助下载(哔哩哔哩);1、下载好德州透视hh...
六分钟机巧!hhpoker是真... 六分钟机巧!hhpoker是真的还是假的(透视)竟然是真的有辅助透视(哔哩哔哩)六分钟机巧!hhpo...
第5分钟攻略!wepoker亲... 第5分钟攻略!wepoker亲友圈有用吗(透视)都是是有辅助神器(哔哩哔哩)第5分钟攻略!wepok...
七分钟方式!impoker辅助... 七分钟方式!impoker辅助(透视)竟然是真的有辅助辅助(哔哩哔哩)1.impoker辅助 选牌创...
第6分钟办法!we poker... 第6分钟办法!we poker插件(透视)确实是真的有辅助神器(哔哩哔哩)we poker插件脚本下...
第一分钟办法!wpk控制牌是真... 第一分钟办法!wpk控制牌是真的吗(透视)本来真的有辅助教程(哔哩哔哩)1、进入游戏-大厅左侧-新手...
三分钟方式!wpk辅助插件(透... 您好,wpk辅助插件这款游戏可以开挂的,确实是有挂的,需要了解加去威信【485275054】很多玩家...