@Override
    public void visitFromDocument(COSDocument doc) throws IOException {
        if (!incrementalUpdate) {
            doWriteHeader(doc);
        } else {
            // Sometimes the original file will be missing a newline at the end
            // In order to avoid having %%EOF the first object on the same line
            // as the %%EOF, we put a newline here. If there's already one at
            // the end of the file, an extra one won't hurt. PDFBOX-1051
            getStandardOutput().writeCRLF();
        }

        doWriteBody(doc);

        // get the previous trailer
        COSDictionary trailer = doc.getTrailer();
        long hybridPrev = -1;

        if (trailer != null) {
            hybridPrev = trailer.getLong(COSName.XREF_STM);
        }

        if (incrementalUpdate || doc.isXRefStream()) {
            doWriteXRefInc(doc, hybridPrev);
        } else {
            doWriteXRefTable();
            doWriteTrailer(doc);
        }

        // write endof
        getStandardOutput().write(STARTXREF);
        getStandardOutput().writeEOL();
        getStandardOutput().write(
                String.valueOf(getStartxref()).getBytes(StandardCharsets.ISO_8859_1));
        getStandardOutput().writeEOL();
        getStandardOutput().write(EOF);
        getStandardOutput().writeEOL();

        if (incrementalUpdate) {
            if (signatureOffset == 0 || byteRangeOffset == 0) {
                doWriteIncrement();
            } else {
                doWriteSignature();
            }
        }
    }
This will get the object key for the object.

@param obj The object to get the key for.
@return The object key for the object.
tika-fuzzing/src/main/java/org/apache/tika/fuzzing/pdf/EvilCOSWriter.java