【问题标题】:C# Window Form Application: Is there a way to convert pdf into bitmap without using any third party library?C# Window Form Application: 有没有办法在不使用任何第三方库的情况下将 pdf 转换为位图?
【发布时间】:2023-04-01 00:40:02
【问题描述】:

抱歉,这里又问了一个愚蠢的问题。 在窗口窗体应用程序中:有没有一种方法可以在不使用任何第三方库的情况下将 pdf 图像转换为位图?

【问题讨论】:

  • 没有。您可以随时编写自己的转换库。

标签: c# .net pdf-generation


【解决方案1】:

我终于找到了一种方法: (再次回答我自己的问题,希望以后能分享和帮助别人)

static void Main(string[] args)
    {
        // Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it.
        RasterRenderer renderer = new RasterRenderer();
        renderer.RegistrationName = "demo";
        renderer.RegistrationKey = "demo";

        // Load PDF document.
        renderer.LoadDocumentFromFile("multipage.pdf");

        for (int i = 0; i < renderer.GetPageCount(); i++)
        {
            // Render first page of the document to BMP image file.
            renderer.RenderPageToFile(i, RasterOutputFormat.BMP, "image" + i + ".bmp");
        }

        // Open the first output file in default image viewer.
        System.Diagnostics.Process.Start("image0.bmp");
    }

使用 RasterRenderer 和 Bytescout.PDFRenderer 会将 pdf 转换为 bmp 文件。它基本上在做的是“渲染”文件内容中的字节,以便用 PDF 进行分析,将其转换为 bmp。 (归功于:bytescout)

【讨论】:

  • 我找不到 bytescout DLL。您确定此解决方案是否在不使用任何 3rd 方库的情况下完成?
  • @deathrace 您需要该 dll 才能使其工作。我使用的第 3 方库是 RasterRenderer 和 Bytescout.PDFRenderer
猜你喜欢
  • 2022-10-14
  • 2012-11-30
  • 2013-03-17
  • 2014-10-13
  • 2017-11-03
  • 1970-01-01
  • 2019-10-14
  • 1970-01-01
  • 2013-07-09
相关资源
最近更新 更多