Visual Basic .NET Web Form

The following steps describe how to create and use .NET Web Forms with DynamicPDF Core Suite.

  1. Open Visual Studio .NET (2010 - 2019) and create a new Visual Basic ASP.NET Web Site.
  2. On the Solution Explorer, right-click Web Application Project and select Add reference.
  3. Select DynamicPDF for .NET from the displayed list and click Select then OK.
  4. On the Solution Explorer, right-click the Web Application Project and select Add --> Add New Item.
  5. Select Web Form from the Templates list.
  6. Name the form HelloWorld.aspx and select Open".
  7. On the Solution Explorer, right-click HelloWorld.aspx and select View Designer.
  8. Select the Source tab to view the web form HTML.
  9. Remove all HTML on the web form below the Page directive (leave the Page directive on the web form).
  10. On the Solution Explorer, right-click on HelloWorld.aspx and select View Code.
  11. Add the following Imports directives to the top of the file:
    using ceTe.DynamicPDF;
    using ceTe.DynamicPDF.PageElements;
    
    Imports ceTe.DynamicPDF
    Imports ceTe.DynamicPDF.PageElements
    
  12. Add the following code to the Page_Load method:
    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 MyDocument As Document = New Document()
    Dim MyPage As ceTe.DynamicPDF.Page = New ceTe.DynamicPDF.Page()
    MyPage.Elements.Add(New Label("Hello World!", 0, 0, 100, 12, Font.Helvetica, 12))
    MyDocument.Pages.Add(MyPage)
    Dim pdfData As Byte() = MyDocument.Draw()
    
    Response.ContentType = "application/pdf"
    Response.BinaryWrite(pdfData)
    
  13. Right click on the new web form and select et As Start Page.
  14. Run the project to view the generated PDF document in your browser.

In this topic