Create a PDF document with a barcode

  • Reference KB000076
  • Type Code sample
  • Product -
  • Categories Generate PDF, Shapes
  • Created 8/19/2010

This code sample demonstrates how to create a PDF document with a barcode.

Create a PDF document with a barcode

This code sample demonstrates how to create a PDF document with a barcode.


using System;
using System.IO;
using System.Text;

using TallComponents.PDF;
using TallComponents.PDF.Shapes;
using TallComponents.PDF.Transforms;
using TallComponents.PDF.Shapes.Barcodes;

namespace TallComponents.BarcodeTest
{
  class Test 
  {
    private const string data = "2147483648";

    [STAThread]
    public static void Main()
    {
      Document doc = new Document();
      Page page = new Page( PageSize.Letter );
      doc.Pages.Add( page );

      Code3of9BarcodeShape shape = new Code3of9BarcodeShape();
        
      page.VisualOverlay.Add( shape );

      shape.Location = TextLocation.BelowEmbedded;
      shape.Transform = new TranslateTransform(50, 600);
      shape.Width = 200;
      shape.Height = 50;
      shape.Data = data;

      using (FileStream stream = new FileStream(  
        "out.pdf", FileMode.Create, FileAccess.Write ))
      {
        doc.Write( stream );
      }
    }
  }
}
 1 using System;
 2 using System.IO;
 3 using System.Text;
 4 
 5 using TallComponents.PDF;
 6 using TallComponents.PDF.Shapes;
 7 using TallComponents.PDF.Transforms;
 8 using TallComponents.PDF.Shapes.Barcodes;
 9 
10 namespace TallComponents.BarcodeTest
11 {
12   class Test 
13   {
14     private const string data = "2147483648";
15 
16     [STAThread]
17     public static void Main()
18     {
19       Document doc = new Document();
20       Page page = new Page( PageSize.Letter );
21       doc.Pages.Add( page );
22 
23       Code3of9BarcodeShape shape = new Code3of9BarcodeShape();
24         
25       page.VisualOverlay.Add( shape );
26 
27       shape.Location = TextLocation.BelowEmbedded;
28       shape.Transform = new TranslateTransform(50, 600);
29       shape.Width = 200;
30       shape.Height = 50;
31       shape.Data = data;
32 
33       using (FileStream stream = new FileStream(  
34         "out.pdf", FileMode.Create, FileAccess.Write ))
35       {
36         doc.Write( stream );
37       }
38     }
39   }
40 }