Check out example codes for "open a pdf file and write to it in java". It will help you in understanding the concepts better.

Code Example 1

// Create a PdfDocument instance
PdfDocument doc = new PdfDocument(); 

try {
  // Write some text on page 1
  doc.writeText("Hello, World!"); // automatically creates a blank page 

  // Save document to file"sample_doc1.pdf");
} catch (IOException | PdfException e) {
  // TODO Auto-generated catch block

Learn ReactJs, React Native from