CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2013
    Posts
    28

    Thumbs up Show all the .pdf contents in to a grid view or any other control ...

    Hi all,

    I am able to read a .pdf file and show it on a text box.... But my requirement is that i shld be able to show all the content and if any images in to the .pdf file in the o/p.... Please help me out... Which control will support for this work...

    I have written the below code...

    Here is the link for dll --- http://sourceforge.net/projects/itextsharp/


    Code:
    Imports System.IO
    Imports System.Text
    Imports iTextSharp.text.pdf
    Imports iTextSharp.text
    Imports Read_Write_PDF_Files
    Imports iTextSharp
    Imports System.Collections.Generic
    Imports iTextSharp.text.pdf.parser
    Imports iTextSharp.text.xml
    
    
    
    ' Dim PdfReader As New System.IO.StreamReader("E:\PDF program in vb.net\Read Write PDF Files\sample.pdf")
    
            Dim text As StringBuilder = New StringBuilder()
            'Dim pdfReader1 As PdfReader = New PdfReader("E:\PDF program in vb.net\Read Write PDF Files\sample.pdf")
            Dim pdfReader1 As PdfReader = New PdfReader(" C:\Users\aseema\Desktop\UGSI - URL Access Request Process.pdf")
    
            Dim page As Integer
            For page = 1 To pdfReader1.NumberOfPages Step page + 1
                Dim strategy As ITextExtractionStrategy = New SimpleTextExtractionStrategy()
                Dim currentText As String = PdfTextExtractor.GetTextFromPage(pdfReader1, page, strategy)
    
                currentText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(currentText)))
    
                'text.Append(currentText)
                TextBox1.Text = currentText
                'DataGridView1.Rows.Add(line.Split(","))
    
                ' DataGridView1.Rows.Add(New String() {currentText})
                '   currentText = "djjoiduieropire"
                text.Append(currentText)
            Next
            pdfReader1.Close()
    
            Return

    add a .dll -- iTextSharp
    If u send me any code or any link that will be of great help....

    NOTE: i have to show word by work or line by line what ever i read from the .pdf file in the o/p.... Also u ppl can suggest me which ever control is good for this....

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Show all the .pdf contents in to a grid view or any other control ...

    You'd have to buy a license for the format of the PDF file. Unless you know someone at ADOBE
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Show all the .pdf contents in to a grid view or any other control ...

    Quote Originally Posted by dglienna View Post
    You'd have to buy a license for the format of the PDF file. Unless you know someone at ADOBE
    Nope.

    You're already using iTextSharp. All you need to do now is use its libraries and functionalities to display the control. You cannot display it otherwise, as the VB / C# controls have no idea of PDF. Even if you were to try a RichTextBox, you would still have to convert the PDF content to RTF.

    My advice would be to interrogate all iTextSharp's capabilities.

    * I do actually have a lot of experience with iTextSharp, just in case you're wondering Good luck!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured