This project has moved. For the latest updates, please go here.

The size of image is weird after convert a pdf to image.

Sep 13, 2016 at 8:44 PM
Edited Sep 13, 2016 at 8:46 PM
The size of image is weird after convert a pdf to image. The pdf image not fill in whole canvas , be put to a corner.
If I change to another pdf file, everything is okay. Is it because of the setting or special pdf format?

I am using the latest version of Magick.NET-Q8-AnyCPU.dll.

Thanks.
Coordinator
Sep 14, 2016 at 11:36 AM
Edited Sep 14, 2016 at 11:36 AM
Can you share your PDF file so I can try to reproduce this issue?
Sep 14, 2016 at 1:29 PM
Thank you for help. I wanted to extract only one page from this PDF.

https://www.dropbox.com/s/dhy9gzvddtl6keu/3P207257-2D.pdf?dl=0
Coordinator
Sep 18, 2016 at 8:16 AM
It appears that your PDF file has a CropBox. You can enable the use of this with Magick.NET but I don't know what this will do with your other images. You will need to test that yourself. Below is the code that can be used to enable the CropBox and read a single page:
MagickReadSettings settings = new MagickReadSettings()
{
  Density = new Density(300), // Setting this value will get you an image with a higher quality 
  FrameIndex = 4, // Specifies the page you want to view (starts at zero)
  Defines = new PdfReadDefines()
  {
    UseCropBox = true // Enables the use of the CropBox.
  }
};

using (MagickImage image = new MagickImage("3P207257-2D.pdf", settings))
{
  image.Write("page.png");
}
Sep 20, 2016 at 2:19 PM
It works. Thank you. Another question, How can I overwrite the exists image?
Coordinator
Sep 20, 2016 at 5:27 PM
I don't understand what you are asking. Do you want to save it as a PDF again?