title: itext7 pdf to image
body: <p>I am using iText7(java) and am looking for  a way to convert a pdf page to image. 
  In older iText versions you could do this : </p>
  
  <pre><code>PdfImportedPage page = writer.getImportedPage(reader, 1);
  Image image = Image.getInstance(page);
  </code></pre>
  
  <p>But iText7 does not have PdfImportedPage .</p>
  
  <p>My use case, I have a one page pdf file. I need to add a table and resize the pdf contents to fit a single page. In old iText I would create a page , add table, convert existing pdf page to image, resize image and add that resized image to new page. Is there a new way to do this in iText7.</p>
  
  <p>Thanks to Bruno's answer I got this working with following code : </p>
  
  <pre><code>PdfPage origPage = readerDoc.getPage(1);
  Rectangle rect = origPage.getPageSize();
  Document document = new Document(writerDoc);
  Table wrapperTable = new Table(1);
  Table containerTable = new Table(new float[]{0.5f,0.5f});
  containerTable.setWidthPercent(100);
  containerTable.addCell( "col1");
  containerTable.addCell("col2");
  
  PdfFormXObject pageCopy = origPage.copyAsFormXObject(writerDoc);
  Image image = new Image(pageCopy);
  image.setBorder(Border.NO_BORDER);
  image.setAutoScale(true);
  image.setHeight(rect.getHeight()-250);
  wrapperTable.addCell(new Cell().add(containerTable).setBorder(Border.NO_BORDER));
  wrapperTable.addCell(new Cell().add(image).setBorder(Border.NO_BORDER));
  document.add(wrapperTable);
  document.close();
  readerDoc.close();
  </code></pre>