title: itext7 - adding content from existing PDF to a new one
body: <p>I'm trying to add some content to my PDF document to the first page of the document. What would be appropriate way of doing this? </p>
  
  <p>At the moment my code works, but it adds(inserts) a new page before the first page of my document. What could be used here insted of the </p>
  
  <pre><code>    PdfPage page = pdf.addNewPage(1, PageSize.A4);
  </code></pre>
  
  <p>so the content from the document I'm reading is added to the existing first page as content and not as a new page</p>
  
  <pre><code>  public static void addContentToFirstPage(String inputFilePath,String filePath) throws IOException, DocumentException {
  
        File inFile = new File(inputFilePath);
        File outFile = new File(inputFilePath + "_numbering.pdf");
  
        PdfDocument pdf = new PdfDocument(new PdfReader(inFile), new PdfWriter(outFile));
        PdfDocument origPdf = new PdfDocument(new PdfReader(filePath));
  
        PdfPage origPage = origPdf.getPage(1);
        Rectangle orig = origPage.getPageSize();
  
        PdfPage page = pdf.addNewPage(1, PageSize.A4);
  
        PdfCanvas canvas = new PdfCanvas(page);
        AffineTransform transformationMatrix = AffineTransform.getScaleInstance(
                  page.getPageSize().getWidth() / orig.getWidth(),
                  page.getPageSize().getHeight() / orig.getHeight());
  
        canvas.concatMatrix(transformationMatrix);
        PdfFormXObject pageCopy = origPage.copyAsFormXObject(pdf); 
  
        canvas.addXObject(pageCopy, 0, 0);
  
        pdf.close();
        origPdf.close();
  
          // delete old file,rename new to old file
          inFile.delete();
          outFile.renameTo(new File(inputFilePath));
  
      }
  </code></pre>