If you want to create a PDF with 300 images you will first have to read all of them in memory. You could use the Q8 instead of the Q16 version of Magick.NET to reduce the memory that is being used.
You cannot write a multipage PDF file by appending to the file. You will have to write the whole file at once:
You cannot write a multipage PDF file by appending to the file. You will have to write the whole file at once:
using (MagickImageCollection collection = new MagickImageCollection()) { string[] jpgs = Directory.GetFiles(@"c:\PDF\", @"*.jpg"); foreach (string jpg in jpgs) { MagickImage img = new MagickImage(jpg); img.Format = MagickFormat.Pdf; collection.Add(img); } collection.Write(@"c:\PDF\out.pdf"); }