<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>create PDF document using Itextsharp.dll</Title>
      <Shortcut>createPDFdocumentusingItextsharp.dll</Shortcut>
      <Description>create PDF document using Itextsharp.dll [VB.NET]</Description>
      <Author>do hoang hai</Author>
      <HelpUrl>/PreviewSnippet.aspx?SnippetID=f0dc2ade-cf5f-4a38-989d-b7acef5c79f8</HelpUrl>
      <SnippetTypes>
        <SnippetType>SurroundsWith</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Code Language="VB"><![CDATA[ ''' <summary>
    ''' create a pdf document using ItextSharp library
    ''' </summary>
    ''' <param name="strFilePath">path to the location of new file, include file name</param>
    ''' <remarks>download itextSharp.dll at http://sourceforge.net/projects/itextsharp/</remarks>
    Public Shared Sub makePDFDocument(ByVal strFilePath As String)
        'if there are more than 9 columns for displaying result, we should use A4 landscape size to present
        Dim document As Document = New Document
        'or for LandScape size: New Document(PageSize.A4.Rotate())
        Try
            'create a pdf file
            PdfWriter.GetInstance(document, New FileStream(strFilePath, FileMode.Create))
            document.Open()
            'add a paragraph
            Dim pr As New Paragraph("Sample paragraph: To make a graph, you first create a graph with text, font, fontsize,FontStype, FontForeColor", New Font(text.Font.TIMES_ROMAN, 13, text.Font.BOLD, text.Color.DARK_GRAY))
            pr.Alignment = Element.ALIGN_CENTER
            document.Add(pr)
           
            'add an image
            Dim imgUrl As String = "http://www.google.com.sg/images/nav_logo3.png"
            Dim img As New iTextSharp.text.Jpeg(imgUrl)
            img.Alignment = Element.ALIGN_CENTER
            document.Add(img)
            'you can also add table to the page, see ItextSharp library,..
        Catch ex As Exception
        Finally
            document.Close()
        End Try
    End Sub]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>