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 Pessoa <ga...@bry.com.br> on 2017/11/14 11:50:22 UTC

Re: Signature image not printing on Chrome

As a follow up to this question we created similar signatures with Adobe 
Reader and iText (both the latest versions, both able to print the 
signature image on Chrome) and inspected the generated PDFs.

Looking at the AP dictionary I noticed that both write the BBox for the 
/N, /FRM and /img dictionaries different than PDFBox.

For the /N and /FRM they both write [0, 0, width, height] the values 
being those from the rectangle where the image is set. For /img they 
calculate the scale factor relative between the image original size and 
the rectangle size.

PDFBox uses by default for all three [100, 50, 0, 0] and that can be 
changed with PDVisibleSignDesigner.formatterRectangleParams(byte[]).

Using that method (but passing 127 for width, because when i used 128 it 
wrote -128 on the PDF), the image was sucessfully printed from Chrome, 
although it does not fit the whole space, I believe because of the line 
"String imgFormContent    = "q " + 100 + " 0 0 50 0 0 cm /" + 
imageName.getName() + " Do Q\n";" in 
PDVisibleSigBuilder.injectAppearanceStreams.

And just to pinpoint the exact BBox, i downloaded PDFBox from 2.0.9 
-SNAPSHOT and changed the code so that only the BBox from 
PDFTemplateBuilder.createHolderForm receives the value set in 
formatterRectangleParams(byte[]) and I was able to print the signature 
image.

I'm curious why PDFBox uses [100, 50, 0, 0] as the BBox, because for 
what i understood according to the PDF spec is that it represents the 
lower left (in this case x=100, y=50) and upper right corners (x=0, y=0) 
of what is being drawn.

The original and signed files that i used for this can be found at: 
https://drive.google.com/open?id=0B2hR5R90BDFQZzkwSHEzTVEwSDQ

Em 27/10/2017 17:15, Tilman Hausherr escreveu:
> it's a known problem in chrome:
> https://bugs.chromium.org/p/pdfium/issues/detail?id=643
>
> it's a known problem in firefox:
> https://github.com/mozilla/pdf.js/issues/4743
>
> Tilman
>
> Am 27.10.2017 um 21:02 schrieb Gabriel Pessoa:
>> Just to clarify, the problem was detected with a client that prefers 
>> to download and print their signed PDFs directly from Chrome.
>>
>> On Edge the image is printed no problem and Firefox is the same as 
>> Chrome.
>>
>>
>> Em 27/10/2017 16:57, Gabriel Pessoa escreveu:
>>> Hello everyone I have a problem that is bugging me for the last 
>>> couple of days.
>>>
>>> When we sign any PDF with a image associated and then we open the 
>>> signed PDF on Chrome and try to print from it, the image does not 
>>> appears.
>>>
>>> I tried PDFs generated with the HelloWorld example, exported from 
>>> Word, BIRT Report Engine and AsposePdf and the result was the same. 
>>> We have applications running PDFBox 1.8.13 (legacy, soon to be 
>>> discontinued) and 2.0.7, and in both the situation occurs.
>>>
>>> It is possible to replicate the problem with the example for visual 
>>> signature on the example directory. In any case the original file 
>>> and the signed one can be found here: 
>>> https://drive.google.com/open?id=0B2hR5R90BDFQZzkwSHEzTVEwSDQ
>>>
>>> Thanks in advance for any help that you guys can give.
>>>
>>> Att,
>>>
>>> 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
>>>
>>
>
>
> ---------------------------------------------------------------------
> 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: Signature image not printing on Chrome

Posted by Tilman Hausherr <TH...@t-online.de>.
https://issues.apache.org/jira/browse/PDFBOX-4011

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


Re: Signature image not printing on Chrome

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

Thank you for investigating this! I like people who dig deep.

What you discovered is indeed a bug and we (this includes me) missed it. 
Yes, in the specification bbox is defined as minX, minY, maxX, maxY: "An 
array of four numbers in the form coordinate system, giving the 
coordinates of the left, bottom, right, and top edges, respectively, of 
the form XObject’s bounding box. These boundaries shall be used to clip 
the form XObject and to determine its size for caching."

I'll change the code to make it more flexible and also create a method 
that uses an int array and deprecate the current one.

     @Override
     public void createFormatterRectangle(int[] params)
     {
         PDRectangle formatterRectangle = new PDRectangle();
formatterRectangle.setLowerLeftX(Math.min(params[0],params[2]));
formatterRectangle.setLowerLeftY(Math.min(params[1],params[3]));
formatterRectangle.setUpperRightX(Math.max(params[0],params[2]));
formatterRectangle.setUpperRightY(Math.max(params[1],params[3]));

         pdfStructure.setFormatterRectangle(formatterRectangle);
         LOG.info("Formatter rectangle has been created");
     }


Tilman

Am 14.11.2017 um 12:50 schrieb Gabriel Pessoa:
> As a follow up to this question we created similar signatures with 
> Adobe Reader and iText (both the latest versions, both able to print 
> the signature image on Chrome) and inspected the generated PDFs.
>
> Looking at the AP dictionary I noticed that both write the BBox for 
> the /N, /FRM and /img dictionaries different than PDFBox.
>
> For the /N and /FRM they both write [0, 0, width, height] the values 
> being those from the rectangle where the image is set. For /img they 
> calculate the scale factor relative between the image original size 
> and the rectangle size.
>
> PDFBox uses by default for all three [100, 50, 0, 0] and that can be 
> changed with PDVisibleSignDesigner.formatterRectangleParams(byte[]).
>
> Using that method (but passing 127 for width, because when i used 128 
> it wrote -128 on the PDF), the image was sucessfully printed from 
> Chrome, although it does not fit the whole space, I believe because of 
> the line "String imgFormContent    = "q " + 100 + " 0 0 50 0 0 cm /" + 
> imageName.getName() + " Do Q\n";" in 
> PDVisibleSigBuilder.injectAppearanceStreams.
>
> And just to pinpoint the exact BBox, i downloaded PDFBox from 2.0.9 
> -SNAPSHOT and changed the code so that only the BBox from 
> PDFTemplateBuilder.createHolderForm receives the value set in 
> formatterRectangleParams(byte[]) and I was able to print the signature 
> image.
>
> I'm curious why PDFBox uses [100, 50, 0, 0] as the BBox, because for 
> what i understood according to the PDF spec is that it represents the 
> lower left (in this case x=100, y=50) and upper right corners (x=0, 
> y=0) of what is being drawn.
>
> The original and signed files that i used for this can be found at: 
> https://drive.google.com/open?id=0B2hR5R90BDFQZzkwSHEzTVEwSDQ
>
> Em 27/10/2017 17:15, Tilman Hausherr escreveu:
>> it's a known problem in chrome:
>> https://bugs.chromium.org/p/pdfium/issues/detail?id=643
>>
>> it's a known problem in firefox:
>> https://github.com/mozilla/pdf.js/issues/4743
>>
>> Tilman
>>
>> Am 27.10.2017 um 21:02 schrieb Gabriel Pessoa:
>>> Just to clarify, the problem was detected with a client that prefers 
>>> to download and print their signed PDFs directly from Chrome.
>>>
>>> On Edge the image is printed no problem and Firefox is the same as 
>>> Chrome.
>>>
>>>
>>> Em 27/10/2017 16:57, Gabriel Pessoa escreveu:
>>>> Hello everyone I have a problem that is bugging me for the last 
>>>> couple of days.
>>>>
>>>> When we sign any PDF with a image associated and then we open the 
>>>> signed PDF on Chrome and try to print from it, the image does not 
>>>> appears.
>>>>
>>>> I tried PDFs generated with the HelloWorld example, exported from 
>>>> Word, BIRT Report Engine and AsposePdf and the result was the same. 
>>>> We have applications running PDFBox 1.8.13 (legacy, soon to be 
>>>> discontinued) and 2.0.7, and in both the situation occurs.
>>>>
>>>> It is possible to replicate the problem with the example for visual 
>>>> signature on the example directory. In any case the original file 
>>>> and the signed one can be found here: 
>>>> https://drive.google.com/open?id=0B2hR5R90BDFQZzkwSHEzTVEwSDQ
>>>>
>>>> Thanks in advance for any help that you guys can give.
>>>>
>>>> Att,
>>>>
>>>> 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
>>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> 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