I need to create a pdf document with images that should be contained in layers. Each image should be contained in a layer, so that we can choose to make each image either visible or not.
I know that iText offers a class PdfLayer for that purpose but they don't explain how to use it. Surprisingly tutorials in the web don't cover this question.
This is a little start:
// Creating a PdfWriter
String dest = "export.pdf";
PdfWriter writer = new PdfWriter(dest);
// Creating a PdfDocument
PdfDocument pdfDoc = new PdfDocument(writer);
// Adding an empty page
//pdfDoc.addNewPage();
// Creating a Document
Document document = new Document(pdfDoc);
/////////////////////////////////////////////////////////
// Creating an ImageData object
String imageFile = "map.png";
ImageData data = ImageDataFactory.create(imageFile);
// Creating an Image object
Image img = new Image(data);
PdfLayer pdflayer = new PdfLayer("main layer", pdfDoc);
pdflayer.setOn(true);
/* normally, here where the image should be added to the layer */
Hope for your help, thanks!