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
  doc.save("sample_doc1.pdf");
  doc.close();
} catch (IOException | PdfException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
}

Learn ReactJs, React Native from akashmittal.com