Can ImageMagick edit PDF
Can ImageMagick or GraphicsMagick edit pdf using c#. I want to recieve a pdf file and add water mark to it. Is there any other liberires that are free and does that. is there code sample. Thank you.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Leon DRank #851 · 2.6K reputationPosted Feb 4, 2020, 2:22 PM EST
Sarmad Yousif108 reputationPosted Feb 5, 2020, 9:15 AM EST
@Leon D I don't think this is free. Thank you
Marvin ReidRank #1,963 · 746 reputationPosted Nov 9, 2022, 10:45 AM EST
You can add a watermark to a PDF using the AnnBatesStamp class. Here is some code and documentation that demonstrates this.
static void AddWatermarktoFile() { string _sourceFile = @"C:\LEADTOOLS22\Resources\Images\input.pdf"; //Create AnnBatesStampComposer instance and add the created Bates stamp to it using (AnnBatesStampComposer batesStampComposer = new AnnBatesStampComposer()) { //Set the rendering engine AnnBatesStampComposer.RenderingEngine = new AnnWinFormsRenderingEngine(); //Create Bates stamp container, set its size and mapper and attach it to the composer AnnContainer batesStampContainer = new AnnContainer(); //Create AnnBatesStamp and set its properties AnnBatesStamp batesStamp = new AnnBatesStamp(); batesStamp.Font = new AnnFont("Arial", 12); batesStamp.Foreground = AnnSolidColorBrush.Create("Red"); batesStamp.HorizontalAlignment = AnnHorizontalAlignment.Center; batesStamp.VerticalAlignment = AnnVerticalAlignment.Center; batesStamp.Logo.Angle = 45; batesStamp.Logo.Font = new AnnFont("Arial", 32); batesStamp.Logo.Opacity = 0.25; batesStamp.Logo.StretchLogo = true; batesStamp.Logo.Text = "Watermark"; using (RasterCodecs _codecs = new RasterCodecs()) { using (CodecsImageInfo info = _codecs.GetInformation(_sourceFile, true)) { batesStampContainer.Mapper.MapResolutions(info.XResolution, info.YResolution, info.XResolution, info.YResolution); batesStampContainer.Size = batesStampContainer.Mapper.SizeToContainerCoordinates(LeadSizeD.Create(info.Width, info.Height)); batesStampComposer.Stamps.Add(batesStamp); //Apply Bates Stamp to our container batesStampComposer.TargetContainers.Add(batesStampContainer); int pages = _codecs.GetTotalPages(_sourceFile); for (int i = 1; i <= pages; i++) { using (RasterImage _image = _codecs.Load(_sourceFile, 24, CodecsLoadByteOrder.BgrOrGray, i, i)) { AnnBatesStampComposer.RenderingEngine.RenderOnImage(batesStampContainer, _image); _codecs.Save(_image, @"C:\LEADTOOLS22\Resources\Images\watermarkedImage.pdf", RasterImageFormat.RasPdf, _image.BitsPerPixel, 1,-1,1,CodecsSavePageMode.Append); } } } } } }https://www.leadtools.com/help/sdk/dh/abs/annbatesstamp.html
https://www.leadtools.com/help/sdk/tutorials/dotnet-console-add-watermark-to-multipage-file.html