[ 
https://issues.apache.org/jira/browse/PDFBOX-4249?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16520761#comment-16520761
 ] 

Xin Lin edited comment on PDFBOX-4249 at 6/22/18 8:54 PM:
----------------------------------------------------------

When flattening  [^barcode.pdf] with just a single barcode field using PDFBox 
2.0.9, the barcode field in the flattened file  [^barcode flattened.pdf] is at 
the lower left corner of the page.
I traced it to line 308 in PDAcroForm.java:
{code:java}
 boolean needsTranslation = resolveNeedsTranslation(appearanceStream);
{code}
If I change that to 
{code:java}
 boolean needsTranslation = true;
{code}
The field will appear in the correct position. 

In the method resolveNeedsTranslation starting from line 748

{code:java}
 if (xObject instanceof PDFormXObject)
                    {
                        PDRectangle bbox = ((PDFormXObject)xObject).getBBox();
                        float llX = bbox.getLowerLeftX();
                        float llY = bbox.getLowerLeftY();
                        if (llX == 0 && llY == 0)
                        {
                            needsTranslation = true;
                        }
                    }
{code}
The xObject in this case is an instance of PDImageXObject instead of 
PDFormXObject, therefore, the 'if' condition in this case will be false and 
therefore resolveNeedsTranslation() will always return false as well. I think 
it should always return true when in doubt.



was (Author: xin.lin):
When flattening  [^barcode.pdf] with just a single barcode field using PDFBox 
2.0.9, the barcode field in the flattened file  [^barcode flattened.pdf] is at 
the lower left corner of the page.
I traced it to line 308 in PDAcroForm.java:
{code:java}
 boolean needsTranslation = resolveNeedsTranslation(appearanceStream);
{code}
If I change that to 
{code:java}
 boolean needsTranslation = true;
{code}
The field will appear in the correct position. 

In the method resolveNeedsTranslation starting from line 748

{code:java}
 if (xObject instanceof PDFormXObject)
                    {
                        PDRectangle bbox = ((PDFormXObject)xObject).getBBox();
                        float llX = bbox.getLowerLeftX();
                        float llY = bbox.getLowerLeftY();
                        if (llX == 0 && llY == 0)
                        {
                            needsTranslation = true;
                        }
                    }
{code}
The xObject in this case is an instance of PDImageXObject instead of 
PDFormXObject, therefore, resolveNeedsTranslation() in this case will always 
return false.


> After flattening, barcode fields are always at the lower left corner of the 
> page
> --------------------------------------------------------------------------------
>
>                 Key: PDFBOX-4249
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4249
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 2.0.9
>            Reporter: Xin Lin
>            Priority: Major
>         Attachments: barcode flattened.pdf, barcode.pdf
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to