Magick.NET-Q16-AnyCPU 7.0.0.0004
I am trying to persist custom properties from PDF to PNG, but When I open the PNG-->Properties-->Details. I do not see the custom information. I need to persist custom properties stored in PDF file along with custom information in PNG file details.
string guid = Guid.NewGuid().ToString();
I am trying to persist custom properties from PDF to PNG, but When I open the PNG-->Properties-->Details. I do not see the custom information. I need to persist custom properties stored in PDF file along with custom information in PNG file details.
string guid = Guid.NewGuid().ToString();
string folderPath = FOLDERPATH;;
var imageFolderPath = folderPath + guid;
var settings = new MagickReadSettings();
// Settings the density to 300 dpi will create an image with a better quality
settings.Density = new MagickGeometry(300, 300);
using (var images = new MagickImageCollection())
{
FileHelper.CheckAndCreateFolder(imageFolderPath);
// loading bytes from a file
byte[] pdfFileAsbytes = System.IO.File.ReadAllBytes(Path of PDF ));
// Add all the pages of the pdf file to the collection
images.Read(pdfFileAsbytes, settings);
int page = 1;
foreach (MagickImage image in images)
{
imageCollection.Add(
new KeyValuePair<string, string>(
string.Format(imageFolderPath + "\\{0}.png", page),
image.ToBase64()));
// attempt to get the profile(s)...
var updatedIptcProfile = image.GetIptcProfile();
var updatedExifProfile = image.GetExifProfile();
// if the profile(s) are null, create a new one; otherwise use existing profile data...
updatedIptcProfile = (updatedIptcProfile ?? new IptcProfile());
updatedExifProfile = (updatedExifProfile ?? new ExifProfile());
// update the various stuff
updatedIptcProfile.SetValue(IptcTag.Title, " ID ");
updatedIptcProfile.SetValue(IptcTag.Keyword, "Id card");
updatedIptcProfile.SetValue(IptcTag.Caption, "image magick");
updatedIptcProfile.SetValue(IptcTag.CustomField1, "1234567890");
updatedIptcProfile.SetValue(IptcTag., "image magick");
image.AddProfile(updatedIptcProfile);
// Write page to file that contains the page number
image.Write(imageFolderPath + "\\" + page + ".png");
page++;
}
}
Please let me know, how to persist Metadata/Custom attribute information in PNG using your library.