title: How to turn PDF page into image and insert it to a new PDF
body: <p>I am using Itext 7 to watermark existing documents. My document is:</p>
  <pre><code>   PdfDocument pdfDoc = new PdfDocument(new PdfReader(sourceFile), new PdfWriter(destinationPath));
  </code></pre>
  <p>Then I am looping thro the pages:</p>
  <pre><code>var numberOfPages = pdfDoc.GetNumberOfPages();
     for (var i = 1; i &lt;= numberOfPages; i++)
                      {
                          page = pdfDoc.GetPage(i);
  
  ...watermark building...
  page.AddAnnotation(watermark);
  
  page?.Flush();
  
  pdfDoc.Close();
  
  }
  </code></pre>
  <p>While that I would like to save this page as an image into this document or to a new pdf document.
  I know that there is the pdfRender available now for Java, but not for C#. Is there a way to save the text based pdf to image based with one leyer? Basically I need to flatten PDF to get all layers to one. So watermark could not be removed as a separate layer with a watermark removal software.</p>
  <p>SOLUTION::UPDATE</p>
  <p>I have the solution now. I found that iText cant do what I want(PDFRender is available in Java right now). So I used Apitron instead to generate images from pages. And then I am using iText again to add images to my new PDF document.
  Here is an example how to add images with Itext 7: <a href="https://www.tutorialspoint.com/itext/itext_adding_image_to_pdf.htm" rel="nofollow noreferrer">https://www.tutorialspoint.com/itext/itext_adding_image_to_pdf.htm</a> (using Image = iText.Layout.Element.Image;)
  Here is an Apitron example for making images from PDF pages: <a href="https://github.com/apitron/Apitron.PDF.Rasterizer.Samples/tree/master/ConvertPDFtoBitmap" rel="nofollow noreferrer">https://github.com/apitron/Apitron.PDF.Rasterizer.Samples/tree/master/ConvertPDFtoBitmap</a></p>
  <p>NOTE: As comments below are saying, the quality is bad with .png. So maybe it is good to use TIFF format.</p>