添加模板并保留pdf标签?

添加模板并保留pdf标签?,pdf,itext,Pdf,Itext,我正在努力工作与标记的内容在此刻,并偶然发现了一个小问题 目前,我使用以下代码将预定义PDF添加到我的新PDF中: // we only use the first page to import PdfImportedPage importedPage = m_writer.GetImportedPage(target, 1); // calculate the transformation matrix // set up t

我正在努力工作与标记的内容在此刻,并偶然发现了一个小问题

目前,我使用以下代码将预定义PDF添加到我的新PDF中:

        // we only use the first page to import
        PdfImportedPage importedPage = m_writer.GetImportedPage(target, 1);

        // calculate the transformation matrix 
        // set up the affine transform 
        float angle = (float)(item.rotationAngle * (Math.PI / 180.0f));
        float a = item.scalingX * (float)(Math.Cos(angle));
        float b = item.scalingY * (float)(Math.Sin(angle));
        float c = (-item.scalingX) * (float)(Math.Sin(angle));
        float d = (item.scalingY) * (float)(Math.Cos(angle));            

        // output
        cb.AddTemplate(importedPage, a, b, c, d, item.x, item.y);
这很好,允许我在同一页上添加多个PDF格式的图片

现在是我的问题了,当我这样做时,标记“Figure”不会出现在标记列表中:

        cb.BeginMarkedContentSequence(PdfName.FIGURE);

        // we only use the first page to import
        PdfImportedPage importedPage = m_writer.GetImportedPage(target, 1);

        // calculate the transformation matrix ( scaling and rotation !! counter clockwise )
        // set up the affine transform 
        float angle = (float)(item.rotationAngle * (Math.PI / 180.0f));
        float a = item.scalingX * (float)(Math.Cos(angle));
        float b = item.scalingY * (float)(Math.Sin(angle));
        float c = (-item.scalingX) * (float)(Math.Sin(angle));
        float d = (item.scalingY) * (float)(Math.Cos(angle));            

        // output
        cb.AddTemplate(importedPage, a, b, c, d, item.x, item.y);

        cb.EndMarkedContentSequence();
是否有办法将pdf标签添加到导入的页面,或者这是错误的方法?Afaik GetImportedPage()会删除标记,这就是我无法处理“预标记”项目的原因


提前感谢:)

对于这种工作,这是错误的方法,也是错误的iText版本。试试看文本7。但是请注意,合并不同文档的结构树绝非易事。@BrunoLowagie你能告诉我正确的方法是什么吗?是否已经有了一个C版本的iText 7(因为我一直在使用C)。是的,有一个C版本的iText 7,没有:我自己还没有机会看到合并标记的PDF。我只知道它在iText 7的技术路线图上,据我所知,它已经得到实施。