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

相关内容

热门资讯

盘点一款!闲逸游戏辅助软件下载... 盘点一款!闲逸游戏辅助软件下载,博雅棋牌辅助器,详细方法(有挂秘诀)1、下载好闲逸游戏辅助软件下载正...
一直以来!agpoker辅助,... 一直以来!agpoker辅助,德普之星辅助工具如何设置,一直是有挂(有挂神器)1.德普之星辅助工具如...
玩家科普!wepoker辅助,... 玩家科普!wepoker辅助,宝宝游戏辅助,详细脚本(有挂功能)宝宝游戏辅助透视方法中分为三种模型:...
2026版教程!wpk作弊是真... 2026版教程!wpk作弊是真的吗,智星德州辅助译码插件靠谱吗,原来真的是有挂(有挂详情)智星德州辅...
必看攻略!川南休闲辅助,微信老... 必看攻略!川南休闲辅助,微信老友广东辅助,详细器(详细教程)微信老友广东辅助破解侠是真的助透视。每个...
今天下午!wepoker免费透... 今天下午!wepoker免费透视脚本,德普之星透视辅助软件是真的吗,真是是真的有挂(今日头条)德普之...
实测教程!微信小程序外辅助工具... 实测教程!微信小程序外辅助工具,网易亲友圈辅助,详细工具(有挂功能)1、这是跨平台的微信小程序外辅助...
现场直击!wepoker辅助器... 现场直击!wepoker辅助器如何使用,德扑之星透视,好像是真的有挂(有挂辅助)1、打开软件启动之后...
玩家必看科普!微乐小程序免费黑... 玩家必看科普!微乐小程序免费黑科技下载,欢乐茶馆挂,详细软件(了解有挂)小薇(辅助器软件下载)致您一...
据文件显示!wepoker透视... 据文件显示!wepoker透视app下载,德扑之星私人局透视,竟然真的有挂(有挂助手)1、点击下载安...