I am trying to convert pdf to tiff(Each page will be an image file). I couldn't find any examples doing this using the library.
Here is what I have so far.
string inputPdf = @"C:\Users\Desktop\pdfconverttes\name.pdf";
string outputPng = @"C:\Users\Desktop\pdfconverttes\name.tif";
using (MagickImage images = new MagickImage())
{
images.Read(inputPdf);
using (MagickImage vertical = images.AppendVertically())
{
vertical.Format = MagickFormat.Tiff;
vertical.Density = new Density(300);
vertical.Write(outputPng);
}
}
This image creates one image that has all pdf pages in it.
What I have tried:
What I tried to create multiple images:
using ImageMagick;
MagickReadSettings settings = new MagickReadSettings();
settings.Density = new Density(300);
using (MagickImageCollection images = new MagickImageCollection())
{
images.Read(@"C:\Users\Desktop\pdfconverttes\name.pdf", settings);
int page = 1;
foreach (MagickImage image in images)
{
image.Write(@"C: \Users\Desktop\pdfconverttes\name.png" + page + ".png");
image.Format = MagickFormat.Ptif;
image.Write(@"C: \Users\Desktop\pdfconverttes\name.tif" + page + ".tif");
page++;
}
}
Unhandled Exception: ImageMagick.MagickCoderErrorException: WriteBlob Failed
This is using ImageMagick.
Side Question: Is there a way to avoid purchasing GhostScript to use ImageMagick