0

trying to create a basic pdf document using iText7 core community,

using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;

FileInfo dest = new FileInfo("C:\\Users\\Utente\\OneDrive\\Desktop\\....\\titlepage_17886.pdf");

var writer = new PdfWriter(dest.FullName);
var pdf = new PdfDocument(writer);
var document = new Document(pdf);
document.Add(new Paragraph("Hello World!"));
document.Close();

when I execute hello word example as above always get System.NullReferenceException: 'Object reference not set to an instance of an object.':

(https://i.stack.imgur.com/VTwnQ.png)

Thanks in advance

Michele

  • 1
    Seems like bug in library or you are using it wrong – Selvin Jun 27 '23 at 08:17
  • https://github.com/itext/itext7-dotnet/blob/7cf1b15ddcdff8c8a3c25d462c47e8f73458cf60/itext/itext.io/itext/io/font/FontCache.cs#L54 Its a silent exception that has no influence on program functionality. You just have set up VS to capture those exceptions while debugging. Change settings so that one is ignored or try to fix the fonts in your system. Presumably one or more has a problem. – Ralf Jun 27 '23 at 08:28
  • Ok, I silent the exception and all works fine!! many thanks. – MicheleRoma Jun 28 '23 at 08:48

0 Answers0