title: iText5 placing a generated QR Code of varying sizes in the header at top right-hand side of a Java rendered PDF document
body: <p>I have a legacy Java program that creates a PDF invoice document (PageSize.LETTER) using iText 5. A “setPageEvent” on a “PdfWriter” of the “Document” creates a header on the document. The “onEndPage” event method creates a “PdfTable” with five columns (i.e., PdfPcell) of varying widths.</p>
  <p>Currently, the first action of the method is to create a cell with a banner image across all five columns (cell.setColspan(5)).</p>
  <p>My challenge, on certain documents, a generated QR code needs to be placed to the right of this banner image at the top right of the page.</p>
  <p>I have read numerous posts and tried different methods to make the banner image span four columns and add the QR code image to the fifth cell. Due to the amount of data contained in the QR code, the code either goes off the top of the page, or when I scale the image (image.scalePercent), a QR code reader fails to read the code.</p>
  <p>For the time being, I have abandoned using the &quot;cell&quot; method, attempting to use somehow either an absolute or fixed positioning of the image to place it in the top right-hand corner next to the banner image. Confusion persists on how to utilize the myriad of “document,” “cell,” and “image” class methods to achieve the desired results of the QR code placed directly to the right of the banner image.</p>
  <p>The QR code gets generated using the “zxing” package. The length and width of the “qrCodewriter.encode” method makes no difference on the size of the QR code, and either does a format of “JPG” or “PNG.” in the “MatrixToImageWriter.writeToStream” method call.</p>
  <p>Any help on a direction to follow will be greatly appreciated.</p>