I am converting a png image to pdf using ImageMagic library(Nuget package Magick.NET-Q16-AnyCPU)
It converts okay and saves the pdf to the destination without any error.
Below is the code which Converts/resize the image to pdf which is working okay.
public static string ConvertToPdfAndSave(byte[] fileContent)
{
var targetFile = "test.pdf";
using (MagickImage mImage = new MagickImage(fileContent))
{
mImage.Quality = 90;
mImage.Density = new Density(90);
mImage.Resize(1200, 0);
mImage.Write(targetFile);
}
return targetFile;
}
I have to do this thing with multiple images and then I have to read those pdfs using ImageMagick to merge all of them into single PDF. I have installed GhostScript(Initially I had 32 BIT version, now have both 32 and 62 BIT versions of dll) on my system.
When I try to read any converted pdf using ImageMagick, it throws below exception:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt
Code to read the file:
using (MagickImage mImage = new MagickImage(targetFile))
{
}
Here strange thing that, this code works well if I read any other original files from system. It just dont read converted files. It thows exception in constructor.
I am on 64Bit Windows 10 machine.
Any help would be appreciated.