Sorry, correct link to PDF generation: link
<https://streaklinks.com/BrNunc4ISJNDPkdhoAuQVw0L/https%3A%2F%2Fgithub.com%2Fnavikt%2Finnsending-api%2Fblob%2Fmain%2Finnsender%2Fsrc%2Fmain%2Fkotlin%2Fno%2Fnav%2Fsoknad%2Fpdfutilities%2FPdfGeneratorTools.kt>


ᐧ

On Tue, Sep 26, 2023 at 11:49 AM Morten Stulen <stulenmor...@gmail.com>
wrote:

>
> You're right, the same validation error occurs in 2.0.29 for that PDF. It
> seems to me that the generation of the PDF differs from v2 to v3 (?). I
> tried just creating a simple page for each, and only PDFBox 3 gives me the ",
> /XRef cross reference streams are not allowed". See code snippets below.
>
> PDFBox 2:
> https://gist.github.com/enstulen/5aad78b7a590a50bced25f54591a90ea
>
> PDFBox 3:
> https://gist.github.com/enstulen/74b504a35db524bd6a0493fd6f82a926
>
> I also attached two PDFs generated with our code with PDFBox 2 and 3. If
> it helps: the code for our PDF generation is here
> <https://github.com/navikt/innsending-api/blob/main/innsender/src/main/kotlin/no/nav/soknad/pdfutilities/PdfGeneratorTools.k>,
>  and
> the PR to upgrade to v3 is here
> <https://streaklinks.com/BrNsiiaaWnLs7YdkGQV0GJoM/https%3A%2F%2Fgithub.com%2Fnavikt%2Finnsending-api%2Fpull%2F103%2Ffiles>
>  (there
> aren't really any changes to the PDF generation itself). I tested with an
> online PDF validator
> <https://streaklinks.com/BrNsiieHR46g-CiyZw229TCo/https%3A%2F%2Fwww.pdf-online.com%2Fosa%2Fvalidate.aspx>
>  and
> only the v3 PDF has the XRef validation error.
>
> If the PDFBox 3 validation is correct, what is required to fix the
> validation for XRef?
>
> ᐧ
>
> On Sat, Sep 23, 2023 at 5:22 AM Tilman Hausherr <thaush...@t-online.de>
> wrote:
>
>> I get the same "error" with 2.0.29.
>>
>> Tilman
>>
>>
>> On 20.09.2023 17:00, Morten Stulen wrote:
>> > After upgrading to PDFBox 3, the PreflightParser.validate() function
>> > returns an error.
>> > "Trailer Syntax error, /XRef cross reference streams are not allowed"
>> >
>> > Code:
>> >
>> > fun isValid(bytes: ByteArray): Boolean {
>> >    val fileName = "tmp_${UUID.randomUUID()}.pdf"
>> >    val file = File(fileName)
>> >
>> >    val document = Loader.loadPDF(bytes)
>> >    document.save(fileName)
>> >
>> >    // This returns a ValidationError
>> >    val result = PreflightParser.validate(file)
>> >
>> >     return result.isValid
>> > }
>> >
>> > The tested PDFs are the same as before the upgrade.
>> >
>> >
>> >
>> > ᐧ
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
>> For additional commands, e-mail: users-h...@pdfbox.apache.org
>>
>>

Reply via email to