How can I generate a PDF automatically using itext in C#?

时间:2019-03-19 14:39:50

标签: c# pdf itext

I have a Windows Form App which automatically generates a PDF using itext. I was using the following code previously to generate the PDF:

namespace ConsoleApp2 { class Program { static void Main(string[] args) {

        Document document = new Document();

        PdfWriter.GetInstance(document, new FileStream("C:/Users/bra/800C.pdf", FileMode.Create));

        document.Open();

        document.Add(Chunk.NEWLINE);                             

        Paragraph p17 = new Paragraph("Use formulations of Penzien (2000) assuming full slip condition. ");
        document.Add(p17);

        document.Close();

        Console.ReadLine();
    }
}

}

Is there a way that my code could be modified so that the PDF can be opened automatically when the program is run? (Rather than being saved on the C drive)? I have seen some examples with memoryStream online but couldn't wrap my head around how this works.

Thanks in advance.

0 个答案:

没有答案