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.

Bobrovsky
  • 13,789
  • 19
  • 80
  • 130
Arindam Das
  • 699
  • 4
  • 20
  • 39
  • 1
    http://stackoverflow.com/questions/430941/c-sharp-pdf-printing-library?rq=1 , http://stackoverflow.com/questions/1324597/how-to-render-an-asp-net-mvc-view-in-pdf-format?rq=1 , http://stackoverflow.com/questions/10341416/server-side-html-to-pdf?rq=1 *Please use the "search" feature* –  Feb 21 '13 at 07:18

3 Answers3

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
Pranay Rana
  • 175,020
  • 35
  • 237
  • 263
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();

} 
-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/