Вот что я пытался решить эту проблему:
Код: Выделить всё
Marked Content for Rectangle: I created marked content for the image’s rectangle and added it to the document. (No success, as the error persisted).
Adding COSName.BBOX to Figure Structure Element: I added a new item COSName.BBOX with a Rectangle(x, y, width, height) to the figure structure element. (Resulted in a corrupted PDF).
Adding COSName.BBOX to Figure Reference: I added a new item with COSName.BBOX in the figure reference, similar to step 2. (Also resulted in a corrupted PDF).
Код: Выделить всё
COSDictionary markedContentDictionary3 = new COSDictionary();
markedContentDictionary3.setInt(COSName.MCID, mcidCounter + 2);
markedContentDictionary3.setString(COSName.ALT, "Alternate Image Description");
PDMarkedContentReference mcr3 = new PDMarkedContentReference();
mcr3.setMCID(mcidCounter + 2);
//COSDictionary markedContentDictionary4 = new COSDictionary();
//markedContentDictionary4.setInt(COSName.MCID, mcidCounter + 3);
//PDMarkedContentReference mcr4 = new PDMarkedContentReference();
//mcr4.setMCID(mcidCounter + 3);
contentStream.beginMarkedContent(COSName.IMAGE, PDPropertyList.create(markedContentDictionary3));
contentStream.drawImage(image, x, y, width, height);
contentStream.endMarkedContent();
// Schließen des Inhaltsstroms
contentStream.close();
PDStructureElement figureElement = new PDStructureElement(StandardStructureTypes.Figure, documentElement);
figureElement.setPage(page);
figureElement.setAlternateDescription("Dieses Bild zeigt: ");
figureElement.appendKid(mcr3);
documentElement.appendKid(figureElement);

Подробнее здесь: https://stackoverflow.com/questions/791 ... -in-pdf-ua