You use
PDPageContentStream contentStream = new PDPageContentStream(document, page);
This constructor is implemented like this:
public PDPageContentStream(PDDocument document, PDPage sourcePage) throws IOException
{
this(document, sourcePage, false, true);
}
which in turn calls this
/**
* Create a new PDPage content stream.
*
* @param document The document the page is part of.
* @param sourcePage The page to write the contents to.
* @param appendContent Indicates whether content will be overwritten. If false all previous content is deleted.
* @param compress Tell if the content stream should compress the page contents.
* @throws IOException If there is an error writing to the page contents.
*/
public PDPageContentStream(PDDocument document, PDPage sourcePage, boolean appendContent, boolean compress) throws IOException
So that two-parameter constructor always uses appendContent = false
which causes all previous content to be deleted.
Thus, you should instead use
PDPageContentStream contentStream = new PDPageContentStream(document, page, true, true);
to append to the current content.