iText InvalidPDException重建失败:'&燃气轮机';文件指针处不应为空

iText InvalidPDException重建失败:'&燃气轮机';文件指针处不应为空,itext,Itext,我们正试图使用PdfSmartCopy将许多动态生成的pdf连接在一起,如下所示 Document document = new Document(); PdfCopy copy = new PdfSmartCopy(document, outputStream); document.open(); for (PdfReader reader : list) { int n = reader.getNumberOfPages();

我们正试图使用PdfSmartCopy将许多动态生成的pdf连接在一起,如下所示

    Document document = new Document();
    PdfCopy copy = new PdfSmartCopy(document, outputStream);

    document.open();

    for (PdfReader reader : list) {
         int n = reader.getNumberOfPages();
        // page numbers start at 1
        for (int page = 1; page <= n; page++) {
            copy.addPage(copy.getImportedPage(reader, page));
        }

        copy.freeReader(reader);
        reader.close();
    }

    document.close();
Document Document=新文档();
PdfCopy copy=新的PdfSmartCopy(文档、输出流);
document.open();
用于(PDF阅读器:列表){
int n=reader.getNumberOfPages();
//页码从1开始

对于(int page=1;page)仅当iText遇到语法无效的PDF时才会发生这种情况。请修复PDF,问题将消失。我使用RUPS iText 5.5.8打开了PDF文件(文档是使用iText 5.5.7 btw创建的),但RUPS并没有真正显示任何problem@timpham请与该问题共享一份PDF,以便再现该问题并分析原因。(顺便说一句,异常中的文件指针值可疑地接近2^16屏障;这可能暗示缓冲问题,例如在创建有问题的PDF时。)