title: Scale image to fill multiple pages with iText
body: <p>I am trying to scale an image with iText (on a new PDF document) in order to make it fill the width of the page without streching, so that it could take several pages.</p>
  
  <p>I've found a lot of solutions but they were pretty complicated and I don't really like coding like that. The best solution I've found till now (from another question on SO) is using PdfTable but it always uses a single page, scaling the image.</p>
  
  <pre><code>// Load image from external storage
  Image image = Image.getInstance(path + "/img.png");
  // Calculate ratio
  float width = PageSize.A4.getWidth();
  float heightRatio = image.getHeight() * width / image.getWidth();
  Document document = new Document();
  document.open();
  PdfPTable table = new PdfPTable(1);
  table.setWidthPercentage(100);
  PdfPCell c = new PdfPCell(image, true);
  c.setBorder(PdfPCell.NO_BORDER);
  c.setPadding(0);
  // Set image dimensions
  c.getImage().scaleToFit(width, heightRatio);
  table.addCell(c);
  document.add(table);
  // Write PDF file
  document.close();
  </code></pre>
  
  <p>Any suggestions?</p>