[jira] [Commented] (PDFBOX-4252) PDChoice related bugs and issues

2018-09-24 Thread Tilman Hausherr (JIRA)


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

Tilman Hausherr commented on PDFBOX-4252:
-

Yes, this would definitively be nice.

> PDChoice related bugs and issues
> 
>
> Key: PDFBOX-4252
> URL: https://issues.apache.org/jira/browse/PDFBOX-4252
> Project: PDFBox
>  Issue Type: Bug
>  Components: AcroForm
>Affects Versions: 2.0.10
>Reporter: Xin Lin
>Priority: Major
>  Labels: Appearance
> Attachments: test listbox and droplist export values.pdf, test 
> listbox_and_droplist export values flattened.pdf, top index 0 flattened.pdf, 
> top index 0 with index 4 set as selected.pdf, top index 0.pdf, top index 3.pdf
>
>
> There are several issues related to either PDListBox or PDComboBox that are 
> still not fixed in 2.0.10, I am going to put them in this one case, let me 
> know if they need to be broken into separate tickets. Thanks.
> 1. When I attempt to set value to a PDListBox whose 'Top Index' is greater 
> than 0 (as in [^top index 3.pdf]), I always receive the following exception:
> {noformat}
> java.lang.IllegalStateException: Error: You must call beginText() before 
> calling endText.
>   at 
> org.apache.pdfbox.pdmodel.PDPageContentStream.endText(PDPageContentStream.java:381)
>  ~[pdfbox-2.0.10.jar:2.0.10]
> ...
> {noformat}
> I tracked it down to a for loop at the end of the private method 
> insertGeneratedListboxAppearance in the class AppearanceGeneratorHelper:
> {code:java}
>  for (int i = topIndex; i < numOptions; i++)
> {
>
> if (i == topIndex)
> {
> yTextPos = yTextPos - font.getFontDescriptor().getAscent() / 
> FONTSCALE * fontSize;
> }
> else
> {
> yTextPos = yTextPos - font.getBoundingBox().getHeight() / 
> FONTSCALE * fontSize;
> contents.beginText();
> }
> contents.newLineAtOffset(contentRect.getLowerLeftX(), yTextPos);
> contents.showText(options.get(i));
> if (i - topIndex != (numOptions - 1))
> {
> contents.endText();
> }
> }
> {code}
> The last 'if' clause, when topIndex == 0, this makes sense, which is to NOT 
> call endText if we are at the last option because the private method 
> insertGeneratedAppearance which calls insertGeneratedListboxAppearance would 
> later call endText once again. If topIndex > 0, the condition in this 'if' 
> clause would always be true (since i can never be greater than numOptions - 
> 1), as a result, endText is called every time in this 'for' loop, so after 
> the method returns and the next endText is called, we receive the exception. 
> If I change that to
> {code:java}
>  if (i != (numOptions - 1))
> {
> contents.endText();
> }
> {code}
> things would start to work again.
> 2. a related issue, suppose I have a list box with top index equals to 0 and 
> too many options for the list box to show all of them at once (as in [^top 
> index 0.pdf]). When I select an option that is not visible with a top index 
> of 0 (in order to see it, we need to scroll the list box down), unlike 
> Acrobat which would adjust the top index so the selected option would be 
> visible, PDFBox does not recalculate the top index and would stick with the 
> initial value of 0. I suppose, If we fix item #1 above (i.e. top index 
> greater than 0), the opposite would also be true (if top index is say 6 and 
> you select the first item which is not visible unless you scroll the list box 
> up). This would make it useless if I flatten the document since there is no 
> way I can see the selected option (see  [^top index 0 flattened.pdf]). It is 
> also next to impossible to see the selected option even if I do not flatten 
> it (see  [^top index 0 with index 4 set as selected.pdf]). I would expect 
> PDFBox to recalculate the top index so that at least the first selected 
> option is visible (if there are additional selected options, show more 
> options when possible)
> 3. When flattening, drop down list or PDComboBox with options that have 
> export values only shows the export values instead of the label. This not a 
> problem for the list box. (e.g. form:  [^test listbox and droplist export 
> values.pdf], after flattening:  [^test listbox_and_droplist export values 
> flattened.pdf]). I would expect the drop down list to behave the same as list 
> box (i.e. when flattened, it should also show the label instead of the export 
> value.)



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

-
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org

[jira] [Commented] (PDFBOX-4252) PDChoice related bugs and issues

2018-09-24 Thread Maruan Sahyoun (JIRA)


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

Maruan Sahyoun commented on PDFBOX-4252:


AFAIK Acrobat advances the position so the first selected item is visible in 
case it wouldn't have been without the advancement (would need to verify this). 
So we should do the same.

[~tilman] Wouldn't it make sense to have individual appearance handlers for 
form elements. This way the code becomes more readable. Currently everything is 
interwoven and not very clean. We could introduce it step by step for 
individual widget types.

> PDChoice related bugs and issues
> 
>
> Key: PDFBOX-4252
> URL: https://issues.apache.org/jira/browse/PDFBOX-4252
> Project: PDFBox
>  Issue Type: Bug
>  Components: AcroForm
>Affects Versions: 2.0.10
>Reporter: Xin Lin
>Priority: Major
>  Labels: Appearance
> Attachments: test listbox and droplist export values.pdf, test 
> listbox_and_droplist export values flattened.pdf, top index 0 flattened.pdf, 
> top index 0 with index 4 set as selected.pdf, top index 0.pdf, top index 3.pdf
>
>
> There are several issues related to either PDListBox or PDComboBox that are 
> still not fixed in 2.0.10, I am going to put them in this one case, let me 
> know if they need to be broken into separate tickets. Thanks.
> 1. When I attempt to set value to a PDListBox whose 'Top Index' is greater 
> than 0 (as in [^top index 3.pdf]), I always receive the following exception:
> {noformat}
> java.lang.IllegalStateException: Error: You must call beginText() before 
> calling endText.
>   at 
> org.apache.pdfbox.pdmodel.PDPageContentStream.endText(PDPageContentStream.java:381)
>  ~[pdfbox-2.0.10.jar:2.0.10]
> ...
> {noformat}
> I tracked it down to a for loop at the end of the private method 
> insertGeneratedListboxAppearance in the class AppearanceGeneratorHelper:
> {code:java}
>  for (int i = topIndex; i < numOptions; i++)
> {
>
> if (i == topIndex)
> {
> yTextPos = yTextPos - font.getFontDescriptor().getAscent() / 
> FONTSCALE * fontSize;
> }
> else
> {
> yTextPos = yTextPos - font.getBoundingBox().getHeight() / 
> FONTSCALE * fontSize;
> contents.beginText();
> }
> contents.newLineAtOffset(contentRect.getLowerLeftX(), yTextPos);
> contents.showText(options.get(i));
> if (i - topIndex != (numOptions - 1))
> {
> contents.endText();
> }
> }
> {code}
> The last 'if' clause, when topIndex == 0, this makes sense, which is to NOT 
> call endText if we are at the last option because the private method 
> insertGeneratedAppearance which calls insertGeneratedListboxAppearance would 
> later call endText once again. If topIndex > 0, the condition in this 'if' 
> clause would always be true (since i can never be greater than numOptions - 
> 1), as a result, endText is called every time in this 'for' loop, so after 
> the method returns and the next endText is called, we receive the exception. 
> If I change that to
> {code:java}
>  if (i != (numOptions - 1))
> {
> contents.endText();
> }
> {code}
> things would start to work again.
> 2. a related issue, suppose I have a list box with top index equals to 0 and 
> too many options for the list box to show all of them at once (as in [^top 
> index 0.pdf]). When I select an option that is not visible with a top index 
> of 0 (in order to see it, we need to scroll the list box down), unlike 
> Acrobat which would adjust the top index so the selected option would be 
> visible, PDFBox does not recalculate the top index and would stick with the 
> initial value of 0. I suppose, If we fix item #1 above (i.e. top index 
> greater than 0), the opposite would also be true (if top index is say 6 and 
> you select the first item which is not visible unless you scroll the list box 
> up). This would make it useless if I flatten the document since there is no 
> way I can see the selected option (see  [^top index 0 flattened.pdf]). It is 
> also next to impossible to see the selected option even if I do not flatten 
> it (see  [^top index 0 with index 4 set as selected.pdf]). I would expect 
> PDFBox to recalculate the top index so that at least the first selected 
> option is visible (if there are additional selected options, show more 
> options when possible)
> 3. When flattening, drop down list or PDComboBox with options that have 
> export values only shows the export values instead of the label. This not a 
> problem for the list box. (e.g. form:  [^test listbox and droplist export 
> values.pdf], after flattening:  

[jira] [Commented] (PDFBOX-4252) PDChoice related bugs and issues

2018-09-24 Thread Tilman Hausherr (JIRA)


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

Tilman Hausherr commented on PDFBOX-4252:
-

Re (2), I wonder if it is needed to add logic into that: the user could easily 
decide to make the first selected the top value by calling {{setTopIndex()}}. 
If we do something ourselves, what should we do? Set the first selected 
visible? Or a strategy to change something only if no selected item is visible? 
Include it by default or as an extra method? Or just mention it in the javadoc?

> PDChoice related bugs and issues
> 
>
> Key: PDFBOX-4252
> URL: https://issues.apache.org/jira/browse/PDFBOX-4252
> Project: PDFBox
>  Issue Type: Bug
>  Components: AcroForm
>Affects Versions: 2.0.10
>Reporter: Xin Lin
>Priority: Major
>  Labels: Appearance
> Attachments: test listbox and droplist export values.pdf, test 
> listbox_and_droplist export values flattened.pdf, top index 0 flattened.pdf, 
> top index 0 with index 4 set as selected.pdf, top index 0.pdf, top index 3.pdf
>
>
> There are several issues related to either PDListBox or PDComboBox that are 
> still not fixed in 2.0.10, I am going to put them in this one case, let me 
> know if they need to be broken into separate tickets. Thanks.
> 1. When I attempt to set value to a PDListBox whose 'Top Index' is greater 
> than 0 (as in [^top index 3.pdf]), I always receive the following exception:
> {noformat}
> java.lang.IllegalStateException: Error: You must call beginText() before 
> calling endText.
>   at 
> org.apache.pdfbox.pdmodel.PDPageContentStream.endText(PDPageContentStream.java:381)
>  ~[pdfbox-2.0.10.jar:2.0.10]
> ...
> {noformat}
> I tracked it down to a for loop at the end of the private method 
> insertGeneratedListboxAppearance in the class AppearanceGeneratorHelper:
> {code:java}
>  for (int i = topIndex; i < numOptions; i++)
> {
>
> if (i == topIndex)
> {
> yTextPos = yTextPos - font.getFontDescriptor().getAscent() / 
> FONTSCALE * fontSize;
> }
> else
> {
> yTextPos = yTextPos - font.getBoundingBox().getHeight() / 
> FONTSCALE * fontSize;
> contents.beginText();
> }
> contents.newLineAtOffset(contentRect.getLowerLeftX(), yTextPos);
> contents.showText(options.get(i));
> if (i - topIndex != (numOptions - 1))
> {
> contents.endText();
> }
> }
> {code}
> The last 'if' clause, when topIndex == 0, this makes sense, which is to NOT 
> call endText if we are at the last option because the private method 
> insertGeneratedAppearance which calls insertGeneratedListboxAppearance would 
> later call endText once again. If topIndex > 0, the condition in this 'if' 
> clause would always be true (since i can never be greater than numOptions - 
> 1), as a result, endText is called every time in this 'for' loop, so after 
> the method returns and the next endText is called, we receive the exception. 
> If I change that to
> {code:java}
>  if (i != (numOptions - 1))
> {
> contents.endText();
> }
> {code}
> things would start to work again.
> 2. a related issue, suppose I have a list box with top index equals to 0 and 
> too many options for the list box to show all of them at once (as in [^top 
> index 0.pdf]). When I select an option that is not visible with a top index 
> of 0 (in order to see it, we need to scroll the list box down), unlike 
> Acrobat which would adjust the top index so the selected option would be 
> visible, PDFBox does not recalculate the top index and would stick with the 
> initial value of 0. I suppose, If we fix item #1 above (i.e. top index 
> greater than 0), the opposite would also be true (if top index is say 6 and 
> you select the first item which is not visible unless you scroll the list box 
> up). This would make it useless if I flatten the document since there is no 
> way I can see the selected option (see  [^top index 0 flattened.pdf]). It is 
> also next to impossible to see the selected option even if I do not flatten 
> it (see  [^top index 0 with index 4 set as selected.pdf]). I would expect 
> PDFBox to recalculate the top index so that at least the first selected 
> option is visible (if there are additional selected options, show more 
> options when possible)
> 3. When flattening, drop down list or PDComboBox with options that have 
> export values only shows the export values instead of the label. This not a 
> problem for the list box. (e.g. form:  [^test listbox and droplist export 
> values.pdf], after flattening:  [^test listbox_and_droplist export values 
> 

[jira] [Commented] (PDFBOX-4252) PDChoice related bugs and issues

2018-09-24 Thread ASF subversion and git services (JIRA)


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

ASF subversion and git services commented on PDFBOX-4252:
-

Commit 1841882 from til...@apache.org in branch 'pdfbox/trunk'
[ https://svn.apache.org/r1841882 ]

PDFBOX-4252: clarify name

> PDChoice related bugs and issues
> 
>
> Key: PDFBOX-4252
> URL: https://issues.apache.org/jira/browse/PDFBOX-4252
> Project: PDFBox
>  Issue Type: Bug
>  Components: AcroForm
>Affects Versions: 2.0.10
>Reporter: Xin Lin
>Priority: Major
>  Labels: Appearance
> Attachments: test listbox and droplist export values.pdf, test 
> listbox_and_droplist export values flattened.pdf, top index 0 flattened.pdf, 
> top index 0 with index 4 set as selected.pdf, top index 0.pdf, top index 3.pdf
>
>
> There are several issues related to either PDListBox or PDComboBox that are 
> still not fixed in 2.0.10, I am going to put them in this one case, let me 
> know if they need to be broken into separate tickets. Thanks.
> 1. When I attempt to set value to a PDListBox whose 'Top Index' is greater 
> than 0 (as in [^top index 3.pdf]), I always receive the following exception:
> {noformat}
> java.lang.IllegalStateException: Error: You must call beginText() before 
> calling endText.
>   at 
> org.apache.pdfbox.pdmodel.PDPageContentStream.endText(PDPageContentStream.java:381)
>  ~[pdfbox-2.0.10.jar:2.0.10]
> ...
> {noformat}
> I tracked it down to a for loop at the end of the private method 
> insertGeneratedListboxAppearance in the class AppearanceGeneratorHelper:
> {code:java}
>  for (int i = topIndex; i < numOptions; i++)
> {
>
> if (i == topIndex)
> {
> yTextPos = yTextPos - font.getFontDescriptor().getAscent() / 
> FONTSCALE * fontSize;
> }
> else
> {
> yTextPos = yTextPos - font.getBoundingBox().getHeight() / 
> FONTSCALE * fontSize;
> contents.beginText();
> }
> contents.newLineAtOffset(contentRect.getLowerLeftX(), yTextPos);
> contents.showText(options.get(i));
> if (i - topIndex != (numOptions - 1))
> {
> contents.endText();
> }
> }
> {code}
> The last 'if' clause, when topIndex == 0, this makes sense, which is to NOT 
> call endText if we are at the last option because the private method 
> insertGeneratedAppearance which calls insertGeneratedListboxAppearance would 
> later call endText once again. If topIndex > 0, the condition in this 'if' 
> clause would always be true (since i can never be greater than numOptions - 
> 1), as a result, endText is called every time in this 'for' loop, so after 
> the method returns and the next endText is called, we receive the exception. 
> If I change that to
> {code:java}
>  if (i != (numOptions - 1))
> {
> contents.endText();
> }
> {code}
> things would start to work again.
> 2. a related issue, suppose I have a list box with top index equals to 0 and 
> too many options for the list box to show all of them at once (as in [^top 
> index 0.pdf]). When I select an option that is not visible with a top index 
> of 0 (in order to see it, we need to scroll the list box down), unlike 
> Acrobat which would adjust the top index so the selected option would be 
> visible, PDFBox does not recalculate the top index and would stick with the 
> initial value of 0. I suppose, If we fix item #1 above (i.e. top index 
> greater than 0), the opposite would also be true (if top index is say 6 and 
> you select the first item which is not visible unless you scroll the list box 
> up). This would make it useless if I flatten the document since there is no 
> way I can see the selected option (see  [^top index 0 flattened.pdf]). It is 
> also next to impossible to see the selected option even if I do not flatten 
> it (see  [^top index 0 with index 4 set as selected.pdf]). I would expect 
> PDFBox to recalculate the top index so that at least the first selected 
> option is visible (if there are additional selected options, show more 
> options when possible)
> 3. When flattening, drop down list or PDComboBox with options that have 
> export values only shows the export values instead of the label. This not a 
> problem for the list box. (e.g. form:  [^test listbox and droplist export 
> values.pdf], after flattening:  [^test listbox_and_droplist export values 
> flattened.pdf]). I would expect the drop down list to behave the same as list 
> box (i.e. when flattened, it should also show the label instead of the export 
> value.)



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


[jira] [Commented] (PDFBOX-4252) PDChoice related bugs and issues

2018-09-24 Thread ASF subversion and git services (JIRA)


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

ASF subversion and git services commented on PDFBOX-4252:
-

Commit 1841883 from til...@apache.org in branch 'pdfbox/branches/2.0'
[ https://svn.apache.org/r1841883 ]

PDFBOX-4252: clarify name

> PDChoice related bugs and issues
> 
>
> Key: PDFBOX-4252
> URL: https://issues.apache.org/jira/browse/PDFBOX-4252
> Project: PDFBox
>  Issue Type: Bug
>  Components: AcroForm
>Affects Versions: 2.0.10
>Reporter: Xin Lin
>Priority: Major
>  Labels: Appearance
> Attachments: test listbox and droplist export values.pdf, test 
> listbox_and_droplist export values flattened.pdf, top index 0 flattened.pdf, 
> top index 0 with index 4 set as selected.pdf, top index 0.pdf, top index 3.pdf
>
>
> There are several issues related to either PDListBox or PDComboBox that are 
> still not fixed in 2.0.10, I am going to put them in this one case, let me 
> know if they need to be broken into separate tickets. Thanks.
> 1. When I attempt to set value to a PDListBox whose 'Top Index' is greater 
> than 0 (as in [^top index 3.pdf]), I always receive the following exception:
> {noformat}
> java.lang.IllegalStateException: Error: You must call beginText() before 
> calling endText.
>   at 
> org.apache.pdfbox.pdmodel.PDPageContentStream.endText(PDPageContentStream.java:381)
>  ~[pdfbox-2.0.10.jar:2.0.10]
> ...
> {noformat}
> I tracked it down to a for loop at the end of the private method 
> insertGeneratedListboxAppearance in the class AppearanceGeneratorHelper:
> {code:java}
>  for (int i = topIndex; i < numOptions; i++)
> {
>
> if (i == topIndex)
> {
> yTextPos = yTextPos - font.getFontDescriptor().getAscent() / 
> FONTSCALE * fontSize;
> }
> else
> {
> yTextPos = yTextPos - font.getBoundingBox().getHeight() / 
> FONTSCALE * fontSize;
> contents.beginText();
> }
> contents.newLineAtOffset(contentRect.getLowerLeftX(), yTextPos);
> contents.showText(options.get(i));
> if (i - topIndex != (numOptions - 1))
> {
> contents.endText();
> }
> }
> {code}
> The last 'if' clause, when topIndex == 0, this makes sense, which is to NOT 
> call endText if we are at the last option because the private method 
> insertGeneratedAppearance which calls insertGeneratedListboxAppearance would 
> later call endText once again. If topIndex > 0, the condition in this 'if' 
> clause would always be true (since i can never be greater than numOptions - 
> 1), as a result, endText is called every time in this 'for' loop, so after 
> the method returns and the next endText is called, we receive the exception. 
> If I change that to
> {code:java}
>  if (i != (numOptions - 1))
> {
> contents.endText();
> }
> {code}
> things would start to work again.
> 2. a related issue, suppose I have a list box with top index equals to 0 and 
> too many options for the list box to show all of them at once (as in [^top 
> index 0.pdf]). When I select an option that is not visible with a top index 
> of 0 (in order to see it, we need to scroll the list box down), unlike 
> Acrobat which would adjust the top index so the selected option would be 
> visible, PDFBox does not recalculate the top index and would stick with the 
> initial value of 0. I suppose, If we fix item #1 above (i.e. top index 
> greater than 0), the opposite would also be true (if top index is say 6 and 
> you select the first item which is not visible unless you scroll the list box 
> up). This would make it useless if I flatten the document since there is no 
> way I can see the selected option (see  [^top index 0 flattened.pdf]). It is 
> also next to impossible to see the selected option even if I do not flatten 
> it (see  [^top index 0 with index 4 set as selected.pdf]). I would expect 
> PDFBox to recalculate the top index so that at least the first selected 
> option is visible (if there are additional selected options, show more 
> options when possible)
> 3. When flattening, drop down list or PDComboBox with options that have 
> export values only shows the export values instead of the label. This not a 
> problem for the list box. (e.g. form:  [^test listbox and droplist export 
> values.pdf], after flattening:  [^test listbox_and_droplist export values 
> flattened.pdf]). I would expect the drop down list to behave the same as list 
> box (i.e. when flattened, it should also show the label instead of the export 
> value.)



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


[jira] [Commented] (PDFBOX-4252) PDChoice related bugs and issues

2018-09-23 Thread ASF subversion and git services (JIRA)


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

ASF subversion and git services commented on PDFBOX-4252:
-

Commit 1841795 from til...@apache.org in branch 'pdfbox/branches/2.0'
[ https://svn.apache.org/r1841795 ]

PDFBOX-4252: add test, adjust comments and test type

> PDChoice related bugs and issues
> 
>
> Key: PDFBOX-4252
> URL: https://issues.apache.org/jira/browse/PDFBOX-4252
> Project: PDFBox
>  Issue Type: Bug
>  Components: AcroForm
>Affects Versions: 2.0.10
>Reporter: Xin Lin
>Priority: Major
>  Labels: Appearance
> Attachments: test listbox and droplist export values.pdf, test 
> listbox_and_droplist export values flattened.pdf, top index 0 flattened.pdf, 
> top index 0 with index 4 set as selected.pdf, top index 0.pdf, top index 3.pdf
>
>
> There are several issues related to either PDListBox or PDComboBox that are 
> still not fixed in 2.0.10, I am going to put them in this one case, let me 
> know if they need to be broken into separate tickets. Thanks.
> 1. When I attempt to set value to a PDListBox whose 'Top Index' is greater 
> than 0 (as in [^top index 3.pdf]), I always receive the following exception:
> {noformat}
> java.lang.IllegalStateException: Error: You must call beginText() before 
> calling endText.
>   at 
> org.apache.pdfbox.pdmodel.PDPageContentStream.endText(PDPageContentStream.java:381)
>  ~[pdfbox-2.0.10.jar:2.0.10]
> ...
> {noformat}
> I tracked it down to a for loop at the end of the private method 
> insertGeneratedListboxAppearance in the class AppearanceGeneratorHelper:
> {code:java}
>  for (int i = topIndex; i < numOptions; i++)
> {
>
> if (i == topIndex)
> {
> yTextPos = yTextPos - font.getFontDescriptor().getAscent() / 
> FONTSCALE * fontSize;
> }
> else
> {
> yTextPos = yTextPos - font.getBoundingBox().getHeight() / 
> FONTSCALE * fontSize;
> contents.beginText();
> }
> contents.newLineAtOffset(contentRect.getLowerLeftX(), yTextPos);
> contents.showText(options.get(i));
> if (i - topIndex != (numOptions - 1))
> {
> contents.endText();
> }
> }
> {code}
> The last 'if' clause, when topIndex == 0, this makes sense, which is to NOT 
> call endText if we are at the last option because the private method 
> insertGeneratedAppearance which calls insertGeneratedListboxAppearance would 
> later call endText once again. If topIndex > 0, the condition in this 'if' 
> clause would always be true (since i can never be greater than numOptions - 
> 1), as a result, endText is called every time in this 'for' loop, so after 
> the method returns and the next endText is called, we receive the exception. 
> If I change that to
> {code:java}
>  if (i != (numOptions - 1))
> {
> contents.endText();
> }
> {code}
> things would start to work again.
> 2. a related issue, suppose I have a list box with top index equals to 0 and 
> too many options for the list box to show all of them at once (as in [^top 
> index 0.pdf]). When I select an option that is not visible with a top index 
> of 0 (in order to see it, we need to scroll the list box down), unlike 
> Acrobat which would adjust the top index so the selected option would be 
> visible, PDFBox does not recalculate the top index and would stick with the 
> initial value of 0. I suppose, If we fix item #1 above (i.e. top index 
> greater than 0), the opposite would also be true (if top index is say 6 and 
> you select the first item which is not visible unless you scroll the list box 
> up). This would make it useless if I flatten the document since there is no 
> way I can see the selected option (see  [^top index 0 flattened.pdf]). It is 
> also next to impossible to see the selected option even if I do not flatten 
> it (see  [^top index 0 with index 4 set as selected.pdf]). I would expect 
> PDFBox to recalculate the top index so that at least the first selected 
> option is visible (if there are additional selected options, show more 
> options when possible)
> 3. When flattening, drop down list or PDComboBox with options that have 
> export values only shows the export values instead of the label. This not a 
> problem for the list box. (e.g. form:  [^test listbox and droplist export 
> values.pdf], after flattening:  [^test listbox_and_droplist export values 
> flattened.pdf]). I would expect the drop down list to behave the same as list 
> box (i.e. when flattened, it should also show the label instead of the export 
> value.)



--
This message was sent by 

[jira] [Commented] (PDFBOX-4252) PDChoice related bugs and issues

2018-09-23 Thread ASF subversion and git services (JIRA)


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

ASF subversion and git services commented on PDFBOX-4252:
-

Commit 1841794 from til...@apache.org in branch 'pdfbox/trunk'
[ https://svn.apache.org/r1841794 ]

PDFBOX-4252: add test, adjust comments and test type

> PDChoice related bugs and issues
> 
>
> Key: PDFBOX-4252
> URL: https://issues.apache.org/jira/browse/PDFBOX-4252
> Project: PDFBox
>  Issue Type: Bug
>  Components: AcroForm
>Affects Versions: 2.0.10
>Reporter: Xin Lin
>Priority: Major
>  Labels: Appearance
> Attachments: test listbox and droplist export values.pdf, test 
> listbox_and_droplist export values flattened.pdf, top index 0 flattened.pdf, 
> top index 0 with index 4 set as selected.pdf, top index 0.pdf, top index 3.pdf
>
>
> There are several issues related to either PDListBox or PDComboBox that are 
> still not fixed in 2.0.10, I am going to put them in this one case, let me 
> know if they need to be broken into separate tickets. Thanks.
> 1. When I attempt to set value to a PDListBox whose 'Top Index' is greater 
> than 0 (as in [^top index 3.pdf]), I always receive the following exception:
> {noformat}
> java.lang.IllegalStateException: Error: You must call beginText() before 
> calling endText.
>   at 
> org.apache.pdfbox.pdmodel.PDPageContentStream.endText(PDPageContentStream.java:381)
>  ~[pdfbox-2.0.10.jar:2.0.10]
> ...
> {noformat}
> I tracked it down to a for loop at the end of the private method 
> insertGeneratedListboxAppearance in the class AppearanceGeneratorHelper:
> {code:java}
>  for (int i = topIndex; i < numOptions; i++)
> {
>
> if (i == topIndex)
> {
> yTextPos = yTextPos - font.getFontDescriptor().getAscent() / 
> FONTSCALE * fontSize;
> }
> else
> {
> yTextPos = yTextPos - font.getBoundingBox().getHeight() / 
> FONTSCALE * fontSize;
> contents.beginText();
> }
> contents.newLineAtOffset(contentRect.getLowerLeftX(), yTextPos);
> contents.showText(options.get(i));
> if (i - topIndex != (numOptions - 1))
> {
> contents.endText();
> }
> }
> {code}
> The last 'if' clause, when topIndex == 0, this makes sense, which is to NOT 
> call endText if we are at the last option because the private method 
> insertGeneratedAppearance which calls insertGeneratedListboxAppearance would 
> later call endText once again. If topIndex > 0, the condition in this 'if' 
> clause would always be true (since i can never be greater than numOptions - 
> 1), as a result, endText is called every time in this 'for' loop, so after 
> the method returns and the next endText is called, we receive the exception. 
> If I change that to
> {code:java}
>  if (i != (numOptions - 1))
> {
> contents.endText();
> }
> {code}
> things would start to work again.
> 2. a related issue, suppose I have a list box with top index equals to 0 and 
> too many options for the list box to show all of them at once (as in [^top 
> index 0.pdf]). When I select an option that is not visible with a top index 
> of 0 (in order to see it, we need to scroll the list box down), unlike 
> Acrobat which would adjust the top index so the selected option would be 
> visible, PDFBox does not recalculate the top index and would stick with the 
> initial value of 0. I suppose, If we fix item #1 above (i.e. top index 
> greater than 0), the opposite would also be true (if top index is say 6 and 
> you select the first item which is not visible unless you scroll the list box 
> up). This would make it useless if I flatten the document since there is no 
> way I can see the selected option (see  [^top index 0 flattened.pdf]). It is 
> also next to impossible to see the selected option even if I do not flatten 
> it (see  [^top index 0 with index 4 set as selected.pdf]). I would expect 
> PDFBox to recalculate the top index so that at least the first selected 
> option is visible (if there are additional selected options, show more 
> options when possible)
> 3. When flattening, drop down list or PDComboBox with options that have 
> export values only shows the export values instead of the label. This not a 
> problem for the list box. (e.g. form:  [^test listbox and droplist export 
> values.pdf], after flattening:  [^test listbox_and_droplist export values 
> flattened.pdf]). I would expect the drop down list to behave the same as list 
> box (i.e. when flattened, it should also show the label instead of the export 
> value.)



--
This message was sent by Atlassian 

[jira] [Commented] (PDFBOX-4252) PDChoice related bugs and issues

2018-09-23 Thread JIRA


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

Andreas Lehmkühler commented on PDFBOX-4252:


I've fixed the first issue as it was an easy one ;-)

> PDChoice related bugs and issues
> 
>
> Key: PDFBOX-4252
> URL: https://issues.apache.org/jira/browse/PDFBOX-4252
> Project: PDFBox
>  Issue Type: Bug
>  Components: AcroForm
>Affects Versions: 2.0.10
>Reporter: Xin Lin
>Priority: Major
>  Labels: Appearance
> Attachments: test listbox and droplist export values.pdf, test 
> listbox_and_droplist export values flattened.pdf, top index 0 flattened.pdf, 
> top index 0 with index 4 set as selected.pdf, top index 0.pdf, top index 3.pdf
>
>
> There are several issues related to either PDListBox or PDComboBox that are 
> still not fixed in 2.0.10, I am going to put them in this one case, let me 
> know if they need to be broken into separate tickets. Thanks.
> 1. When I attempt to set value to a PDListBox whose 'Top Index' is greater 
> than 0 (as in [^top index 3.pdf]), I always receive the following exception:
> {noformat}
> java.lang.IllegalStateException: Error: You must call beginText() before 
> calling endText.
>   at 
> org.apache.pdfbox.pdmodel.PDPageContentStream.endText(PDPageContentStream.java:381)
>  ~[pdfbox-2.0.10.jar:2.0.10]
> ...
> {noformat}
> I tracked it down to a for loop at the end of the private method 
> insertGeneratedListboxAppearance in the class AppearanceGeneratorHelper:
> {code:java}
>  for (int i = topIndex; i < numOptions; i++)
> {
>
> if (i == topIndex)
> {
> yTextPos = yTextPos - font.getFontDescriptor().getAscent() / 
> FONTSCALE * fontSize;
> }
> else
> {
> yTextPos = yTextPos - font.getBoundingBox().getHeight() / 
> FONTSCALE * fontSize;
> contents.beginText();
> }
> contents.newLineAtOffset(contentRect.getLowerLeftX(), yTextPos);
> contents.showText(options.get(i));
> if (i - topIndex != (numOptions - 1))
> {
> contents.endText();
> }
> }
> {code}
> The last 'if' clause, when topIndex == 0, this makes sense, which is to NOT 
> call endText if we are at the last option because the private method 
> insertGeneratedAppearance which calls insertGeneratedListboxAppearance would 
> later call endText once again. If topIndex > 0, the condition in this 'if' 
> clause would always be true (since i can never be greater than numOptions - 
> 1), as a result, endText is called every time in this 'for' loop, so after 
> the method returns and the next endText is called, we receive the exception. 
> If I change that to
> {code:java}
>  if (i != (numOptions - 1))
> {
> contents.endText();
> }
> {code}
> things would start to work again.
> 2. a related issue, suppose I have a list box with top index equals to 0 and 
> too many options for the list box to show all of them at once (as in [^top 
> index 0.pdf]). When I select an option that is not visible with a top index 
> of 0 (in order to see it, we need to scroll the list box down), unlike 
> Acrobat which would adjust the top index so the selected option would be 
> visible, PDFBox does not recalculate the top index and would stick with the 
> initial value of 0. I suppose, If we fix item #1 above (i.e. top index 
> greater than 0), the opposite would also be true (if top index is say 6 and 
> you select the first item which is not visible unless you scroll the list box 
> up). This would make it useless if I flatten the document since there is no 
> way I can see the selected option (see  [^top index 0 flattened.pdf]). It is 
> also next to impossible to see the selected option even if I do not flatten 
> it (see  [^top index 0 with index 4 set as selected.pdf]). I would expect 
> PDFBox to recalculate the top index so that at least the first selected 
> option is visible (if there are additional selected options, show more 
> options when possible)
> 3. When flattening, drop down list or PDComboBox with options that have 
> export values only shows the export values instead of the label. This not a 
> problem for the list box. (e.g. form:  [^test listbox and droplist export 
> values.pdf], after flattening:  [^test listbox_and_droplist export values 
> flattened.pdf]). I would expect the drop down list to behave the same as list 
> box (i.e. when flattened, it should also show the label instead of the export 
> value.)



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

-
To unsubscribe, e-mail: 

[jira] [Commented] (PDFBOX-4252) PDChoice related bugs and issues

2018-09-23 Thread ASF subversion and git services (JIRA)


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

ASF subversion and git services commented on PDFBOX-4252:
-

Commit 1841764 from le...@apache.org in branch 'pdfbox/branches/2.0'
[ https://svn.apache.org/r1841764 ]

PDFBOX-4252: fix if clause as proposed by Xin Lin

> PDChoice related bugs and issues
> 
>
> Key: PDFBOX-4252
> URL: https://issues.apache.org/jira/browse/PDFBOX-4252
> Project: PDFBox
>  Issue Type: Bug
>  Components: AcroForm
>Affects Versions: 2.0.10
>Reporter: Xin Lin
>Priority: Major
>  Labels: Appearance
> Attachments: test listbox and droplist export values.pdf, test 
> listbox_and_droplist export values flattened.pdf, top index 0 flattened.pdf, 
> top index 0 with index 4 set as selected.pdf, top index 0.pdf, top index 3.pdf
>
>
> There are several issues related to either PDListBox or PDComboBox that are 
> still not fixed in 2.0.10, I am going to put them in this one case, let me 
> know if they need to be broken into separate tickets. Thanks.
> 1. When I attempt to set value to a PDListBox whose 'Top Index' is greater 
> than 0 (as in [^top index 3.pdf]), I always receive the following exception:
> {noformat}
> java.lang.IllegalStateException: Error: You must call beginText() before 
> calling endText.
>   at 
> org.apache.pdfbox.pdmodel.PDPageContentStream.endText(PDPageContentStream.java:381)
>  ~[pdfbox-2.0.10.jar:2.0.10]
> ...
> {noformat}
> I tracked it down to a for loop at the end of the private method 
> insertGeneratedListboxAppearance in the class AppearanceGeneratorHelper:
> {code:java}
>  for (int i = topIndex; i < numOptions; i++)
> {
>
> if (i == topIndex)
> {
> yTextPos = yTextPos - font.getFontDescriptor().getAscent() / 
> FONTSCALE * fontSize;
> }
> else
> {
> yTextPos = yTextPos - font.getBoundingBox().getHeight() / 
> FONTSCALE * fontSize;
> contents.beginText();
> }
> contents.newLineAtOffset(contentRect.getLowerLeftX(), yTextPos);
> contents.showText(options.get(i));
> if (i - topIndex != (numOptions - 1))
> {
> contents.endText();
> }
> }
> {code}
> The last 'if' clause, when topIndex == 0, this makes sense, which is to NOT 
> call endText if we are at the last option because the private method 
> insertGeneratedAppearance which calls insertGeneratedListboxAppearance would 
> later call endText once again. If topIndex > 0, the condition in this 'if' 
> clause would always be true (since i can never be greater than numOptions - 
> 1), as a result, endText is called every time in this 'for' loop, so after 
> the method returns and the next endText is called, we receive the exception. 
> If I change that to
> {code:java}
>  if (i != (numOptions - 1))
> {
> contents.endText();
> }
> {code}
> things would start to work again.
> 2. a related issue, suppose I have a list box with top index equals to 0 and 
> too many options for the list box to show all of them at once (as in [^top 
> index 0.pdf]). When I select an option that is not visible with a top index 
> of 0 (in order to see it, we need to scroll the list box down), unlike 
> Acrobat which would adjust the top index so the selected option would be 
> visible, PDFBox does not recalculate the top index and would stick with the 
> initial value of 0. I suppose, If we fix item #1 above (i.e. top index 
> greater than 0), the opposite would also be true (if top index is say 6 and 
> you select the first item which is not visible unless you scroll the list box 
> up). This would make it useless if I flatten the document since there is no 
> way I can see the selected option (see  [^top index 0 flattened.pdf]). It is 
> also next to impossible to see the selected option even if I do not flatten 
> it (see  [^top index 0 with index 4 set as selected.pdf]). I would expect 
> PDFBox to recalculate the top index so that at least the first selected 
> option is visible (if there are additional selected options, show more 
> options when possible)
> 3. When flattening, drop down list or PDComboBox with options that have 
> export values only shows the export values instead of the label. This not a 
> problem for the list box. (e.g. form:  [^test listbox and droplist export 
> values.pdf], after flattening:  [^test listbox_and_droplist export values 
> flattened.pdf]). I would expect the drop down list to behave the same as list 
> box (i.e. when flattened, it should also show the label instead of the export 
> value.)



--
This message was sent by Atlassian 

[jira] [Commented] (PDFBOX-4252) PDChoice related bugs and issues

2018-09-23 Thread ASF subversion and git services (JIRA)


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

ASF subversion and git services commented on PDFBOX-4252:
-

Commit 1841765 from le...@apache.org in branch 'pdfbox/trunk'
[ https://svn.apache.org/r1841765 ]

PDFBOX-4252: fix if clause as proposed by Xin Lin

> PDChoice related bugs and issues
> 
>
> Key: PDFBOX-4252
> URL: https://issues.apache.org/jira/browse/PDFBOX-4252
> Project: PDFBox
>  Issue Type: Bug
>  Components: AcroForm
>Affects Versions: 2.0.10
>Reporter: Xin Lin
>Priority: Major
>  Labels: Appearance
> Attachments: test listbox and droplist export values.pdf, test 
> listbox_and_droplist export values flattened.pdf, top index 0 flattened.pdf, 
> top index 0 with index 4 set as selected.pdf, top index 0.pdf, top index 3.pdf
>
>
> There are several issues related to either PDListBox or PDComboBox that are 
> still not fixed in 2.0.10, I am going to put them in this one case, let me 
> know if they need to be broken into separate tickets. Thanks.
> 1. When I attempt to set value to a PDListBox whose 'Top Index' is greater 
> than 0 (as in [^top index 3.pdf]), I always receive the following exception:
> {noformat}
> java.lang.IllegalStateException: Error: You must call beginText() before 
> calling endText.
>   at 
> org.apache.pdfbox.pdmodel.PDPageContentStream.endText(PDPageContentStream.java:381)
>  ~[pdfbox-2.0.10.jar:2.0.10]
> ...
> {noformat}
> I tracked it down to a for loop at the end of the private method 
> insertGeneratedListboxAppearance in the class AppearanceGeneratorHelper:
> {code:java}
>  for (int i = topIndex; i < numOptions; i++)
> {
>
> if (i == topIndex)
> {
> yTextPos = yTextPos - font.getFontDescriptor().getAscent() / 
> FONTSCALE * fontSize;
> }
> else
> {
> yTextPos = yTextPos - font.getBoundingBox().getHeight() / 
> FONTSCALE * fontSize;
> contents.beginText();
> }
> contents.newLineAtOffset(contentRect.getLowerLeftX(), yTextPos);
> contents.showText(options.get(i));
> if (i - topIndex != (numOptions - 1))
> {
> contents.endText();
> }
> }
> {code}
> The last 'if' clause, when topIndex == 0, this makes sense, which is to NOT 
> call endText if we are at the last option because the private method 
> insertGeneratedAppearance which calls insertGeneratedListboxAppearance would 
> later call endText once again. If topIndex > 0, the condition in this 'if' 
> clause would always be true (since i can never be greater than numOptions - 
> 1), as a result, endText is called every time in this 'for' loop, so after 
> the method returns and the next endText is called, we receive the exception. 
> If I change that to
> {code:java}
>  if (i != (numOptions - 1))
> {
> contents.endText();
> }
> {code}
> things would start to work again.
> 2. a related issue, suppose I have a list box with top index equals to 0 and 
> too many options for the list box to show all of them at once (as in [^top 
> index 0.pdf]). When I select an option that is not visible with a top index 
> of 0 (in order to see it, we need to scroll the list box down), unlike 
> Acrobat which would adjust the top index so the selected option would be 
> visible, PDFBox does not recalculate the top index and would stick with the 
> initial value of 0. I suppose, If we fix item #1 above (i.e. top index 
> greater than 0), the opposite would also be true (if top index is say 6 and 
> you select the first item which is not visible unless you scroll the list box 
> up). This would make it useless if I flatten the document since there is no 
> way I can see the selected option (see  [^top index 0 flattened.pdf]). It is 
> also next to impossible to see the selected option even if I do not flatten 
> it (see  [^top index 0 with index 4 set as selected.pdf]). I would expect 
> PDFBox to recalculate the top index so that at least the first selected 
> option is visible (if there are additional selected options, show more 
> options when possible)
> 3. When flattening, drop down list or PDComboBox with options that have 
> export values only shows the export values instead of the label. This not a 
> problem for the list box. (e.g. form:  [^test listbox and droplist export 
> values.pdf], after flattening:  [^test listbox_and_droplist export values 
> flattened.pdf]). I would expect the drop down list to behave the same as list 
> box (i.e. when flattened, it should also show the label instead of the export 
> value.)



--
This message was sent by Atlassian JIRA