Tech Off Post

Single Post Permalink

View Thread: ASP.NET and iTextSharp (free PDF Generator for .NET)
  • jaleelak

    Hi friends,

    I have a very special requirement with Itextsharp. Actually, I have Infopath form template(.xsn). When I fill it out and save , it is stored as >xml files. I need to convert this to .pdf files. I think , ItextSharp can help me.


    I got a code from http://www.ujihara.jp/iTextdotNET/en/examples.html  as shown here.When I run this , it creates pdf but no contents. I think step 3 has some problem. To convert XML, should I use XSL. Cna anybody help me in this....?

    public class Chap0704 
    {
      public static void Main(String[] args)
         {
                // step 1: creation of a document-object
                 Document documentA = new Document(PageSize.A4, 80, 50, 30, 65);
            
                   // step 1: creation of a document-object
                   Document documentB = new Document(PageSize.A4, 80, 50, 30, 65);
            
                   // step 2:
                   // we create a writer that listens to the document
                   // and directs a XML-stream to a file
                   PdfWriter.getInstance(documentA, new FileStream("Chap0704a.pdf", FileMode.Create));
                   PdfWriter.getInstance(documentB, new FileStream("Chap0704b.pdf", FileMode.Create));
            
                   // step 3: we parse the document
                   XmlParser.parse(documentA, "Chap0701.xml");
                 XmlParser.parse(documentB, "playRomeoJuliet.xml", "tagmapRomeoJuliet.xml");
            }
    }

    Thanks in advance....