不显示文件保存对话框,将“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辅助器下载,微信小程序可以开挂吗,开挂透视(有人有挂)-哔哩哔哩小薇(辅助器...
透视了解!hhpoker是真的... 透视了解!hhpoker是真的吗,hhpoker辅助靠谱吗(透视)确实是真的app(哔哩哔哩)1、全...
透视指南!hhpoker的辅助... 透视指南!hhpoker的辅助是真的吗,HHpoker脚本其实存在有安装,第8分钟教程(有挂详情)1...
透视规律!wpk透视是真的吗,... 透视规律!wpk透视是真的吗,微乐自建房辅助工具免费,有挂透视(今日头条)-哔哩哔哩1.wpk透视是...
透视辅助!如何判断wpk辅助软... 透视辅助!如何判断wpk辅助软件的真假,wpk透视插件(透视)本来是有挂(哔哩哔哩)透视方法中分为三...
透视积累!pokemmo脚本辅... 透视积累!pokemmo脚本辅助下载,WPK方法本来是有安装,6分钟教程(有挂方针)透视积累!pok...
透视实锤!约局吧德州可以透视吗... 透视实锤!约局吧德州可以透视吗,微信自建房辅助多少钱一个月,专业透视(有挂技巧)-哔哩哔哩1)约局吧...
透视要领!hhpoker德州作... 透视要领!hhpoker德州作必弊,HHpoker下载一贯存在有开挂,九分钟教程(详细教程)1、下载...
脚本科普!wpk透视辅助,wp... 脚本科普!wpk透视辅助,wpk系统是否存在作必弊行为(透视)一贯是有器(哔哩哔哩)1、下载好正确养...
透视黑科技!xpoker辅助神... 透视黑科技!xpoker辅助神器,微乐智能辅助真的假的,辅助透视(有挂详情)-哔哩哔哩xpoker辅...