Tech Off Thread

10 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

read pdf file in C#

Back to Forum: Tech Off
  • User profile image
    esudhakar

    Hi,

    Ho to read pdf (fields in pdf file) file in c# code?

    I used this code:

    // which document to open

    string file = Server.MapPath(@"C:\Documents and Settings\703477\Desktop\CMSS Documents\NewHealthForm.pdf");

    PdfReader reader = new PdfReader(file);

    // then create a PdfStamper from the created reader to modify the form fields

    PdfStamper outStamper = new PdfStamper(reader, m);

    string name = outStamper.AcroFields.GetField("AGENT_NAME1");


    this throws err:
    pdfreader could not be found, missing namespace or reference

    can any one help me out?
    Sudhakar E, esudhakar@india.com

  • User profile image
    littleguru

    PdfReader, PdfStamper... are those standard .NET classes? I don't think so. Which package are you using?

    I don't understand why people doesn't post more details...

    Have you added a reference to the assembly that contains the PdfReader and PdfStamper classes??

  • User profile image
    cokert

    looks like you need to download this:

    http://sourceforge.net/projects/itextsharp/

  • User profile image
    Deactivated User

    Comment removed at user's request.

  • User profile image
    sbc

    You need iTextSharp and these two 'using' statements:

    using iTextSharp.text;
    using iTextSharp.text.pdf;
    Documentation is not great, but I find the following links helpful

    Tutorial:
    http://itextsharp.sourceforge.net/tutorial/
    The code doesn't seem to work as iText Java code cannot directly be ported to C# (API is slightly different). There is updated code though: http://www.steedsoft.com/itextsharp/tutorial01/index.html


    There is also the mailing list: https://lists.sourceforge.net/lists/listinfo/itextsharp-questions

    As a last resort, I look at the source code or use Reflector.



  • User profile image
    littleguru

    Graaah! *gulp* namespaces in lower case :-!

  • User profile image
    Ion Todirel

    littleguru wrote:
    Graaah! *gulp* namespaces in lower case :-!
    if that's the comercial or whatever name of the component why not? iTextSharp looks good, but iTextSharp.text is stupid, graaah.

  • User profile image
    jBuelna

    littleguru wrote:
    Graaah! *gulp* namespaces in lower case :-!


    Definitely.  Poor naming conventions through and through (it's not a commercial app, so why not?)  You have access to the source.  Feel free to organize and use Pascal casing.

  • User profile image
    jBuelna

    Ion Todirel wrote:
    
    littleguru wrote: Graaah! *gulp* namespaces in lower case :-!
    if that's the comercial or whatever name of the component why not? iTextSharp looks good, but iTextSharp.text is stupid, graaah.


    "iTextSharp" is acceptable.   "ITextSharp" would be a non-descript name of an interface.   I would prefer "Its", but only if I couldn't come up with a better name for the project.   iTextSharp... bah.  

  • User profile image
    sbc

    jBuelna wrote:
    
    Ion Todirel wrote:
    littleguru wrote: Graaah! *gulp* namespaces in lower case :-!
    if that's the comercial or whatever name of the component why not? iTextSharp looks good, but iTextSharp.text is stupid, graaah.


    "iTextSharp" is acceptable.   "ITextSharp" would be a non-descript name of an interface.   I would prefer "Its", but only if I couldn't come up with a better name for the project.   iTextSharp... bah.  

    It's only called that because it is based on iText.

    Namespaces are lowercase (as littleguru states), but classes, methods etc are Pascal case.

    It is a pretty good library - on par with (or even better than) commercial alternatives (documentation isn't great though). Big (lines of code / file size), with lots of features.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.