关闭文档时出现错误。从 PdfCopy 调用函数“FixTaggedStructure”时抛出它
Dictionary<int, PdfIndirectReference> numTree = structureTreeRoot.NumTree;
我的调试器显示“structureTreeRoot”为空,但我不知道为什么。
我的代码非常简单。我正在尝试将 PDF 转换为 PDF/A-1,请 参阅将 PDF 转换为 PDF/A3 或将 PDF/A-1 转换为 PDF/A-3
Document doc = new Document();
FileStream fs = new FileStream(destPdfA, FileMode.Create);
PdfReader reader = new PdfReader(pdfParth);
PdfCopy copy = new PdfCopy(doc, fs);
copy.SetPdfVersion(PdfCopy.PDF_VERSION_1_4);
copy.SetTagged();
copy.CreateXmpMetadata();
doc.Open();
ICC_Profile icc = ICC_Profile.GetInstance(new FileStream(ICM, FileMode.Open));
PdfDictionary outi = new PdfDictionary(PdfName.OUTPUTINTENT);
outi.Put(PdfName.OUTPUTCONDITIONIDENTIFIER, new PdfString("sRGB IEC61966-2.1"));
outi.Put(PdfName.INFO, new PdfString("sRGB IEC61966-2.1"));
outi.Put(PdfName.S, PdfName.GTS_PDFA1);
// get this file here: http://old.nabble.com/attachment/10971467/0/srgb.profile
PdfICCBased ib = new PdfICCBased(icc);
ib.Remove(PdfName.ALTERNATE);
outi.Put(PdfName.DESTOUTPUTPROFILE, copy.AddToBody(ib).IndirectReference);
copy.ExtraCatalog.Put(PdfName.OUTPUTINTENTS, outi);
copy.AddDocument(reader);
doc.Close();