You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Gabriel Madeira Pessoa <ga...@bry.com.br> on 2018/03/22 17:58:32 UTC

Error signing document with reference table stream

Hello everyone,

While trying to sign PDFs created from many different sources we found 
an unusual behavior with files generated with iText (older versions up 
until 7.1.1) when they are created with full compression enabled (that 
creates the xref table as a stream).

iText does not add the the reference for the object of the xref table 
inside the own table. That way, when signing with PDFBox (2.0.7, 2.0.8 
and even 2.0.9 that I saw had its tagged created on github) 
COSWriter.prepareIncrement does not know that the number of objects is 
actually one higher than it had found, so the first entry on the 
signature revision has the same number that the xref table on the 
previous revision.

With invisible signatures that does not looks like a problem, but when 
we have a visible signature, the image does not show in in Microsoft 
Edge or Google Chrome.

PDFBox can get the actual highest number on PDFs created with xref table 
stream that have its own reference inside.

I'm actually in doubt which on is the correct table, with or without a 
reference its own dictionary object.

For a PDF that the table contains the reference we used the one from 
PDFBOX-3198 just removing the signature (or use it as it is on the 
ticket, because the image shows up on browsers).

To create a iText PDF with xref table as stream just run:

WriterProperties properties = new WriterProperties();
properties.setFullCompressionMode(true);
PdfWriter writer = new PdfWriter("doc.pdf", properties);
PdfDocument pdf = new PdfDocument(writer);
Document document = new Document(pdf);
document.add(new Paragraph("Hello World!"));
document.close();

Thank you guys very much.
-- 
Atenciosamente,

Gabriel Pessoa
Analista
BRy Tecnologia
Rua Lauro Linhares, 2123 Torre B - 3º andar
88036-002 - Florianópolis - SC - Brasil
+55 (48) 3234 6696

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Error signing document with reference table stream

Posted by Tilman Hausherr <TH...@t-online.de>.
Thanks, now I understand what you meant earlier.

We don't store the object number of the XRef stream. 
(COSParser.parseXrefObjStream()). This makes sense because this is 
recreated when doing a classic save.

My first thought was to add 1 to the highest number, but this doesn't 
work because there is no guarantee that the object number of the XRef 
stream is the highest. (Seen in 007087-payment-due-p1_reduced_bc0.pdf)

Analyzing the last trailer (/Index and /Size) doesn't help either, it is 
unclear which trailer is taken.

So my current thought is to have COSParser.parseXrefObjStream() store 
the highest XRef object key number in the COSDocument object and check 
it later.

I'll investigate wether the troubles in 
https://issues.apache.org/jira/browse/PDFBOX-3631 are the same problem.

Tilman

Am 26.03.2018 um 13:38 schrieb Gabriel Madeira Pessoa:
> Sorry again for incomplete information about the problem.
>
> When I ran the CreateVisibleSignature example I ran it without setting 
> the Perms dictionary. Without it, the annotation for the visible 
> signature becomes the object "8 0", the same as xref object from the 
> previous revision. With Perms "on" they get to be "8 0" and the 
> annotation goes to a "valid" number and the browser can show it.
>
> Em 23/03/2018 18:12, Tilman Hausherr escreveu:
>> Am 23.03.2018 um 21:22 schrieb Gabriel Madeira Pessoa:
>>> Sorry I was not very clear.
>>>
>>> - iText 7.1.1 included, the code I sent was tested with that version.
>>>
>>> - PDFBOX-3917_signed.pdf
>>
>> Thanks... both work with edge and with the google drive pdf viewer on
>> my phone. I used the trunk to create the signatures. Can you display
>> them?
>>
>> http://home.snafu.de/tilman/tmp/PDFBOX-3917_signed.pdf
>>
>> http://home.snafu.de/tilman/tmp/itext-doc_signed.pdf
>>
>> If no, then the problem is on your side...
>>
>> If yes, then I should retry with 2.0.9.
>>
>> Tilman
>>
>>>
>>> Em 23/03/2018 16:49, Tilman Hausherr escreveu:
>>>> Am 22.03.2018 um 18:58 schrieb Gabriel Madeira Pessoa:
>>>>> Hello everyone,
>>>>>
>>>>> While trying to sign PDFs created from many different sources we 
>>>>> found an unusual behavior with files generated with iText (older 
>>>>> versions up until 7.1.1) when they are created with full 
>>>>> compression enabled (that creates the xref table as a stream).
>>>>
>>>> "older versions up until 7.1.1" - do you mean including 7.1.1 or
>>>> except 7.1.1 ? Because 7.1.1 is the latest version.
>>>> http://mvnrepository.com/artifact/com.itextpdf/itext7-core
>>>>
>>>>
>>>>>
>>>>> iText does not add the the reference for the object of the xref 
>>>>> table inside the own table. That way, when signing with PDFBox 
>>>>> (2.0.7, 2.0.8 and even 2.0.9 that I saw had its tagged created on 
>>>>> github) COSWriter.prepareIncrement does not know that the number 
>>>>> of objects is actually one higher than it had found, so the first 
>>>>> entry on the signature revision has the same number that the xref 
>>>>> table on the previous revision.
>>>>>
>>>>> With invisible signatures that does not looks like a problem, but 
>>>>> when we have a visible signature, the image does not show in in 
>>>>> Microsoft Edge or Google Chrome.
>>>>>
>>>>> PDFBox can get the actual highest number on PDFs created with xref 
>>>>> table stream that have its own reference inside.
>>>>>
>>>>> I'm actually in doubt which on is the correct table, with or 
>>>>> without a reference its own dictionary object.
>>>>>
>>>>> For a PDF that the table contains the reference we used the one 
>>>>> from PDFBOX-3198 just removing the signature (or use it as it is 
>>>>> on the ticket, because the image shows up on browsers).
>>>>
>>>> PDFBOX-3198 has several PDFs. Which one do you mean?
>>>>
>>>>>
>>>>> To create a iText PDF with xref table as stream just run:
>>>>>
>>>>> WriterProperties properties = new WriterProperties();
>>>>> properties.setFullCompressionMode(true);
>>>>> PdfWriter writer = new PdfWriter("doc.pdf", properties);
>>>>> PdfDocument pdf = new PdfDocument(writer);
>>>>> Document document = new Document(pdf);
>>>>> document.add(new Paragraph("Hello World!"));
>>>>> document.close();
>>>>>
>>>>> Thank you guys very much.
>>>>
>>>>
>>>> Ok, I'll test this...
>>>>
>>>> I wonder if your problem is related to
>>>> https://issues.apache.org/jira/browse/PDFBOX-3631
>>>>
>>>> Tilman
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Error signing document with reference table stream

Posted by Gabriel Madeira Pessoa <ga...@bry.com.br>.
Hi, I tested with the files we have here that presented the problem and 
the signature is now visible on Chrome again :)

Thank you Tillman for the quick response!

Em 27/03/2018 17:43, Tilman Hausherr escreveu:
> Hi,
> 
> Snapshot available here:
> https://repository.apache.org/content/groups/snapshots/org/apache/pdfbox/pdfbox-app/2.0.10-SNAPSHOT/
> 
> Please test it and tell whether the problem goes away.
> 
> Tilman
> 
> Am 26.03.2018 um 13:38 schrieb Gabriel Madeira Pessoa:
>> Sorry again for incomplete information about the problem.
>> 
>> When I ran the CreateVisibleSignature example I ran it without setting 
>> the Perms dictionary. Without it, the annotation for the visible 
>> signature becomes the object "8 0", the same as xref object from the 
>> previous revision. With Perms "on" they get to be "8 0" and the 
>> annotation goes to a "valid" number and the browser can show it.
>> 
>> Em 23/03/2018 18:12, Tilman Hausherr escreveu:
>>> Am 23.03.2018 um 21:22 schrieb Gabriel Madeira Pessoa:
>>>> Sorry I was not very clear.
>>>> 
>>>> - iText 7.1.1 included, the code I sent was tested with that 
>>>> version.
>>>> 
>>>> - PDFBOX-3917_signed.pdf
>>> 
>>> Thanks... both work with edge and with the google drive pdf viewer on
>>> my phone. I used the trunk to create the signatures. Can you display
>>> them?
>>> 
>>> http://home.snafu.de/tilman/tmp/PDFBOX-3917_signed.pdf
>>> 
>>> http://home.snafu.de/tilman/tmp/itext-doc_signed.pdf
>>> 
>>> If no, then the problem is on your side...
>>> 
>>> If yes, then I should retry with 2.0.9.
>>> 
>>> Tilman
>>> 
>>>> 
>>>> Em 23/03/2018 16:49, Tilman Hausherr escreveu:
>>>>> Am 22.03.2018 um 18:58 schrieb Gabriel Madeira Pessoa:
>>>>>> Hello everyone,
>>>>>> 
>>>>>> While trying to sign PDFs created from many different sources we 
>>>>>> found an unusual behavior with files generated with iText (older 
>>>>>> versions up until 7.1.1) when they are created with full 
>>>>>> compression enabled (that creates the xref table as a stream).
>>>>> 
>>>>> "older versions up until 7.1.1" - do you mean including 7.1.1 or
>>>>> except 7.1.1 ? Because 7.1.1 is the latest version.
>>>>> http://mvnrepository.com/artifact/com.itextpdf/itext7-core
>>>>> 
>>>>> 
>>>>>> 
>>>>>> iText does not add the the reference for the object of the xref 
>>>>>> table inside the own table. That way, when signing with PDFBox 
>>>>>> (2.0.7, 2.0.8 and even 2.0.9 that I saw had its tagged created on 
>>>>>> github) COSWriter.prepareIncrement does not know that the number 
>>>>>> of objects is actually one higher than it had found, so the first 
>>>>>> entry on the signature revision has the same number that the xref 
>>>>>> table on the previous revision.
>>>>>> 
>>>>>> With invisible signatures that does not looks like a problem, but 
>>>>>> when we have a visible signature, the image does not show in in 
>>>>>> Microsoft Edge or Google Chrome.
>>>>>> 
>>>>>> PDFBox can get the actual highest number on PDFs created with xref 
>>>>>> table stream that have its own reference inside.
>>>>>> 
>>>>>> I'm actually in doubt which on is the correct table, with or 
>>>>>> without a reference its own dictionary object.
>>>>>> 
>>>>>> For a PDF that the table contains the reference we used the one 
>>>>>> from PDFBOX-3198 just removing the signature (or use it as it is 
>>>>>> on the ticket, because the image shows up on browsers).
>>>>> 
>>>>> PDFBOX-3198 has several PDFs. Which one do you mean?
>>>>> 
>>>>>> 
>>>>>> To create a iText PDF with xref table as stream just run:
>>>>>> 
>>>>>> WriterProperties properties = new WriterProperties();
>>>>>> properties.setFullCompressionMode(true);
>>>>>> PdfWriter writer = new PdfWriter("doc.pdf", properties);
>>>>>> PdfDocument pdf = new PdfDocument(writer);
>>>>>> Document document = new Document(pdf);
>>>>>> document.add(new Paragraph("Hello World!"));
>>>>>> document.close();
>>>>>> 
>>>>>> Thank you guys very much.
>>>>> 
>>>>> 
>>>>> Ok, I'll test this...
>>>>> 
>>>>> I wonder if your problem is related to
>>>>> https://issues.apache.org/jira/browse/PDFBOX-3631
>>>>> 
>>>>> Tilman
>>>>> 
>>>>> 
>>>>> 
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>> 
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org

-- 
Atenciosamente,

Gabriel Pessoa
Analista
BRy Tecnologia
Rua Lauro Linhares, 2123 Torre B - 3º andar
88036-002 - Florianópolis - SC - Brasil
+55 (48) 3234 6696

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Error signing document with reference table stream

Posted by Tilman Hausherr <TH...@t-online.de>.
Hi,

Snapshot available here:
https://repository.apache.org/content/groups/snapshots/org/apache/pdfbox/pdfbox-app/2.0.10-SNAPSHOT/

Please test it and tell whether the problem goes away.

Tilman

Am 26.03.2018 um 13:38 schrieb Gabriel Madeira Pessoa:
> Sorry again for incomplete information about the problem.
>
> When I ran the CreateVisibleSignature example I ran it without setting 
> the Perms dictionary. Without it, the annotation for the visible 
> signature becomes the object "8 0", the same as xref object from the 
> previous revision. With Perms "on" they get to be "8 0" and the 
> annotation goes to a "valid" number and the browser can show it.
>
> Em 23/03/2018 18:12, Tilman Hausherr escreveu:
>> Am 23.03.2018 um 21:22 schrieb Gabriel Madeira Pessoa:
>>> Sorry I was not very clear.
>>>
>>> - iText 7.1.1 included, the code I sent was tested with that version.
>>>
>>> - PDFBOX-3917_signed.pdf
>>
>> Thanks... both work with edge and with the google drive pdf viewer on
>> my phone. I used the trunk to create the signatures. Can you display
>> them?
>>
>> http://home.snafu.de/tilman/tmp/PDFBOX-3917_signed.pdf
>>
>> http://home.snafu.de/tilman/tmp/itext-doc_signed.pdf
>>
>> If no, then the problem is on your side...
>>
>> If yes, then I should retry with 2.0.9.
>>
>> Tilman
>>
>>>
>>> Em 23/03/2018 16:49, Tilman Hausherr escreveu:
>>>> Am 22.03.2018 um 18:58 schrieb Gabriel Madeira Pessoa:
>>>>> Hello everyone,
>>>>>
>>>>> While trying to sign PDFs created from many different sources we 
>>>>> found an unusual behavior with files generated with iText (older 
>>>>> versions up until 7.1.1) when they are created with full 
>>>>> compression enabled (that creates the xref table as a stream).
>>>>
>>>> "older versions up until 7.1.1" - do you mean including 7.1.1 or
>>>> except 7.1.1 ? Because 7.1.1 is the latest version.
>>>> http://mvnrepository.com/artifact/com.itextpdf/itext7-core
>>>>
>>>>
>>>>>
>>>>> iText does not add the the reference for the object of the xref 
>>>>> table inside the own table. That way, when signing with PDFBox 
>>>>> (2.0.7, 2.0.8 and even 2.0.9 that I saw had its tagged created on 
>>>>> github) COSWriter.prepareIncrement does not know that the number 
>>>>> of objects is actually one higher than it had found, so the first 
>>>>> entry on the signature revision has the same number that the xref 
>>>>> table on the previous revision.
>>>>>
>>>>> With invisible signatures that does not looks like a problem, but 
>>>>> when we have a visible signature, the image does not show in in 
>>>>> Microsoft Edge or Google Chrome.
>>>>>
>>>>> PDFBox can get the actual highest number on PDFs created with xref 
>>>>> table stream that have its own reference inside.
>>>>>
>>>>> I'm actually in doubt which on is the correct table, with or 
>>>>> without a reference its own dictionary object.
>>>>>
>>>>> For a PDF that the table contains the reference we used the one 
>>>>> from PDFBOX-3198 just removing the signature (or use it as it is 
>>>>> on the ticket, because the image shows up on browsers).
>>>>
>>>> PDFBOX-3198 has several PDFs. Which one do you mean?
>>>>
>>>>>
>>>>> To create a iText PDF with xref table as stream just run:
>>>>>
>>>>> WriterProperties properties = new WriterProperties();
>>>>> properties.setFullCompressionMode(true);
>>>>> PdfWriter writer = new PdfWriter("doc.pdf", properties);
>>>>> PdfDocument pdf = new PdfDocument(writer);
>>>>> Document document = new Document(pdf);
>>>>> document.add(new Paragraph("Hello World!"));
>>>>> document.close();
>>>>>
>>>>> Thank you guys very much.
>>>>
>>>>
>>>> Ok, I'll test this...
>>>>
>>>> I wonder if your problem is related to
>>>> https://issues.apache.org/jira/browse/PDFBOX-3631
>>>>
>>>> Tilman
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Error signing document with reference table stream

Posted by Gabriel Madeira Pessoa <ga...@bry.com.br>.
Sorry again for incomplete information about the problem.

When I ran the CreateVisibleSignature example I ran it without setting 
the Perms dictionary. Without it, the annotation for the visible 
signature becomes the object "8 0", the same as xref object from the 
previous revision. With Perms "on" they get to be "8 0" and the 
annotation goes to a "valid" number and the browser can show it.

Em 23/03/2018 18:12, Tilman Hausherr escreveu:
> Am 23.03.2018 um 21:22 schrieb Gabriel Madeira Pessoa:
>> Sorry I was not very clear.
>> 
>> - iText 7.1.1 included, the code I sent was tested with that version.
>> 
>> - PDFBOX-3917_signed.pdf
> 
> Thanks... both work with edge and with the google drive pdf viewer on
> my phone. I used the trunk to create the signatures. Can you display
> them?
> 
> http://home.snafu.de/tilman/tmp/PDFBOX-3917_signed.pdf
> 
> http://home.snafu.de/tilman/tmp/itext-doc_signed.pdf
> 
> If no, then the problem is on your side...
> 
> If yes, then I should retry with 2.0.9.
> 
> Tilman
> 
>> 
>> Em 23/03/2018 16:49, Tilman Hausherr escreveu:
>>> Am 22.03.2018 um 18:58 schrieb Gabriel Madeira Pessoa:
>>>> Hello everyone,
>>>> 
>>>> While trying to sign PDFs created from many different sources we 
>>>> found an unusual behavior with files generated with iText (older 
>>>> versions up until 7.1.1) when they are created with full compression 
>>>> enabled (that creates the xref table as a stream).
>>> 
>>> "older versions up until 7.1.1" - do you mean including 7.1.1 or
>>> except 7.1.1 ? Because 7.1.1 is the latest version.
>>> http://mvnrepository.com/artifact/com.itextpdf/itext7-core
>>> 
>>> 
>>>> 
>>>> iText does not add the the reference for the object of the xref 
>>>> table inside the own table. That way, when signing with PDFBox 
>>>> (2.0.7, 2.0.8 and even 2.0.9 that I saw had its tagged created on 
>>>> github) COSWriter.prepareIncrement does not know that the number of 
>>>> objects is actually one higher than it had found, so the first entry 
>>>> on the signature revision has the same number that the xref table on 
>>>> the previous revision.
>>>> 
>>>> With invisible signatures that does not looks like a problem, but 
>>>> when we have a visible signature, the image does not show in in 
>>>> Microsoft Edge or Google Chrome.
>>>> 
>>>> PDFBox can get the actual highest number on PDFs created with xref 
>>>> table stream that have its own reference inside.
>>>> 
>>>> I'm actually in doubt which on is the correct table, with or without 
>>>> a reference its own dictionary object.
>>>> 
>>>> For a PDF that the table contains the reference we used the one from 
>>>> PDFBOX-3198 just removing the signature (or use it as it is on the 
>>>> ticket, because the image shows up on browsers).
>>> 
>>> PDFBOX-3198 has several PDFs. Which one do you mean?
>>> 
>>>> 
>>>> To create a iText PDF with xref table as stream just run:
>>>> 
>>>> WriterProperties properties = new WriterProperties();
>>>> properties.setFullCompressionMode(true);
>>>> PdfWriter writer = new PdfWriter("doc.pdf", properties);
>>>> PdfDocument pdf = new PdfDocument(writer);
>>>> Document document = new Document(pdf);
>>>> document.add(new Paragraph("Hello World!"));
>>>> document.close();
>>>> 
>>>> Thank you guys very much.
>>> 
>>> 
>>> Ok, I'll test this...
>>> 
>>> I wonder if your problem is related to
>>> https://issues.apache.org/jira/browse/PDFBOX-3631
>>> 
>>> Tilman
>>> 
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org

-- 
Atenciosamente,

Gabriel Pessoa
Analista
BRy Tecnologia
Rua Lauro Linhares, 2123 Torre B - 3º andar
88036-002 - Florianópolis - SC - Brasil
+55 (48) 3234 6696

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Error signing document with reference table stream

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 23.03.2018 um 21:22 schrieb Gabriel Madeira Pessoa:
> Sorry I was not very clear.
>
> - iText 7.1.1 included, the code I sent was tested with that version.
>
> - PDFBOX-3917_signed.pdf

Thanks... both work with edge and with the google drive pdf viewer on my 
phone. I used the trunk to create the signatures. Can you display them?

http://home.snafu.de/tilman/tmp/PDFBOX-3917_signed.pdf

http://home.snafu.de/tilman/tmp/itext-doc_signed.pdf

If no, then the problem is on your side...

If yes, then I should retry with 2.0.9.

Tilman

>
> Em 23/03/2018 16:49, Tilman Hausherr escreveu:
>> Am 22.03.2018 um 18:58 schrieb Gabriel Madeira Pessoa:
>>> Hello everyone,
>>>
>>> While trying to sign PDFs created from many different sources we 
>>> found an unusual behavior with files generated with iText (older 
>>> versions up until 7.1.1) when they are created with full compression 
>>> enabled (that creates the xref table as a stream).
>>
>> "older versions up until 7.1.1" - do you mean including 7.1.1 or
>> except 7.1.1 ? Because 7.1.1 is the latest version.
>> http://mvnrepository.com/artifact/com.itextpdf/itext7-core
>>
>>
>>>
>>> iText does not add the the reference for the object of the xref 
>>> table inside the own table. That way, when signing with PDFBox 
>>> (2.0.7, 2.0.8 and even 2.0.9 that I saw had its tagged created on 
>>> github) COSWriter.prepareIncrement does not know that the number of 
>>> objects is actually one higher than it had found, so the first entry 
>>> on the signature revision has the same number that the xref table on 
>>> the previous revision.
>>>
>>> With invisible signatures that does not looks like a problem, but 
>>> when we have a visible signature, the image does not show in in 
>>> Microsoft Edge or Google Chrome.
>>>
>>> PDFBox can get the actual highest number on PDFs created with xref 
>>> table stream that have its own reference inside.
>>>
>>> I'm actually in doubt which on is the correct table, with or without 
>>> a reference its own dictionary object.
>>>
>>> For a PDF that the table contains the reference we used the one from 
>>> PDFBOX-3198 just removing the signature (or use it as it is on the 
>>> ticket, because the image shows up on browsers).
>>
>> PDFBOX-3198 has several PDFs. Which one do you mean?
>>
>>>
>>> To create a iText PDF with xref table as stream just run:
>>>
>>> WriterProperties properties = new WriterProperties();
>>> properties.setFullCompressionMode(true);
>>> PdfWriter writer = new PdfWriter("doc.pdf", properties);
>>> PdfDocument pdf = new PdfDocument(writer);
>>> Document document = new Document(pdf);
>>> document.add(new Paragraph("Hello World!"));
>>> document.close();
>>>
>>> Thank you guys very much.
>>
>>
>> Ok, I'll test this...
>>
>> I wonder if your problem is related to
>> https://issues.apache.org/jira/browse/PDFBOX-3631
>>
>> Tilman
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Error signing document with reference table stream

Posted by Gabriel Madeira Pessoa <ga...@bry.com.br>.
Sorry I was not very clear.

- iText 7.1.1 included, the code I sent was tested with that version.

- PDFBOX-3917_signed.pdf

Em 23/03/2018 16:49, Tilman Hausherr escreveu:
> Am 22.03.2018 um 18:58 schrieb Gabriel Madeira Pessoa:
>> Hello everyone,
>> 
>> While trying to sign PDFs created from many different sources we found 
>> an unusual behavior with files generated with iText (older versions up 
>> until 7.1.1) when they are created with full compression enabled (that 
>> creates the xref table as a stream).
> 
> "older versions up until 7.1.1" - do you mean including 7.1.1 or
> except 7.1.1 ? Because 7.1.1 is the latest version.
> http://mvnrepository.com/artifact/com.itextpdf/itext7-core
> 
> 
>> 
>> iText does not add the the reference for the object of the xref table 
>> inside the own table. That way, when signing with PDFBox (2.0.7, 2.0.8 
>> and even 2.0.9 that I saw had its tagged created on github) 
>> COSWriter.prepareIncrement does not know that the number of objects is 
>> actually one higher than it had found, so the first entry on the 
>> signature revision has the same number that the xref table on the 
>> previous revision.
>> 
>> With invisible signatures that does not looks like a problem, but when 
>> we have a visible signature, the image does not show in in Microsoft 
>> Edge or Google Chrome.
>> 
>> PDFBox can get the actual highest number on PDFs created with xref 
>> table stream that have its own reference inside.
>> 
>> I'm actually in doubt which on is the correct table, with or without a 
>> reference its own dictionary object.
>> 
>> For a PDF that the table contains the reference we used the one from 
>> PDFBOX-3198 just removing the signature (or use it as it is on the 
>> ticket, because the image shows up on browsers).
> 
> PDFBOX-3198 has several PDFs. Which one do you mean?
> 
>> 
>> To create a iText PDF with xref table as stream just run:
>> 
>> WriterProperties properties = new WriterProperties();
>> properties.setFullCompressionMode(true);
>> PdfWriter writer = new PdfWriter("doc.pdf", properties);
>> PdfDocument pdf = new PdfDocument(writer);
>> Document document = new Document(pdf);
>> document.add(new Paragraph("Hello World!"));
>> document.close();
>> 
>> Thank you guys very much.
> 
> 
> Ok, I'll test this...
> 
> I wonder if your problem is related to
> https://issues.apache.org/jira/browse/PDFBOX-3631
> 
> Tilman
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org

-- 
Atenciosamente,

Gabriel Pessoa
Analista
BRy Tecnologia
Rua Lauro Linhares, 2123 Torre B - 3º andar
88036-002 - Florianópolis - SC - Brasil
+55 (48) 3234 6696

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Error signing document with reference table stream

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 22.03.2018 um 18:58 schrieb Gabriel Madeira Pessoa:
> Hello everyone,
>
> While trying to sign PDFs created from many different sources we found 
> an unusual behavior with files generated with iText (older versions up 
> until 7.1.1) when they are created with full compression enabled (that 
> creates the xref table as a stream).

"older versions up until 7.1.1" - do you mean including 7.1.1 or except 
7.1.1 ? Because 7.1.1 is the latest version.
http://mvnrepository.com/artifact/com.itextpdf/itext7-core


>
> iText does not add the the reference for the object of the xref table 
> inside the own table. That way, when signing with PDFBox (2.0.7, 2.0.8 
> and even 2.0.9 that I saw had its tagged created on github) 
> COSWriter.prepareIncrement does not know that the number of objects is 
> actually one higher than it had found, so the first entry on the 
> signature revision has the same number that the xref table on the 
> previous revision.
>
> With invisible signatures that does not looks like a problem, but when 
> we have a visible signature, the image does not show in in Microsoft 
> Edge or Google Chrome.
>
> PDFBox can get the actual highest number on PDFs created with xref 
> table stream that have its own reference inside.
>
> I'm actually in doubt which on is the correct table, with or without a 
> reference its own dictionary object.
>
> For a PDF that the table contains the reference we used the one from 
> PDFBOX-3198 just removing the signature (or use it as it is on the 
> ticket, because the image shows up on browsers).

PDFBOX-3198 has several PDFs. Which one do you mean?

>
> To create a iText PDF with xref table as stream just run:
>
> WriterProperties properties = new WriterProperties();
> properties.setFullCompressionMode(true);
> PdfWriter writer = new PdfWriter("doc.pdf", properties);
> PdfDocument pdf = new PdfDocument(writer);
> Document document = new Document(pdf);
> document.add(new Paragraph("Hello World!"));
> document.close();
>
> Thank you guys very much.


Ok, I'll test this...

I wonder if your problem is related to
https://issues.apache.org/jira/browse/PDFBOX-3631

Tilman



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org