1

I'm trying to render a scaled image using the code:

new PdfToImageConverter
{
    ScaleTo = 2200
}
.GenerateImage(
    "sample.pdf",
    1,
    ImageFormat.Png,
    "sample.pdf.png");

The code renders a good proportional image under Ubuntu, but a squared image under Windows.

The squared window has a white field:

enter image description here

Sample application: https://github.com/sergei-voronkov/Test.NReco.ScaleTo

Also, the generated image is correct if I try to generate it using native poppler utility pdftoppm.exe under Windows:

pdftoppm.exe -png -aa yes -aaVector yes  -f 1 -l 1 -singlefile  -scale-to 2200 sample.pdf sample.pdf

The command line generates a proportional scaled image:

enter image description here

  • Maybe you need to specify "-aa yes -aaVector yes" options to get the same result?.. You can do that with "PdfToImageConverter.CustomArgs" property. – Vitaliy Fedorchenko Jul 13 '22 at 15:48
  • The command line is built by the NReco.PdfRenderer while it calls the pdftoppm. I've just copy it from process explorer during the NReco render process. – Sergey Voronkov Jul 13 '22 at 18:46
  • I've found out important information about the problem. The archive https://github.com/sergei-voronkov/Test.NReco.ScaleTo/raw/master/Test.NReco.ScaleTo/NReco.vs.Origin.zip Contains 2 folders. The PdfRenderer is the folder being created during the NReco rendering. I've put the sample.pdf to the folder and run pdftoppm.exe -png -aa yes -aaVector yes -f 1 -l 1 -singlefile -scale-to 2200 sample.pdf sample.pdf I've got the squared png. The folder poppler contains original poppler binary modules. I've done the same operation within the folder and got correct result. – Sergey Voronkov Jul 13 '22 at 18:56

2 Answers2

0

The behaviour is different because 'pdftoppm' versions are different.

On Windows, NReco.PdfRenderer uses poppler tools binaries that are shipped in the nuget package -- they are extracted on first use and there is no need to deploy them manually. The latest NReco.PdfRenderer includes poppler 21.03 release. In this version "-scale-to" parameter works differently, it always renders to square image; say, if ScaleTo=2000 then output always is 2000x2000. It seems this bug is already known and fixed: https://gitlab.freedesktop.org/poppler/poppler/-/issues/1062. I'll check that, maybe it would be enough to prepare a new NReco.PdfRenderer release with the latest poppler tools binaries for Windows. As a temporary workaround, you may consider to use "Dpi" property to get better resolution for your output images.

On Linux you may choose what poppler tools version to install, and I guess in your case this version is older (like 0.68 or earlier), where "-scale-to" works correctly.

Vitaliy Fedorchenko
  • 8,447
  • 3
  • 37
  • 34
0

The problem has been fixed in the version 1.5.0.