The documentation is crafted to assist you to apply the features on your side easily. ByteScout PDF Suite was made to help with hide images in PDF document in C#. ByteScout PDF Suite is the set that includes 6 SDK products to work with PDF from generating rich PDF reports to extracting data from PDF documents and converting them to HTML. This bundle includes PDF (Generator) SDK, PDF Renderer SDK, PDF Extractor SDK, PDF to HTML SDK, PDF Viewer SDK and PDF Generator SDK for Javascript.
C# code snippet like this for ByteScout PDF Suite works best when you need to quickly implement hide images in PDF document in your C# application. If you want to implement this functionality, you should copy and paste code below into your app using code editor. Then compile and run your application. Further improvement of the code will make it more robust.
Visit our website to get a free trial version of ByteScout PDF Suite. Free trial contains many of source code samples to help you with your C# project.
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 PDF Suite Home Page
Explore ByteScout PDF Suite Documentation
Explore Samples
Sign Up for ByteScout PDF Suite Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
60 Day Free Trial or Visit ByteScout PDF Suite Home Page
Explore ByteScout PDF Suite Documentation
Explore Samples
Sign Up for ByteScout PDF Suite Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
also available as: