Insert a barcode

Insert a barcode

Forum member · Jun 11, 2007
In an existing merged document page, I add a form field for barcode. How do I add a barcode to that field without adding a new page to the document? Please help. Joseph,

Re: Insert a barcode

Support · Jun 11, 2007
Hello Joseph, You can add a barcode in the place of an existing form field without any problem. You can get the X, Y position of the existing form field by using the GetX and GetY methods of the PdfFormField class. You can add the barcode page element in the same X, Y position. Thanks, ceTe Software Support Team.

Re: Insert a barcode

Forum member · Jun 11, 2007
Thank you for your quick reply. Here is my code: Dim MyDocument As MergeDocument = New MergeDocument(Server.MapPath("benchange2.pdf")) MyDocument.Form.Fields("First Name").Value = tboxFirst.Text ' TextBox field MyDocument.Form.Fields("Last Name").Value = tboxLast.Text ' CheckBox field MyDocument.Form.Fields("formcode").Value = "FORM: BCG" 'MyDocument.Form.Fields("ComboBox1").Value = "Item4" ' ComboBox field Dim barCode As Code39 = New Code39("CODE 39", 50, 50, 48) ' **** (code to add barcode to MyDocument....) MyDocument.Draw(Server.MapPath("benchange_filled.pdf")) Would you please to fill in the line "**** (code to add barcode to MyDocument....)" using VB.NET? Thank you very much, Joseph.

Re: Insert a barcode

Support · Jun 11, 2007
Hello Joseph, Following is the sample VB.NET code: Dim pdf As MergeDocument Dim pdfDoc As PdfDocument Dim pdfFormField As PdfFormField Dim barCode As Code39 = New Code39("CODE 39", 50, 50, 48) pdfDoc = New PdfDocument(Server.MapPath("benchange2.pdf")) pdf = New MergeDocument(pdfDoc) pdfFormField = pdfDoc.Form.Fields("barcodefield") Dim pdfPage As ceTe.DynamicPDF.Page = pdf.Pages(pdfFormField.GetOriginalPageNumber() - 1) pdfPage.Elements.Add(barCode) pdfFormField.PositionPageElement(barCode, pdfPage) MyDocument.Draw(Server.MapPath("benchange_filled.pdf")) Thanks, ceTe Software Support Team