Getting a mysterious null ref error using itext7. Everything was working fine before. The PDF I'm reading looks normal.
var sr1 = new MemoryStream(data);
rdr = new PdfReader(sr1);
// https://stackoverflow.com/questions/17691013/pdfreader-not-opened-with-owner-password-error-in-itext
rdr.SetUnethicalReading(true);
pdf = new PdfDocument(rdr);
var pages = pdf.GetNumberOfPages();
merger.Merge(pdf, 1, pages);
The only recent change was to add that call to SetUnethicalReading, which fixed one issue. The PDF is fine, data has plenty of bytes. 'merger' is not null, nor is 'pdf'.
System.NullReferenceException: Object reference not set to an instance of an object.
at iText.Kernel.Pdf.PdfOutline..ctor(String title, PdfDictionary content, PdfOutline parent)
at iText.Kernel.Pdf.PdfCatalog.ConstructOutlines(PdfDictionary outlineRoot, IDictionary`2 names)
at iText.Kernel.Pdf.PdfCatalog.GetOutlines(Boolean updateOutlines)
at iText.Kernel.Pdf.PdfDocument.GetOutlines(Boolean updateOutlines)
at iText.Kernel.Pdf.PdfPage.GetOutlines(Boolean updateOutlines)
at iText.Kernel.Pdf.PdfDocument.CopyPagesTo(IList`1 pagesToCopy, PdfDocument toDocument, Int32 insertBeforePage, IPdfPageExtraCopier copier)
at iText.Kernel.Pdf.PdfDocument.CopyPagesTo(IList`1 pagesToCopy, PdfDocument toDocument, IPdfPageExtraCopier copier)
at iText.Kernel.Pdf.PdfDocument.CopyPagesTo(IList`1 pagesToCopy, PdfDocument toDocument)
at iText.Kernel.Utils.PdfMerger.Merge(PdfDocument from, IList`1 pages)
at iText.Kernel.Utils.PdfMerger.Merge(PdfDocument from, Int32 fromPage, Int32 toPage)