We regularly create and update our sample code library so you may quickly learn hide images in PDF document and the step-by-step process in C#. ByteScout Premium Suite was made to help with hide images in PDF document in C#. ByteScout Premium Suite is the set that includes 12 SDK products from ByteScout including tools and components for PDF, barcodes, spreadsheets, screen video recording.
Want to speed up the application development? Then this C#, code samples for C#, developers help to speed up the application development and writing a code when using ByteScout Premium Suite. Follow the steps-by-step instructions from the scratch to work and copy and paste code for C# into your editor. Further improvement of the code will make it more robust.
If you want to try other samples for C# then free trial version of ByteScout Premium Suite is available on our website.
On-demand (REST Web API) version:
Web API (on-demand version)
On-premise offline SDK for Windows:
60 Day Free Trial (on-premise)
using System.Diagnostics; using System.Drawing; using Bytescout.PDF; using Bytescout.PDFExtractor; using Image = Bytescout.PDF.Image; namespace ConsoleApp1 { class Program { static void Main(string[] args) { string inputPdfDocument = @".\sample.pdf"; string maskingImage = @".\mask.png"; string resultPdfDocument = @".\result.pdf"; // Create Bytescout.PDFExtractor.ImageExtractor instance using (ImageExtractor imageExtractor = new ImageExtractor()) { imageExtractor.RegistrationName = "demo"; imageExtractor.RegistrationKey = "demo"; // Load document imageExtractor.LoadDocumentFromFile(inputPdfDocument); // Create Bytescout.PDF.Document instance using (Document pdfDocument = new Document()) { pdfDocument.RegistrationName = "demo"; pdfDocument.RegistrationKey = "demo"; // Load document pdfDocument.Load(inputPdfDocument); // Load masking image var maskImage = new Image(maskingImage); // Process pages for (int i = 0; i < pdfDocument.Pages.Count; i++) { Page page = pdfDocument.Pages[i]; // Find images on the page if (imageExtractor.GetFirstPageImage(i)) { do { // Get image rectangle var imageRect = imageExtractor.GetCurrentImageRectangle(); // Draw new image other the found image page.Canvas.DrawImage(maskImage, imageRect.Left, imageRect.Top, imageRect.Width, imageRect.Height); } while (imageExtractor.GetNextImage()); } } // Save modified document pdfDocument.Save(resultPdfDocument); } } // Open document in default PDF viewer application (for demonstration). Process.Start(resultPdfDocument); } } }
60 Day Free Trial or Visit ByteScout Premium Suite Home Page
Explore ByteScout Premium Suite Documentation
Explore Samples
Sign Up for ByteScout Premium Suite Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
60 Day Free Trial or Visit ByteScout Premium Suite Home Page
Explore ByteScout Premium Suite Documentation
Explore Samples
Sign Up for ByteScout Premium Suite Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
also available as: