Hallo liebe Community,
ich habe mir mal wieder ein kleines Tools gebastelt und stehe nun vor einem Problem. Dieses ist folgendes, ich manipuliere ein PDF Dokument mit itextsharp, dass klappt alles super. Für das letzte Eingabefeld müsste ich Zahlen eingeben und diese als Barcode ausgeben. Leider habe ich zu wenig wissen um dies zu realisieren. Vllt. kann mir jemand einen Denkanstoß oder eine Lösung bieten?
Vielen Dank im Voraus
p24
Oberfläche des Programms:
http://panorama24.eu/form1.png
Fertiges erzeugtes PDF des Programms:
http://panorama24.eu/form2.png
Projekt Download:
http://panorama24.eu/LabelGEN.zip
Hier mein Code:
Imports iTextSharp.text.pdf
Imports iTextSharp.text
Imports System.IO
Public Class Form1
Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Label2.Click
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles btnclose.Click
Me.Close()
End Sub
Private Sub btngen_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles btngen.Click
Dim oldFile As String = "templates/template.pdf"
Dim newFile As String = "output/etikett.pdf"
Dim reader As New PdfReader(oldFile)
Dim size As Rectangle = reader.GetPageSizeWithRotation(1)
Dim document As New Document(size)
Dim fs As New FileStream(newFile, FileMode.Create, FileAccess.Write)
Dim writer As PdfWriter = PdfWriter.GetInstance(document, fs)
document.Open()
Dim cb As PdfContentByte = writer.DirectContent
Dim bf As BaseFont = BaseFont.CreateFont(BaseFont.HELVETICA, _
BaseFont.CP1252, BaseFont.NOT_EMBEDDED)
cb.SetColorFill(BaseColor.BLACK)
cb.SetFontAndSize(bf, 16)
cb.BeginText()
Dim platz As String = txtplatz.Text
Dim name As String = txtname.Text
Dim nr As String = txtnr.Text
Dim code As String = txtcode.Text
cb.ShowTextAligned(1, platz, 240, 204, 0)
cb.ShowTextAligned(1, name, 240, 145, 0)
cb.ShowTextAligned(1, nr, 240, 125, 0)
cb.ShowTextAligned(1, code, 240, 140, 0)
cb.EndText()
Dim page As PdfImportedPage = writer.GetImportedPage(reader, 1)
cb.AddTemplate(page, 0, 0)
document.Close()
fs.Close()
writer.Close()
reader.Close()
MsgBox("Label erfolgreich gespeichert.", MsgBoxStyle.Information, _
Title:="Information")
End Sub
Private Sub btnprint_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles btnprint.Click
Dim path = System.IO.Path.Combine(Application.StartupPath, _
"output/etikett.pdf")
Process.Start(path)
End Sub
End Class
Beitrag wurde zuletzt am 22.06.17 um 12:45:11 editiert. |