ByteScout PDF SDK - C# - Add Images to PDF - ByteScout

ByteScout PDF SDK – C# – Add Images to PDF

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF SDK – C# – Add Images to PDF

How to add images to PDF in C# using ByteScout PDF SDK

The tutorial shows how to add images to PDF in C#

The sample source codes on this page shows how to add images to PDF in C#. ByteScout PDF SDK is the SDK for pdf documents generation, modification and updates. Can also generate and fill PDF forms. Provides support for text (fonts, style, size, font family), layers, pdf form fields, vector and raster drawings. It can add images to PDF in C#.

The SDK samples like this one below explain how to quickly make your application do add images to PDF in C# with the help of ByteScout PDF SDK. In your C# project or application you may simply copy & paste the code and then run your app! Use of ByteScout PDF SDK in C# is also explained in the documentation included along with the product.

ByteScout PDF SDK free trial version is available on our website. C# and other programming languages are supported.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

Program.cs
      
using System.Diagnostics; using Bytescout.PDF; using Image = Bytescout.PDF.Image; namespace Images { /// <summary> /// This example demonstrates how to add images of various formats. /// </summary> class Program { static void Main() { // Create new document Document pdfDocument = new Document(); pdfDocument.RegistrationName = "demo"; pdfDocument.RegistrationKey = "demo"; // Add page Page page = new Page(PaperFormat.A4); pdfDocument.Pages.Add(page); Canvas canvas = page.Canvas; // Add JPEG image and draw unscaled Image image1 = new Image("Image1.jpg"); canvas.DrawImage(image1, 20, 20); // Add PNG image and draw reduced twice Image image2 = new Image("Image2.png"); canvas.DrawImage(image2, 20, 520, image2.Width / 2, image2.Height / 2); // Add TIFF image and draw scaled disproportionately Image image3 = new Image("Image3.tif"); canvas.DrawImage(image3, 270, 520, image3.Width / 2, image3.Height / 4); // Add GIF image and draw rotated 90 degrees and scaled Image image4 = new Image("Image4.gif"); canvas.TranslateTransform(390, 650); canvas.RotateTransform(90); canvas.DrawImage(image4, 0, 0, image4.Width / 4, image4.Height / 4); // Save document to file pdfDocument.Save("result.pdf"); // Cleanup pdfDocument.Dispose(); // Open result document in default associated application (for demo purpose) ProcessStartInfo processStartInfo = new ProcessStartInfo("result.pdf"); processStartInfo.UseShellExecute = true; Process.Start(processStartInfo); } } }

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF SDK Home Page

Explore ByteScout PDF SDK Documentation

Explore Samples

Sign Up for ByteScout PDF SDK Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF SDK Home Page

Explore ByteScout PDF SDK Documentation

Explore Samples

Sign Up for ByteScout PDF SDK Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next