0
var file = new FileStream("output.pdf", FileMode.Create);
using (var document = new Document())
{
    PdfWriter writer = PdfWriter.GetInstance(document, file);
}

this is throwing null reference exception in my system

Adalyat Nazirov
  • 1,611
  • 2
  • 14
  • 28
Anmol
  • 9
  • At which point is the exception thrown? – Heslacher Jun 15 '23 at 05:20
  • 1
    Does this answer your question? [iTextSharp pdfWriter.GetInstance error](https://stackoverflow.com/questions/26884908/itextsharp-pdfwriter-getinstance-error) – Heslacher Jun 15 '23 at 05:21
  • 1
    what is output.pdf. you should include complete path of file like "C:\output.pdf" – zia khan Jun 15 '23 at 05:29
  • PdfWriter writer = PdfWriter.GetInstance(document, file); here exception is thrown – Anmol Jun 15 '23 at 05:56
  • could you provide a full exception including the inner call stack? Because the code you provided is fine and works – Adalyat Nazirov Jun 15 '23 at 06:23
  • Actual code is working fine but the GetInstance method is taking bit longer time to load since the file is not loading it is throwing the error , i dont know to use await and async here. – Anmol Jun 15 '23 at 06:27
  • Yes "output.pdf" is the full reference for the file – Anmol Jun 15 '23 at 06:50
  • First of all, please *provide a full exception including the inner call stack* as @Adalyat has asked for. If you provide no details, the only answers you'll get are like the generic one Fildor's comment points to. Furthermore you say you *dont know to use await and async here* - you simply don't do so; iText does not make use of these asynchronous constructs. – mkl Jun 15 '23 at 10:33

0 Answers0