85 messaggi dal 04 settembre 2010
Buonasera,
nel codice che vi posto genero il barcode degli articoli di magazzino, ho la necessita di aggiungere informazioni al file PDF e alcuni testi sono lunghi e vorrei che il contenuto delle textbox se superano la grandezza del foglio portino a capo il testo.
Non riesco a trovare la soluzione chiedo un piccolo aiuto grazie.

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks
Imports System.Windows.Forms
Imports iTextSharp.text
Imports iTextSharp.text.pdf
Imports System.IO
  
    Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim doc As Document = New Document(New iTextSharp.text.Rectangle(24, 12), 5, 5, 1, 1)
        Try 
            Dim writer As PdfWriter = PdfWriter.GetInstance(doc, New FileStream((Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/codes.pdf"), FileMode.Create))
            doc.Open
            Dim dt As DataTable = New DataTable
            dt.Columns.Add("ID")
            dt.Columns.Add("Price")
            Dim i As Integer = 0
            Do While (i < 20)
                Dim row As DataRow = dt.NewRow
                row("ID") = ("ZS00000000000000" + i.ToString)
                row("Price") = ("100," + i.ToString)
                dt.Rows.Add(row)
                i = (i + 1)
            Loop
            
            Dim img1 As System.Drawing.Image = Nothing
            Dim i As Integer = 0
            Do While (i < dt.Rows.Count)
                If (i <> 0) Then
                    doc.NewPage
                End If
                
                Dim cb1 As PdfContentByte = writer.DirectContent
                Dim bf As BaseFont = BaseFont.CreateFont(BaseFont.TIMES_BOLDITALIC, BaseFont.CP1252, BaseFont.NOT_EMBEDDED)
                cb1.SetFontAndSize(bf, 2!)
                cb1.BeginText
                cb1.SetTextMatrix(1.2!, 9.5!)
                cb1.ShowText(txtDescrizioneArticolo.text)
                cb1.EndText
                Dim cb2 As PdfContentByte = writer.DirectContent
                Dim bf1 As BaseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED)
                ' Change the font size here
                cb2.SetFontAndSize(bf1, 1.3!)
                cb2.BeginText
                cb2.SetTextMatrix(17.5!, 1!)
                cb2.ShowText(dt.Rows(i)("Price").ToString)
                cb2.EndText
                Dim cb As iTextSharp.text.pdf.PdfContentByte = writer.DirectContent
                Dim bc As iTextSharp.text.pdf.Barcode128 = New Barcode128
                bc.TextAlignment = Element.ALIGN_LEFT
                bc.Code = dt.Rows(i)("ID").ToString
                bc.StartStopText = false
                bc.CodeType = iTextSharp.text.pdf.Barcode128.EAN13
                bc.Extended = true
                Dim img As iTextSharp.text.Image = bc.CreateImageWithBarcode(cb, iTextSharp.text.BaseColor.BLACK, iTextSharp.text.BaseColor.BLACK)
                cb.SetTextMatrix(1.5!, 3!)
                img.ScaleToFit(60, 5)
                img.SetAbsolutePosition(1.5!, 1)
                cb.AddImage(img)
                i = (i + 1)
            Loop
            
            '''/////////////////***********************************//////////////////////
            doc.Close
            System.Diagnostics.Process.Start((Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/codes.pdf"))
            'MessageBox.Show("Bar codes generated on desktop fileName=codes.pdf");
        Catch  As System.Exception
            
        Finally
            doc.Close
        End Try
       
    End Sub


il testo a capo lo vorrei cb1.ShowText(txtDescrizioneArticolo.text).

Ringrazio in anticipo

Torna al forum | Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.