PdfImageXObject extends PdfXObject { @Override public void flush() { super.flush(); } PdfImageXObject(ImageData image);  PdfImageXObject(ImageData image, PdfImageXObject imageMask);  PdfImageXObject(PdfStream pdfStream); @Override float getWidth(); @Override float getHeight(); @Override void flush(); PdfImageXObject copyTo(PdfDocument document); java.awt.image.BufferedImage getBufferedImage(); byte[] getImageBytes(); byte[] getImageBytes(boolean decoded); ImageType identifyImageType(); String identifyImageFileExtension(); PdfImageXObject put(PdfName key, PdfObject value);  }
@Test public void addFlushedImageXObjectToCanvas() throws IOException, InterruptedException { String filename = destinationFolder + "addFlushedImageXObjectToCanvas.pdf"; String cmpfile = sourceFolder + "cmp_addFlushedImageXObjectToCanvas.pdf"; String image = sourceFolder + "image.png"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(filename)); PdfImageXObject imageXObject = new PdfImageXObject(ImageDataFactory.create(image)); imageXObject.getPdfObject().makeIndirect(pdfDoc).flush(); PdfCanvas canvas = new PdfCanvas(pdfDoc.addNewPage()); canvas.addXObject(imageXObject, 50, 500, 200); pdfDoc.close(); Assert.assertNull(new CompareTool().compareByContent(filename, cmpfile, destinationFolder)); }