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

相关内容

热门资讯

黑科技安装(aapoker正规... 黑科技安装(aapoker正规)外挂透明挂辅助下载(透视)都是有挂(真的有挂)-哔哩哔哩1、很好的工...
黑科技好友房(约局吧)外挂透明... 黑科技好友房(约局吧)外挂透明挂辅助AI(透视)切实真的有挂(有挂细节)-哔哩哔哩1、黑科技好友房(...
黑科技教程(wepoke模拟器... 黑科技教程(wepoke模拟器)外挂透明挂辅助挂(透明挂黑科技)竟然是真的有挂(有挂辅助)-哔哩哔哩...
黑科技黑科技(Wepoke工具... 黑科技黑科技(Wepoke工具)外挂透明挂辅助设备(ai代打)其实是真的有挂(有挂详细)-哔哩哔哩W...
黑科技黑科技(wpk胜率)外挂... 黑科技黑科技(wpk胜率)外挂透明挂辅助代打(辅助挂)一贯有挂(有挂方针)-哔哩哔哩1、wpk胜率系...
黑科技黑科技(德州之星手游)外... 黑科技黑科技(德州之星手游)外挂透明挂辅助AI(ai代打)确实是有挂(有挂秘籍)-哔哩哔哩1、超多福...
黑科技挂黑科技(德州wpk)外... 黑科技挂黑科技(德州wpk)外挂透明挂辅助神器(智能ai)竟然真的是有挂(有挂讲解)-哔哩哔哩1、金...
黑科技工具(wpk德州ai机器... 黑科技工具(wpk德州ai机器人)外挂透明挂辅助AI(透视)其实有挂(有挂攻略)-哔哩哔哩暗藏猫腻,...
黑科技软件(aapker代理)... 黑科技软件(aapker代理)外挂透明挂辅助挂(智能ai)好像有挂(确实有挂)-哔哩哔哩1、下载好a...
黑科技安卓版(WPK内置)外挂... 黑科技安卓版(WPK内置)外挂透明挂辅助代打(软件透明挂)一直是真的有挂(讲解有挂)-哔哩哔哩1、W...