When creating document, there is an issue if the operand for a command is floating number positive or negative Infinity, or NaN.
The problem is in method org.apache.pdfbox.pdmodel.PDPageContentStream#write. In case the method org.apache.pdfbox.pdmodel.PDPageContentStream#writeOperand(float) receives as operand a floating number with value Float.POSITIVE_INFINITY or Float.NEGATIVE_INFINITY the result of formating is symbol for infinity: ∞ (unicode 0x221E). The NaN produce unicode symbol 0xFFFD (replacement character). This is then later converted to bytes using the US_ASCII encoding which produces symbol ? (0x3F) this symbol is then put into the content stream and the resulting PDF is invalid.
Mimimal working example to reproduce this issue.