title: Formatting pdf in Java
body: <p>I have some problem with formatting pdf. I already add text to pdf file but there is problem- I don't know how pdf will look like. I mean there is much more than one template and on one pdf I add in good place, however on another my text cover some important informations.</p>
  
  <pre><code>/**
  * metoda dodaje podpis do pdf
  * @param fileDokument
  * @throws DocumentException
  * @throws IOException
  * @throws SQLException 
  */
  private void addSignatureToPdf(FileDokument fileDokument) throws DocumentException, IOException, SQLException {
     java.util.Date dateToFind = Calendar.getInstance().getTime();
     DecimalFormat df = new DecimalFormat("00");
     DateTime dt = new DateTime();
     int year = dt.getYear();
     int month = dt.getMonthOfYear();
     int day = dt.getDayOfMonth();
  
     File f = new File(fileDokument.getFileNazwa());
  
     String operator = produkt.getOperatorProwadzacyForRolaAndDate(dateToFind, 5).toString();
     operator = operator.replaceAll("\\(.*\\)", "").trim();
  
     PdfReader reader = new PdfReader(""+fileDokument.getFileNazwaFile());
     int height = (int) reader.getPageSize(1).getHeight();
     int width = (int) reader.getPageSize(1).getWidth();
     int fontSize = getFontSizeAdjustingToScreenSize(height);
     int marginCompatibility = getMarginCompatibilityAdjustingToScreenSize(width);
     int heightBelow = getHeightBelowAdjustingToScreenSize(width);
  
     File outFile = File.createTempFile("pismo_", ".pdf", MainApp.tmpDir);
  
     PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(outFile));
     BaseFont bf = BaseFont.createFont(BaseFont.TIMES_ITALIC, codingType, false);
     PdfContentByte over;
  
     int total = reader.getNumberOfPages() + 1;
     for (int a = 1; a &lt; total; a++) {
         stamper.setRotateContents(false);
         over = stamper.getOverContent(a);
         over.beginText();
         over.setFontAndSize(bf,fontSize);
         over.setTextMatrix(marginCompatibility, heightBelow);
         over.showText("Za zgodność z oryginałem Radca Prawny " + operator + ", Wrocław, dnia " + df.format(day) + "-" + df.format(month) + "-" + year + "r.  .................. (podpis)");  
         over.endText();
     }
     stamper.close();
     MainApp.openFile(outFile);
  
  }
  </code></pre>
  
  <p>My idea is to scale pdf to make it a bit smaller and add TextField which will always be empty and won't cover any text. Can you help or give other ideas, please?</p>