We're building a brand new version of the site, and we'd love to hear your ideas
Members
Technology Zones
IBM Learning Center
Articles
Hosted By
Info
|
[5682] iTextSharp :library to create PDF Files on fly in C#.net
Last post 08-29-2008 1:51 PM by janebush08. 16 replies.
-
01-01-1999 12:00 AM
|
|
Advertisement
|
|
-
-
svas_sri


- Joined on 07-18-2006

- Points 25
|
Re: [5682] iTextSharp :library to read & write into pdf using vb.net
Thank you for the Shortest Explanation I was able to work out with vb.net using your help
Srinivas
Add the itextsharp.dll in the references
Add 2 command buttons
Add 6 text boxes
Add the Class MetaData with in the form class
copy the code in the respective places and run
Imports System Imports System.IO Imports iTextSharp.text Imports iTextSharp.text.pdf Imports System.Data Imports System.Text Imports System.Drawing Imports System.ComponentModel Imports System.Collections
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fs As FileStream Dim sr As StreamReader Dim mydocument As Document Dim i As Integer
fs = New FileStream("c:\LOGFILE.txt", FileMode.Open, FileAccess.Read) sr = New StreamReader(fs)
Dim t As String
t = "X" While t <> "" If i < 1 Then t = sr.ReadToEnd i = i + 1
mydocument = New Document
PdfWriter.GetInstance(mydocument, New FileStream("c:\csharp.pdf", FileMode.Create))
mydocument.AddTitle("SamplePDF") mydocument.AddAuthor("Srinivas") mydocument.AddCreator("PDM Technologies") mydocument.AddKeywords("First testing program for checking the metada in pdf") mydocument.AddSubject("PDF Creator") mydocument.AddHeader("PDM Technologies", "PDM Technologies")
mydocument.Open() mydocument.Add(New Paragraph(t)) mydocument.Close()
Else t = sr.ReadToEnd i = i + 1 If t <> "" Then mydocument = New Document
PdfWriter.GetInstance(mydocument, New FileStream("c:\csharp.pdf", FileMode.Append, FileAccess.Write))
mydocument.Open()
mydocument.Add(New Paragraph(t)) mydocument.Close() End If End If
End While
sr.Close() fs.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim fs As FileStream Dim sw As StreamWriter Dim mydocument As Document Dim fr As FileStream Dim sr As StreamReader Dim t As String
Dim m As MemoryStream = New MemoryStream
Dim md As MetaData = New MetaData
Dim Reader As PdfReader = New PdfReader("c:\csharp.pdf")
md.info1 = Reader.Info
TextBox1.Text = md.info1("Author")
TextBox2.Text = md.info1("Subject")
TextBox3.Text = md.info1("Title")
TextBox4.Text = md.info1("Creator")
TextBox5.Text = md.info1("Producer")
TextBox6.Text = md.info1("Keywords")
End Sub
Public Class MetaData Private info As Hashtable = New Hashtable
Public Property info1() Get Return info End Get Set(ByVal Value) info = Value End Set End Property
Public Property Author() As String Get Return info1(Author) End Get Set(ByVal Value As String) info.Add("Author", Value) End Set End Property Public Property Title() As String Get Return info1(Title) End Get Set(ByVal Value As String) info.Add("Title", Value) End Set End Property
Public Property Subject() As String Get Return info1(Subject) End Get Set(ByVal Value As String) info.Add("Subject", Value) End Set End Property
Public Property Keywords() As String Get Return info1(Keywords) End Get Set(ByVal Value As String) info.Add("Keywords", Value) End Set End Property
Public Property Producer() As String Get Return info1(Producer) End Get Set(ByVal Value As String) info.Add("Producer", Value) End Set End Property
Public Property Creator() As String Get Return info1(Creator) End Get Set(ByVal Value As String) info.Add("Creator", Value) End Set End Property
Public Property Version() As String Get Return info1(Version) End Get Set(ByVal Value As String) info.Add("Version", Value) End Set End Property Public Property Header() As String Get Return info1(Header) End Get Set(ByVal Value As String) info.Add("Header", Value) End Set End Property
End Class
|
|
-
-
-
-
-
-
-
-
1nspired


- Joined on 09-30-2006

- Points 5
|
Re: [5682] iTextSharp :library to create PDF Files on fly in C#.net
Try:
PdfWriter.GetInstance(mydocument, New FileStream("filename.pdf", FileMode.Create));
If you're using C# it's case sensitive and the "g" needs to be uppercase.
|
|
-
-
-
-
steedsoft


- Joined on 06-06-2006
- China

- Points 15
|
Re: [5682] iTextSharp :library to create PDF Files on fly in C#.net
just download tutorial codes from http://blog.rubypdf.com/downloadboth C# and VB.NET(over 100 code examples)
Welcome to use the PDF softwares I developed, you can download it from http://www.rubypdf.com http://www.steedsoft.com. And welcome to talk about iTextsharp.
|
|
-
-
-
Linda Fahmy


- Joined on 05-12-2007
- Egypt

- Points 5
|
Re: [5682] iTextSharp :library to create PDF Files on fly in C#.net
Hello,I found out how to generate Arabic PDF files, here is an example:
Document document = new Document(PageSize.A4, 50, 50, 50, 50);
// step 2
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("righttoleft.pdf",FileMode.Create));
// step 3
document.Open();
BaseFont bf = BaseFont.CreateFont("c:\\windows\\fonts\\times.ttf", BaseFont.IDENTITY_H, true);
iTextSharp.text. Font f2 = new iTextSharp.text.Font(bf, 24, iTextSharp.text.Font.NORMAL, iTextSharp.text.Color.BLUE);
String atext = "اهلا";
PdfPTable table = new PdfPTable(1);
table.RunDirection= PdfWriter.RUN_DIRECTION_RTL;
PdfPCell cell = new PdfPCell(new Phrase(10, atext, f2));
table.AddCell(cell);
document.Add(table);
document.Close();
|
|
-
-
mintara


- Joined on 04-24-2007
- Germany

- Points 15
|
Re: [5682] iTextSharp :library to read & write into pdf using vb.net
Hello,
Iam using itextsharp 4.0.2.0 and vc++.net 2003. Could you please tell me how to create an array of image objects in Itextsharp I tried this iTextSharp::text::Image *in[]=new iTextSharp::text::Image[50]; for (int i=0;i<Length; i++)
in[i]= iTextSharp:: text::Image::GetInstance(imgfilename[i]); //imgfilename[i]- path of image in[i]->ScalePercent(95); } but it does not work. Thanks in advance for your time.
|
|
|
Search
Code Samples
New Members
|