ComponentOne PDF for .NET
In This Topic
    Quick Start
    In This Topic

    This quick start guides you through the steps of creating a simple PDF application. You begin by creating a Windows Forms App in Visual Studio, creating an instance of C1PdfDocument class, adding content to it, and saving it as a PDF file.

    The following image showcases the Pdf file generated using the PDF library.

    Set Up the Application

    1. Create a new Windows Forms App (.NET or .NET Framework) and set the project framework to .NET 6.0 for .NET application and .NET 4.5.2 for .NET Framework application using Configure your new project window.
    2. Add reference to the PDF assembly in your application by installing C1.PDF NuGet package ( for .NET app) or adding C1.PDF dll (for .NET Framework app).
    3. Switch to the code view and create a new instance of the C1PdfDocument class through code as demonstrated in the following code.
      C#
      Copy Code
      // Create the C1PdfDocument object.
      C1PdfDocument pdf = new C1PdfDocument();
      

    Add Content to PDF Document

    Define a text format for drawing a string in the specified rectangle with the specified brush and font objects using DrawString method of the C1PdfDocument class.

    C#
    Copy Code
    // Add content to the page.
    RectangleF rect = pdf.PageRectangle;
    rect.Inflate(-72, -72);
    Font font = new Font("Arial", 12);
    pdf.DrawString("Hello World!", font, Brushes.Black, rect);
    

    Save as PDF File

    Now, you can save the document using Save method of the C1PdfDocument class.

    C#
    Copy Code
    // Save the document to a file.
    pdf.Save("Hello_World.pdf");