小编Nik*_*o.K的帖子

获取PDF的原始大小

我想要获得与使用 Adob​​e Acrobat 中的将 pdf 导出为 png 相同的图像质量。

但不知怎的,这对我不起作用。如果我借助 Adob​​e Acrobat 工具将 pdf 导出为 png,得到的尺寸为: 宽度:11264 pix 高度:15940 pix

正如您所看到的,我为您提供了阅读 pdf 并在每页创建图像的方法。我的可能性是使用 .Render 方法,它需要int page(index) float dpiX, float dpiY, bool forPrinting

但有些怎么对保存的图像没有影响呢?

using (var document = PdfiumViewer.PdfDocument.Load(file)) 
{
    //This int is used to get the page count for each document 
    int pagecount = document.PageCount;

    //With the int pagecount we can create as may screenshots as there are pages in the document
    for (int index = 0; index < pagecount; …
Run Code Online (Sandbox Code Playgroud)

c# pdf pdfium

4
推荐指数
1
解决办法
3971
查看次数

阅读PDF c#中的所有页面

我想阅读我的PDF的所有页面并将它们保存为图像,到目前为止我所做的只是让我0 = 1首先定义的页面等等.我是否有机会定义范围?

static void Main(string[] args)
{
   try
   {
      string path = @"C:\Users\test\Desktop\pdfToWord\";
      foreach (string file in Directory.EnumerateFiles(path, "*.pdf")) { 
      using (var document = PdfiumViewer.PdfDocument.Load(file))
      {
         int i = 1;
         var image = document.Render(0,300,300, true);
         image.Save(@"C:\Users\test\Desktop\pdfToWord\output.png", ImageFormat.Png);
          }
       }
    }
    catch (Exception ex)
    {
       // handle exception here;
    }
Run Code Online (Sandbox Code Playgroud)

c# pdfium

2
推荐指数
1
解决办法
936
查看次数

标签 统计

c# ×2

pdfium ×2

pdf ×1