1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| PdfDocument document = new PdfDocument();
// Create an empty page
PdfPage page = document.AddPage();
//page.Orientation = PageOrientation.Landscape;
// Get an XGraphics object for drawing
XGraphics gfx = XGraphics.FromPdfPage(page);
//BAR CODE
PdfSharp.Drawing.BarCodes.Code3of9Standard BarCode39 = new PdfSharp.Drawing.BarCodes.Code3of9Standard();
BarCode39.TextLocation = new PdfSharp.Drawing.BarCodes.TextLocation();
BarCode39.Text = "123456789";//value of code to draw on page "123456789"
BarCode39.StartChar = Convert.ToChar("*");
BarCode39.EndChar = Convert.ToChar("*");
BarCode39.Direction = PdfSharp.Drawing.BarCodes.CodeDirection.LeftToRight;
XFont fontBARCODE = new XFont("Arial", 4, XFontStyle.Regular);
XPoint xpoint = new XPoint(90, 40);
XSize BARCODE_SIZE = new XSize(xpoint);
BarCode39.Size = BARCODE_SIZE;
gfx.DrawBarCode(BarCode39, XBrushes.Black, fontBARCODE, new XPoint(460, 160));
document.Save(pathPdf); |
Partager