C# Web Form
The following steps outline creating a web application using DynamicPDF Core Suite.
- Open Visual Studio .NET (2010 - 2022) and create a new C# ASP.NET Web Site.
- On the Solution Explorer, right-click on the Web Application Project and select Add reference....
- Select DynamicPDF for .NET from the list on the .NET tab and click Select followed by OK.
- On the Solution Explorer, right click on the Web Application Project and select Add New Item... from the Add context menu.
- Select Web Form... from the Templates list.
- Name the form
HelloWorld.aspxand click Open. - On the Solution Explorer, right-click on
HelloWorld.aspxand select View Designer. - Select the Source tab to view the HTML of the web form.
- Remove all HTML code from the web form below the
@Pagedirective (leave the@Pagedirective on the web form). - On the Solution Explorer, right click on
HelloWorld.aspxand select View Code. - Remove all
usingdirectives and replace that section with the following code.using System;using ceTe.DynamicPDF;using ceTe.DynamicPDF.PageElements;Imports SystemImports ceTe.DynamicPDFImports ceTe.DynamicPDF.PageElements - Add the following code to the
Page_Loadmethod:Document document = new Document();ceTe.DynamicPDF.Page page = new ceTe.DynamicPDF.Page();page.Elements.Add( new Label( "Hello World!", 0, 0, 100, 12, Font.Helvetica, 12 ) );document.Pages.Add( page );byte[] pdfData = document.Draw();Response.ContentType = "application/pdf";Response.BinaryWrite(pdfData);Dim document As Document = New Document()Dim page As ceTe.DynamicPDF.Page = New ceTe.DynamicPDF.Page()page.Elements.Add(New Label("Hello World!", 0, 0, 100, 12, Font.Helvetica, 12))document.Pages.Add(page)Dim pdfData As Byte() = document.Draw()Response.ContentType = "application/pdf"Response.BinaryWrite(pdfData) - Right-click on the new web form and select Set As Start Page.
- Run the project to view the generated PDF document in your browser.