0

I am trying to find a way to write a purchase order data in a PDF file. Can any one suggest me anything on this?

I can't afford to buy a 3rd party DLL so want a suggestion for a free DLL or any other way.

I tried this one: (http://www.codeproject.com/Articles/7627/PDF-Library-for-creating-PDF-with-tables-and-text) but it didn't help.

1

3 Answers 3

3

Use iTextSharp is a C# port of iText, and open source Java library for PDF generation and manipulation. It can be used to create PDF documents from scratch, to convert XML to PDF (using the extra XFA Worker DLL), to fill out interactive PDF forms, to stamp new content on existing PDF documents, to split and merge existing PDF documents, and much more.

Features

  • PDF generation
  • PDF manipulation (stamping watermarks, merging/splitting PDFs,...)
  • PDF form filling
  • XML functionality
  • Digital signatures
Sign up to request clarification or add additional context in comments.

5 Comments

is this free ? bcoz i can't buy for this project
@ArindamDas - yes , you can visit the site and check
thanks for that .. i am trying that if it works i will let u know
@ArindamDas - welcome... you can check tutorial on codeproject.com for this..dont forget to upvote and mark answer as accepted if works as you need
@ArindamDas iText and iTextSharp are available either commercially or free subject to the conditions of the AGPL. You should check whether your project is compatible with these conditions.
0

Like wise Create It will Work

string Filepath = Server.MapPath("/AOF.pdf"); var pdfpath = Path.Combine(Filepath, "");

    var Formcontent = ListFieldNames(Filepath);
    Formcontent["Name_txt"] = "T.Test";
    FillForm(Formcontent);
  //  var pdfContents = FillForm(pdfpath, Formcontent);


}
public Dictionary<string, string> ListFieldNames(string Filepath)
{




    //PdfReader pdfReader = new PdfReader(pdfTemplate);

    //StringBuilder sb = new StringBuilder();

    //foreach(DictionaryEntry de in pdfReader.AcroFields.Fields)
    //{

    //    sb.Append(de.Key.ToString() + Environment.NewLine);

    //}

    var Fileds = new Dictionary<string, string>();
    PdfReader pdfReader = new PdfReader(Filepath);
    var reader = new PdfReader(pdfReader);
    foreach (var entry in reader.AcroFields.Fields)
        Fileds.Add(entry.Key.ToString(), string.Empty);
    reader.Close();

    return Fileds;

}
public byte[] FillForm(string pdfPath, Dictionary<string, string> formFieldMap)
{

    var output = new MemoryStream();
    var reader = new PdfReader(pdfPath);
    var stamper = new PdfStamper(reader, output);
    var formFields = stamper.AcroFields;


    foreach (var fieldName in formFieldMap.Keys)
        formFields.SetField(fieldName, formFieldMap[fieldName]);


    stamper.FormFlattening = true;
    stamper.Close();
    reader.Close();

    return output.ToArray();

}
public void FillForm(Dictionary<string, string> Formfiledmap)
{

    string pdfTemplate =Server.MapPath("/AOF.pdf");

    string newFile = @"C:\Users\USer\Desktop\completed_fw4.pdf";

    PdfReader pdfReader = new PdfReader(pdfTemplate);

    PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(newFile, FileMode.Create));

    AcroFields pdfFormFields = pdfStamper.AcroFields;

    foreach(var fieldName in Formfiledmap.Keys)
        pdfFormFields.SetField(fieldName,Formfiledmap[fieldName]);





    pdfStamper.FormFlattening = true;

    pdfStamper.Close();

} 

Comments

-1

You can use iText library for .NET you can find some useful information here http://www.ujihara.jp/iTextdotNET/en/examples.html download the iText Library from http://itextpdf.com/

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.