Home
We need your feedback!

Bytescout.PDF for .NET


Subscribe to Our Bi-Monthly Newsletter (tips, new releases, specials):
 Subscribe in a reader
 PRODUCTS  |  DOWNLOAD  |  PURCHASE  |  SUPPORT  |  TESTIMONIALS   |  NEWS  | 

Bytescout.PDF library for .NET - adding push button control into PDF form document

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

Adding a push button into PDF form

This example demonstrates how to create push button control in PDF form made with Bytescout.PDF library

(See also: how to create PDF form and how to fill PDF form tutorials )

Push button in PDF form document generated with Bytescout.PDF library

Download example source code: bytescoutpdf_push_button.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);

// Set text position
double textX = 500.0f;
double textY = 280.0f;

// Draw Text
drawing.PlaceText(textX, textY, 0, "PushButton");

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

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

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

// Create new push button
PushButtonControl pushButton = new PushButtonControl(page, rect, "PushButton1");

// Set caption
pushButton.Caption = "Push me!";

// Set border width
double borderWidth = 5.0f;

// Set border style
pushButton.SetBorderStyle(Drawing.RGBToColor(0, 0, 0), Drawing.RGBToColor(183, 175, 111), borderWidth);

// Set font size
fontSize = 12;

// Set font
pushButton.SetFont(font, fontSize, Drawing.RGBToColor(0, 0, 0));

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


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

Download example source code: bytescoutpdf_push_button.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:

HOME  |  CONTACT US

Copyright © ByteScout, 2003-2010. Privacy Statement
Microsoft®, Windows®, Windows 2000®, Windows Server®, Windows Vista®, Internet Explorer®, .NET Framework®, ActiveX®, Visual Basic®, Visual C#®, ASP®, ASP.NET®, Excel®, PowerPoint®, are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. Adobe®, Flash® and Acrobat® are registered trademarks of Adobe Systems, Incorporated. Mozilla®, Firefox® and the Mozilla and Firefox Logos are registered trademarks of the Mozilla Foundation. Other product names or brandnames used herein are for identification purposes only and might be trademarks or registered trademarks of their respective companies. We disclaim any and all rights to those marks.