我正在尝试使用标记内容,并偶然发现一个小问题。
目前,我使用以下代码将预定义的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,比如图片。
现在这是我的问题,当我做这样的事情时,标签“图”不会出现在标签列表中:
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()删除标签,这就是我无法使用“预标记”项目的原因。
提前致谢:)