This is pushing me too close to the edge ":-( On FrmCreatePDF is a Btn_GeneratePDF. The code snippet below slightly modified from CodeGuru throws a "NULL REFERENCE Object reference not set to an instance of an object". The error is thrown on "document.Add(header);". So 'document' is a new object right? Also 'header' is a new Paragraph object right? So why does this code not work for me?
Thanks in advance.
Thanks in advance.
Create PDF:
private void Btn_GeneratePDF_Click(object sender, EventArgs e)
{
String pdfDestination = "C:/users/rickw/source/repos/QC-Base/PDFs/example.pdf";
PdfWriter myPDFwriter = new PdfWriter(pdfDestination);
PdfDocument pdfDoc = new PdfDocument(myPDFwriter);
Document document = new Document(pdfDoc);
Paragraph header = new Paragraph("HEADER")
.SetTextAlignment(TextAlignment.CENTER)
.SetFontSize(20);
document.Add(header);
document.Close();
}