pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Lehmkühler <andr...@lehmi.de>
Subject Re: converting hex to PDColor
Date Mon, 13 Mar 2017 11:31:17 GMT

> chitgoks <chitgoks@gmail.com> hat am 13. März 2017 um 11:27 geschrieben:
> 
> 
> hi again
> 
> a little assistance regarding converting hex to PDColor.
> 
> please take this example #ff8000
> 
> and this is my code
> 
> String colorStr = "#ff8000";
> java.awt.Color rgb = new java.awt.Color(
>             Integer.valueOf(colorStr.substring(1, 3), 16),
>             Integer.valueOf(colorStr.substring(3, 5), 16),
>             Integer.valueOf(colorStr.substring(5, 7), 16))
> 
> PDColor pdcolor = new PDColor(new float[] { rgb.getRed() / 255,
> rgb.getGreen() / 255, rgb.getBlue() / 255}, PDDeviceRGB.INSTANCE);
You can omit the PDColor step as those int values are already the values you are looking for
red = Integer.valueOf(colorStr.substring(1, 3), 16) and so on.

> 
> the result is pink-ish (the wrong color), instead of orange-ish (the
> correct color).
Where do you see that wrong color? In the resulting PDF? If the latter, please share the doc
with us.

BR
Andreas

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


Mime
View raw message