C# – Create PDF Document and Edit It

PDF (Portable Document Format) is one kind of electronic file format, which can be used on any operation systems. One PDF file can include many contents, such as hyperlink, audio, video and so on.

At present, PDF is widely used to create electronic books or magazines because it can display characters, colors and images as same as original document. Also, font size of some PDF e-books can be adjusted, which can be more convenient for reading.

How to create and edit PDF document? In this post, I will show the basic operation on PDF by using C#, including creating a blank document, adding text and image in it. And I use one component, Spire.PDF to achieve my goal.

At the beginning, I need to add reference in my project, Spire.PDF dll file and system.drawing for setting font color.

Then, let’s go to steps.

  1. Create a blank PDF document and add one page for it.
  2. Write text. The texts give a brief description of the following image which I will insert.
  3. Insert image in PDF and set size for it.
  4. Save and launch file.


using System;

using System.Drawing;

using Spire.Pdf;

using Spire.Pdf.Graphics;

namespace EditPDF


    class Edit


        static void Main(string[] args)


            //Create PDF Document and Add Page

            PdfDocument doc = new PdfDocument();

            PdfPageBase page = doc.Pages.Add();

            //Write Cue Words

            page.Canvas.DrawString(“The following image shows parts of vip cusomters’ information.”,

                                   new PdfFont(PdfFontFamily.TimesRoman, 20f),

                                   new PdfSolidBrush(Color.DarkOrange),

                                   10, 10);

            //Insert Image

            PdfImage image = PdfImage.FromFile(@”D:\work\My Documents\vip.bmp”);

            float width = image.Width * 0.75f;

            float height = image.Height * 0.75f;

            float x = (page.Canvas.ClientSize.Width – width) / 2;

            page.Canvas.DrawImage(image, x, 60, width, height);

            //Save and Launch File









Click Here to learn more about Spire.PDF

Click Here to download Spire.PDF


6 thoughts on “C# – Create PDF Document and Edit It

  1. Awais says:

    good work but can you please guide me tha how i can edit a PDF document by removing signature from that document before uploading it using c#……

    • janewdaisy says:

      In fact, it is difficult to remove signature from a document. I haven’t found a good method to realize this function right now.
      Sorry that I can’t help you.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s