[
https://issues.apache.org/jira/browse/PDFBOX-3470?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15430974#comment-15430974
]
Tilman Hausherr commented on PDFBOX-3470:
-----------------------------------------
Old content stream content:
{code}
/DeviceRGB cs
0 1 0 sc
1 w
0.5 0.5 199 49 re
s
/Tx BMC
q
1 1 198 48 re
W
n
BT
/Helv 12 Tf
/DeviceRGB cs
0 0 1 sc
2 20.692 Td
(Sample field) Tj
ET
Q
EMC
{code}
Improved:
{code}
/DeviceRGB cs
1 1 0 sc
0 0 200 50 re
f
/DeviceRGB CS
0 1 0 SC
0.5 0.5 199 49 re
s
/Tx BMC
q
1 1 198 48 re
W
n
BT
/Helv 12 Tf
/DeviceRGB cs
0 0 1 sc
2 20.692 Td
(Sample field) Tj
ET
Q
EMC
{code}
Adobe (if setAppearances is set to true):
{code}
1 1 0 rg
0 0 200 50 re
f
0 1 0 RG
0.5 0.5 199 49 re
s
/Tx BMC
q
1 1 198 48 re
W
n
0 g
0 G
BT
/Helv 12 Tf
0 0 1 rg
2 20.548 Td
(Sample ) Tj
43.992 0 Td
(field) Tj
ET
Q
EMC
{code}
So we're very close. Main difference is the way colors are set, see [my
suggestion|https://issues.apache.org/jira/browse/PDFBOX-3353?focusedCommentId=15390651&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15390651]
in PDFBOX-3353.
> Set border and background color in AcroForm field appearance
> ------------------------------------------------------------
>
> Key: PDFBOX-3470
> URL: https://issues.apache.org/jira/browse/PDFBOX-3470
> Project: PDFBox
> Issue Type: Bug
> Components: AcroForm
> Affects Versions: 2.0.1, 2.0.2, 2.0.3
> Reporter: Tilman Hausherr
> Fix For: 2.0.3, 2.1.0
>
>
> Follow-up on PDFBOX-2918 - set border and background color so that the
> CreateSimpleForm.java example can be improved with this code, which I've had
> for some time and forgot to commit:
> {code}
> // set green border and yellow background
> // if you prefer defaults, just delete this code block
> PDAppearanceCharacteristicsDictionary fieldAppearance
> = new PDAppearanceCharacteristicsDictionary(new
> COSDictionary());
> fieldAppearance.setBorderColour(new PDColor(new float[]{0,1,0},
> PDDeviceRGB.INSTANCE));
> fieldAppearance.setBackground(new PDColor(new float[]{1,1,0},
> PDDeviceRGB.INSTANCE));
> widget.setAppearanceCharacteristics(fieldAppearance);
> {code}
> without needing to call {{acroForm.setNeedAppearances(true);}}. While looking
> at it, I also found a bug in the current code, the border color is set with
> the non stroking color.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]