Home

Bytescout.PDF for .NET



Bytescout.PDF library for .NET - creating fillable PDF form

Download Free Trial Buy Now More Information
For HTML2PDF and XML2PDF solution check our PDFDoc Scout ActiveX library instead

How to create a fillable PDF form document using PDF document

This example demonstrates how to create PDF form with edit and checkbox control using Bytescout.PDF library
(check this sample to see how to fill such PDF form)

fillable PDF form generated with Bytescout.PDF

Download example source code: bytescoutpdf_create_pdf_form.zip (10 KB)

using System;
using System.Collections.Generic;
using System.Text;
using Bytescout.PDF;
using System.Diagnostics;

namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
// Create main PDF Doc Engine
PDFDocEngine engine = new PDFDocEngine("", "");

// Add new document
Document document = engine.AddDocument();

// Append new page to the document
Page page = document.AddPage(PageSizeType.A3, PageOrientationType.LandScape);

// Create new drawing
Drawing drawing = page.AddDrawing();

// Add standard font
uint font = document.AddFontStandard(StandardFontType.TimesRoman, FontEncodingType.WinAnsi);

// Set font size
double fontSize = 30;

// Set Active Font
drawing.SetActiveFont(font, fontSize, false, false);

// Draw Text
drawing.PlaceText(500.0f, 280.0f, 0, "Married");
drawing.PlaceText(350.0f, 280.0f, 0, "Surname");
drawing.PlaceText(200.0f, 280.0f, 0, "Name");

// Set font size
fontSize = 15;

// Set Active Font
drawing.SetActiveFont(font, fontSize, false, false);

// Create new bounding rectangle
Rectangle rect = new Rectangle();

// Set position and size
rect.Left = 500;
rect.Bottom = 500;
rect.Top = 520;
rect.Right = 530;

// Create new check box
AcroCheckBox checkBox1 = new AcroCheckBox(page, rect, "Married", true);

// Set position and size
rect.Left = 350;
rect.Bottom = 500;
rect.Top = 520;
rect.Right = 450;

// Create new text box
EditBoxControl editBoxSurname = new EditBoxControl(page, rect, "editBoxSurname");

// Set position and size
rect.Left = 200;
rect.Bottom = 500;
rect.Top = 520;
rect.Right = 300;

// Create new text box
EditBoxControl editBoxName = new EditBoxControl(page, rect, "editBoxName");

// Set caption
checkBox1.Caption = "Married";

// Set style
checkBox1.SetCheckboxStyle(CheckBoxMarkStyleType.Vmark, CheckBoxStyleType.CircleBox);

// Closing drawing on the page
drawing.Close();

// Save document
document.Save("CreateForm.pdf");

// open generated PDF document in default PDF viewer installed in Windows
Process.Start("CreateForm.pdf");
}
}
}

Download example source code: bytescoutpdf_create_pdf_form.zip (10 KB)

Download Free Trial Buy Now More Information
For HTML2PDF and XML2PDF solution check our PDFDoc Scout ActiveX library instead

"Hello, World!" quick start step-by-step tutorials:

Advanced Examples:
Products  |  Download  |  Purchase  |  Support  |  Contacts  |  Testimonials  |  News |  

ByteScout, 2003-2008. All other company and product names may be trademarks of their respective companies. Privacy Statement