Tried to generate a simple pdf with pdfbox 3.0.0-RC1 and it generates corrupt pdf. On further inspection the pdf generated is missing xref. Tried with pdfbox 2.0.24 and the pdf is generated successfully. The xref is there and I can open the PDF. Anyone know if this is a issue with pdfbox 3.0.0-RC1?
Edit:
ByteArrayOutputStream output = new ByteArrayOutputStream();
try (PDDocument document = new PDDocument()) {
PDPage page = new PDPage();
document.addPage(page);
try (PDPageContentStream contentStream = new PDPageContentStream(document, page)) {
contentStream.beginText();
contentStream.setFont(PDType1Font.TIMES_ROMAN, 12);
contentStream.setLeading(14.5f);
contentStream.newLineAtOffset(25, 700);
contentStream.showText("Hello World");
contentStream.endText();
// Make sure that the content stream is closed:
contentStream.close();
}
document.save(output);
} catch (Exception e) {
e.printStackTrace();
}
Edit2:
%PDF-1.6
%öäüß
1 0 obj
<<
/Type /Catalog
/Version /1.4
/Pages 2 0 R
>>
endobj
7 0 obj
<<
/Length 50
/Filter /FlateDecode
>>
stream
xs
áÒw3T04RIã240P0â.
Ô|ðü¢M,.×.
Ð
endstream
endobj
8 0 obj
<<
/Length 189
/Type /ObjStm
/N 5
/Filter /FlateDecode
/First 27
>>
stream
xUÍ
Â0_e^@·ikKA
endstream
endobj
9 0 obj
<<
/Length 33
/Root 1 0 R
/ID [<B8D11B08CDC0D3C46CF107ADC4249370> <B8D11B08CDC0D3C46CF107ADC4249370>]
/Type /XRef
/Size 10
/Index [0 9]
/W [1 1 1]
/Filter /FlateDecode
>>
stream
xc`øÏÈÏÀÄDLLLÌL,~'
endstream
endobj
startxref
493
%%EOF
Edit3: Link to pdf https://easyupload.io/mz4fsk