Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

[5682] iTextSharp :library to create PDF Files on fly in C#.net

Last post 07-25-2007 1:55 PM by mintara. 15 replies.
Page 1 of 2 (16 items) 1 2 Next >
Sort Posts: Previous Next
  • 01-01-1999 12:00 AM

    [5682] iTextSharp :library to create PDF Files on fly in C#.net

    • Post Points: 30
  • 07-18-2006 2:02 PM In reply to

    • svas_sri
    • Not Ranked
    • Joined on 07-18-2006
    • New Member
    • 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




































































































































































































































    • Post Points: 20
  • 07-24-2006 8:04 AM In reply to

    • svas_sri
    • Not Ranked
    • Joined on 07-18-2006
    • New Member
    • Points 25

    Re: [5682] iTextSharp :library to create PDF Files on fly in C#.net

    Is there any other way to create our own schemas(Custom) for writing  and reading the meta data

    Please kindly help me

    Thank you





    • Post Points: 5
  • 08-12-2006 5:33 PM In reply to

    • essone
    • Not Ranked
    • Joined on 08-12-2006
    • New Member
    • Points 5

    Re: [5682] iTextSharp :library to read & write into pdf using vb.net

    hi there,

    nice and cool stuff Smiley Face [:)], but works with text files onlySad [:(]; what if i have images to be converted into pdf, or a word document with images.





    • Post Points: 5
  • 08-28-2006 11:32 AM In reply to

    • Cerebro
    • Top 500 Contributor
    • Joined on 10-07-2005
    • Member
    • Points 305

    Re: [5682] iTextSharp :library to read & write into pdf using vb.net

    Hi

    where i can dowload itextsharp.dll?
    i can find in  http://www.lowagie.com/iText/






    • Post Points: 5
  • 08-28-2006 11:32 AM In reply to

    • Cerebro
    • Top 500 Contributor
    • Joined on 10-07-2005
    • Member
    • Points 305

    Re: [5682] iTextSharp :library to read & write into pdf using vb.net

    Hi

    where i can dowload itextsharp.dll?
    i can't find in  http://www.lowagie.com/iText/






    • Post Points: 10
  • 09-27-2006 9:39 PM In reply to

    • routing
    • Not Ranked
    • Joined on 09-27-2006
    • New Member
    • Points 15

    Re: [5682] iTextSharp :library to create PDF Files on fly in C#.net

    I tried the example, but I got an error message --
    Compiler Error Message: CS0117: 'iTextSharp.text.pdf.PdfWriter' does not contain a definition for 'getInstance'

    I'm wondering what is wrong.

    Thanks,
    Mike







    • Post Points: 5
  • 09-27-2006 9:40 PM In reply to

    • routing
    • Not Ranked
    • Joined on 09-27-2006
    • New Member
    • Points 15

    Re: [5682] iTextSharp :library to create PDF Files on fly in C#.net

    I tried the example, but I got an error message --
    Compiler Error Message: CS0117: 'iTextSharp.text.pdf.PdfWriter' does not contain a definition for 'getInstance'

    I'm wondering what is wrong.

    Thanks,
    Mike





    • Post Points: 10
  • 09-30-2006 9:14 PM In reply to

    • 1nspired
    • Not Ranked
    • Joined on 09-30-2006
    • New Member
    • 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.

    • Post Points: 5
  • 10-10-2006 4:12 PM In reply to

    • stanglp
    • Not Ranked
    • Joined on 10-10-2006
    • New Member
    • Points 5

    Re: [5682] iTextSharp :library to create PDF Files on fly in C#.net

    I have a problem using itextsharp: I want to append a document to one existing, therefore i write:
    PdfWriter.GetInstance(doc,new FileStream(filename,FileMode.Append,FileAccess.Write));
    I also tried a StreamWriter:
    StreamWriter sw = new StreamWriter(filename,true);
    sw.AutoFlush = true;
    PdfWriter.GetInstance(doc,sw.BaseStream);

    Now the Problem is, that the Filesize of the pdf document is getting bigger and bigger, but I can always just see the last page added to the document

    does anyone has any idea?? thx
    • Post Points: 5
  • 11-04-2006 6:40 AM In reply to

    • babin
    • Not Ranked
    • Joined on 11-04-2006
    • New Member
    • Points 5

    Re: [5682] iTextSharp :library to read & write into pdf using vb.net

    You can download from here

    http://sourceforge.net/project/showfiles.php?group_id=72954&package_id=72901&release_id=458860
    it's for CSharp (.NET)

    But I need Tutorial on iTextSharp as I need to genetrate *.JTF , *.PDL file by "iTextSharp"

    can any one help regards this








    • Post Points: 5
  • 11-09-2006 10:27 AM In reply to

    • steedsoft
    • Not Ranked
    • Joined on 06-06-2006
    • China
    • New Member
    • Points 15

    Re: [5682] iTextSharp :library to create PDF Files on fly in C#.net

    just download tutorial codes from http://blog.rubypdf.com/download
    both 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.
    • Post Points: 5
  • 11-18-2006 7:21 AM In reply to

    • walcom
    • Not Ranked
    • Joined on 06-05-2006
    • Sudan
    • New Member
    • Points 10

    Re: [5682] iTextSharp :library to create PDF Files on fly in C#.net

    This package cannot create PDF file from a string variable that contains Arabic letters

    When creating PDF file of Arabic letters, there is no text in the output file.





    • Post Points: 10
  • 05-14-2007 1:50 PM In reply to

    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();

    • Post Points: 5
  • 07-25-2007 1:54 PM In reply to

    • mintara
    • Not Ranked
    • Joined on 04-24-2007
    • Germany
    • New Member
    • Points 10

    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.


     







    • Post Points: 5
Page 1 of 2 (16 items) 1 2 Next >