Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Im trying to get some string input of a textbox to a pdf document on a button click



i got a code from net

VB
Dim pdf As PdfDocument = New PdfDocument
       pdf.Info.Title = "My First PDF"
       Dim pdfPage As PdfPage = pdf.AddPage
       Dim graph As XGraphics = XGraphics.FromPdfPage(pdfPage)
       Dim font As XFont = New XFont("Verdana", 20, XFontStyle.Bold)
       graph.DrawString(Convert.ToString(txtdata.Text), font, XBrushes.Black, _
       New XRect(0, 0, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.Center)
       Dim pdfFilename As String = "firstpage.pdf"
       pdf.Save(pdfFilename)
       Process.Start(pdfFilename)



the output of pdf file is just in a single line (other data got trimmed)...not in paragraph format....

My (txtdata.text) may contain at least 2 pages of text ..

is there any other way ?? if so please provide me step by step format.

thanking you in advance

[Note: no need of crystal report]
Posted
Comments
Richard MacCutchan 22-May-14 4:46am    
Search Google for "iTextSharp" and you will find lots of help.
Sidharth R 22-May-14 5:58am    
ya thanq i got a solution

Dim myDocument As New iTextSharp.text.Document(PageSize.A4.Rotate())
Try

PdfWriter.GetInstance(myDocument, New FileStream("c:\XXXXX.pdf", FileMode.Create))
myDocument.Open()
myDocument.Add(New iTextSharp.text.Paragraph(txtdata.Text))

Catch de As DocumentException
Console.[Error].WriteLine(de.Message)
Catch ioe As IOException
Console.[Error].WriteLine(ioe.Message)
End Try
myDocument.Close()

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900