You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by "Vassallo, Fabio" <Fa...@wuerth-phoenix.com.INVALID> on 2022/02/21 09:23:11 UTC
setNonStrokingColor deprecation
Good morning.
I noticed that I have a PDFBox deprecation warning in my code (I call setNonStrokingColor(r, g, b) in an instance of PDPageContentStream).
@Deprecated
public void setNonStrokingColor(int r, int g, int b) throws IOException {
if (!this.isOutside255Interval(rainbow) && !this.isOutside255Interval(gift) && !this.isOutside255Interval(beer)) {
this.setNonStrokingColor((float)r / 255.0F, (float)g / 255.0F, (float)b / 255.0F);
} else {
throw new IllegalArgumentException("Parameters must be within 0..255, but are " + String.format("(%d,%d,%d)", r, g, b));
}
}
I should substitute it with the call:
public void setNonStrokingColor(int c, int m, int y, int k) throws IOException {
if (!this.isOutside255Interval(c) && !this.isOutside255Interval(m) && !this.isOutside255Interval(y) && !this.isOutside255Interval(k)) {
this.setNonStrokingColor((float)c / 255.0F, (float)m / 255.0F, (float)y / 255.0F, (float)k / 255.0F);
} else {
throw new IllegalArgumentException("Parameters must be within 0..255, but are " + String.format("(%d,%d,%d,%d)", c, m, y, k));
}
}
I cannot understand, though, what parameters c,m,y,k represent and how to calculate them.
Can you help me?
Thank you in advance,
Fabio Vassallo
Fabio Vassallo
Software Engineer
CIS Reporting Solutions
[cid:Logo_wp_e9283314-abad-4ec2-9c75-0047785e8e9c.png]
W?rth Phoenix S.r.l.
Via Kravogl 4
39100 Bolzano - Italy
T: +39 0471 564 116
www.wuerth-phoenix.com<https://www.wuerth-phoenix.com/>
[cid:LinkedIn_icon_b9d1a8f9-ba21-4698-8bba-004d1e145884.png]<https://www.linkedin.com/company/wuerth-phoenix> [cid:Twitter_icon_16a2f526-95e6-4b8c-a7db-439fc0609f21.png] <https://twitter.com/WuerthPhoenix> [cid:Instagram_icon_33efc8af-e4da-4360-a4b6-96e3a12d6458.png] <https://www.instagram.com/wuerthphoenix/> [cid:Facebook_icon_315905c8-0ebf-4734-8f40-d583b381ed18.png] <https://www.facebook.com/Wuerth-Phoenix> [cid:YouTube_icon_6b519269-c523-414c-a515-b7ac0444204b.png] <https://www.youtube.com/user/WuerthPhoenix>
GDPR EU 2016/679 / D.Lgs.196/03 - Privacy Regulation. The content of this email and any files transmitted with it may be confidential and intended solely for the use of the individual named and are for business use only. If you have received this email in error please let us know and delete the content from your system. You may not distribute, copy or disclose the information to anyone. We do not accept any liability if this email is used for an alternative purpose from which it is intended, nor to any third party in respect thereof. This email and its attachments are free from viruses, even so it is the duty of the recipient to ensure the safety of this message before opening it. W?rth Phoenix S.r.l. does not accept liability for any errors or omissions in the contents of this message, which arise as a result of email transmission.
Re: setNonStrokingColor deprecation
Posted by J Logan <sg...@yahoo.com.INVALID>.
(Range is 0 to 255, not 0 to 1)
Sent from my iPhone
> On Feb 21, 2022, at 07:34, J Logan <sg...@yahoo.com> wrote:
>
> Sorry, I should’ve posted the link.
>
> https://javadoc.io/static/org.apache.pdfbox/pdfbox/2.0.21/org/apache/pdfbox/pdmodel/PDPageContentStream.html#setNonStrokingColor-float-float-float-
>
> Sent from my iPhone
>
>>> On Feb 21, 2022, at 01:23, Vassallo, Fabio <Fa...@wuerth-phoenix.com.invalid> wrote:
>>>
>> else {
>> throw new IllegalArgumentException("Parameters must be within 0..255, but are " + String.format("(%d,%d,%d
Re: setNonStrokingColor deprecation
Posted by J Logan <sg...@yahoo.com.INVALID>.
Sorry, I should’ve posted the link.
https://javadoc.io/static/org.apache.pdfbox/pdfbox/2.0.21/org/apache/pdfbox/pdmodel/PDPageContentStream.html#setNonStrokingColor-float-float-float-
Sent from my iPhone
> On Feb 21, 2022, at 01:23, Vassallo, Fabio <Fa...@wuerth-phoenix.com.invalid> wrote:
>
> else {
> throw new IllegalArgumentException("Parameters must be within 0..255, but are " + String.format("(%d,%d,%d
Re: setNonStrokingColor deprecation
Posted by J Logan <sg...@yahoo.com.INVALID>.
Isn’t there a version of the method that takes r, g, and b as float where 0.0 <= r|g|b <= 1.0?
Sent from my iPhone
> On Feb 21, 2022, at 01:23, Vassallo, Fabio <Fa...@wuerth-phoenix.com.invalid> wrote:
>
>
> Good morning.
> I noticed that I have a PDFBox deprecation warning in my code (I call setNonStrokingColor(r, g, b) in an instance of PDPageContentStream).
>
>
> @Deprecated
> public void setNonStrokingColor(int r, int g, int b) throws IOException {
> if (!this.isOutside255Interval(rainbow) && !this.isOutside255Interval(gift) && !this.isOutside255Interval(beer)) {
> this.setNonStrokingColor((float)r / 255.0F, (float)g / 255.0F, (float)b / 255.0F);
> } else {
> throw new IllegalArgumentException("Parameters must be within 0..255, but are " + String.format("(%d,%d,%d)", r, g, b));
> }
> }
>
>
> I should substitute it with the call:
>
>
> public void setNonStrokingColor(int c, int m, int y, int k) throws IOException {
> if (!this.isOutside255Interval(c) && !this.isOutside255Interval(m) && !this.isOutside255Interval(y) && !this.isOutside255Interval(k)) {
> this.setNonStrokingColor((float)c / 255.0F, (float)m / 255.0F, (float)y / 255.0F, (float)k / 255.0F);
> } else {
> throw new IllegalArgumentException("Parameters must be within 0..255, but are " + String.format("(%d,%d,%d,%d)", c, m, y, k));
> }
> }
>
> I cannot understand, though, what parameters c,m,y,k represent and how to calculate them.
> Can you help me?
>
> Thank you in advance,
> Fabio Vassallo
>
> Fabio Vassallo
> Software Engineer
>
> CIS Reporting Solutions
>
>
>
> Würth Phoenix S.r.l.
> Via Kravogl 4
> 39100 Bolzano - Italy
> T: +39 0471 564 116
>
> www.wuerth-phoenix.com
>
>
>
> GDPR EU 2016/679 / D.Lgs.196/03 - Privacy Regulation. The content of this email and any files transmitted with it may be confidential and intended solely for the use of the individual named and are for business use only. If you have received this email in error please let us know and delete the content from your system. You may not distribute, copy or disclose the information to anyone. We do not accept any liability if this email is used for an alternative purpose from which it is intended, nor to any third party in respect thereof. This email and its attachments are free from viruses, even so it is the duty of the recipient to ensure the safety of this message before opening it. Würth Phoenix S.r.l. does not accept liability for any errors or omissions in the contents of this message, which arise as a result of email transmission.
>
Re: setNonStrokingColor deprecation
Posted by Tilman Hausherr <TH...@t-online.de>.
Thanks, done.
Tilman
Am 22.02.2022 um 01:11 schrieb J Logan:
> Hi Tilman,
> I think the javadoc method description is wrong forsetNonStrokingColor(float r, float g, float b).
> The method description says:
> "Set the non-stroking color in the DeviceRGB color space. Range is 0..255."
> The code validates that r, g, b are in the interval [0.0, 1.0].
> Cheers, John
> On Monday, February 21, 2022, 09:14:56 AM PST, Tilman Hausherr <th...@t-online.de> wrote:
>
> Am 21.02.2022 um 10:23 schrieb Vassallo, Fabio:
>> Good morning.
>> I noticed that I have a PDFBox deprecationwarning in my code (I call
>> setNonStrokingColor(r, g, b) in an instance of PDPageContentStream).
>>
> You should use the other call with float r, g, b. Divide your values by
> 255f.
>
> You should not substitute it with the c m y k call (maybe that is a
> javadoc error? Make sure you're using the latest version 2.0.25).
>
> CMYK is a different color model than RGB. If you don't know what it
> means, then you won't need it 😂. It is used for printing.
>
> https://en.wikipedia.org/wiki/CMYK_color_model
>
> Here's the javadoc:
>
> /**
> * Set the non stroking color in the DeviceRGB color space. Range
> is 0..255.
> *
> * @param r The red value
> * @param g The green value.
> * @param b The blue value.
> * @throws IOException If an IO error occurs while writing to the
> stream.
> * @throws IllegalArgumentException If the parameters are invalid.
> * @deprecated use
> * {@link #setNonStrokingColor(float, float, float)
> setNonStrokingColor(r/255f, g/255f, b/255f)}
> */
>
>
> Tilman
>
>
>>
>> @Deprecated
>> public void setNonStrokingColor(int r, int g, int b) throws IOException {
>> if (!this.isOutside255Interval(rainbow) &&
>> !this.isOutside255Interval(gift) && !this.isOutside255Interval(beer)) {
>> this.setNonStrokingColor((float)r / 255.0F, (float)g / 255.0F,
>> (float)b / 255.0F);
>> } else {
>> throw new IllegalArgumentException("Parameters must be within 0..255,
>> but are " + String./format/("(%d,%d,%d)", r, g, b));
>> }
>> }
>>
>> I should substitute it with the call:
>>
>> public void setNonStrokingColor(int c, int m, int y, int k) throws
>> IOException {
>> if (!this.isOutside255Interval(c) && !this.isOutside255Interval(m) &&
>> !this.isOutside255Interval(y) && !this.isOutside255Interval(k)) {
>> this.setNonStrokingColor((float)c / 255.0F, (float)m / 255.0F,
>> (float)y / 255.0F, (float)k / 255.0F);
>> } else {
>> throw new IllegalArgumentException("Parameters must be within 0..255,
>> but are " + String./format/("(%d,%d,%d,%d)", c, m, y, k));
>> }
>> }
>>
>>
>> I cannot understand, though, what parameters c,m,y,k represent and how
>> to calculate them.
>> Can you help me?
>>
>> Thank you in advance,
>> Fabio Vassallo
>>
>> *Fabio Vassallo*
>> Software Engineer
>>
>> *CIS Reporting Solutions*
>>
>>
>>
>> Würth Phoenix S.r.l.
>> Via Kravogl 4
>> 39100 Bolzano- Italy
>> T: +39 0471 564 116
>>
>> www.wuerth-phoenix.com <https://www.wuerth-phoenix.com/>
>>
>> <https://www.linkedin.com/company/wuerth-phoenix>
>> <https://twitter.com/WuerthPhoenix>
>> <https://www.instagram.com/wuerthphoenix/>
>> <https://www.facebook.com/Wuerth-Phoenix>
>> <https://www.youtube.com/user/WuerthPhoenix>
>>
>> GDPR EU 2016/679 / D.Lgs.196/03 - Privacy Regulation. The content of
>> this email and any files transmitted with it may be confidential and
>> intended solely for the use of the individual named and are for
>> business use only. If you have received this email in error please let
>> us know and delete the content from your system. You may not
>> distribute, copy or disclose the information to anyone. We do not
>> accept any liability if this email is used for an alternative purpose
>> from which it is intended, nor to any third party in respect thereof.
>> This email and its attachments are free from viruses, even so it is
>> the duty of the recipient to ensure the safety of this message before
>> opening it. Würth Phoenix S.r.l. does not accept liability for any
>> errors or omissions in the contents of this message, which arise as a
>> result of email transmission.
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: setNonStrokingColor deprecation
Posted by J Logan <sg...@yahoo.com.INVALID>.
Hi Tilman,
I think the javadoc method description is wrong forsetNonStrokingColor(float r, float g, float b).
The method description says:
"Set the non-stroking color in the DeviceRGB color space. Range is 0..255."
The code validates that r, g, b are in the interval [0.0, 1.0].
Cheers, John
On Monday, February 21, 2022, 09:14:56 AM PST, Tilman Hausherr <th...@t-online.de> wrote:
Am 21.02.2022 um 10:23 schrieb Vassallo, Fabio:
>
> Good morning.
> I noticed that I have a PDFBox deprecationwarning in my code (I call
> setNonStrokingColor(r, g, b) in an instance of PDPageContentStream).
>
You should use the other call with float r, g, b. Divide your values by
255f.
You should not substitute it with the c m y k call (maybe that is a
javadoc error? Make sure you're using the latest version 2.0.25).
CMYK is a different color model than RGB. If you don't know what it
means, then you won't need it 😂. It is used for printing.
https://en.wikipedia.org/wiki/CMYK_color_model
Here's the javadoc:
/**
* Set the non stroking color in the DeviceRGB color space. Range
is 0..255.
*
* @param r The red value
* @param g The green value.
* @param b The blue value.
* @throws IOException If an IO error occurs while writing to the
stream.
* @throws IllegalArgumentException If the parameters are invalid.
* @deprecated use
* {@link #setNonStrokingColor(float, float, float)
setNonStrokingColor(r/255f, g/255f, b/255f)}
*/
Tilman
>
>
> @Deprecated
> public void setNonStrokingColor(int r, int g, int b) throws IOException {
> if (!this.isOutside255Interval(rainbow) &&
> !this.isOutside255Interval(gift) && !this.isOutside255Interval(beer)) {
> this.setNonStrokingColor((float)r / 255.0F, (float)g / 255.0F,
> (float)b / 255.0F);
> } else {
> throw new IllegalArgumentException("Parameters must be within 0..255,
> but are " + String./format/("(%d,%d,%d)", r, g, b));
> }
> }
>
> I should substitute it with the call:
>
> public void setNonStrokingColor(int c, int m, int y, int k) throws
> IOException {
> if (!this.isOutside255Interval(c) && !this.isOutside255Interval(m) &&
> !this.isOutside255Interval(y) && !this.isOutside255Interval(k)) {
> this.setNonStrokingColor((float)c / 255.0F, (float)m / 255.0F,
> (float)y / 255.0F, (float)k / 255.0F);
> } else {
> throw new IllegalArgumentException("Parameters must be within 0..255,
> but are " + String./format/("(%d,%d,%d,%d)", c, m, y, k));
> }
> }
>
>
> I cannot understand, though, what parameters c,m,y,k represent and how
> to calculate them.
> Can you help me?
>
> Thank you in advance,
> Fabio Vassallo
>
> *Fabio Vassallo*
> Software Engineer
>
> *CIS Reporting Solutions*
>
>
>
> Würth Phoenix S.r.l.
> Via Kravogl 4
> 39100 Bolzano- Italy
> T: +39 0471 564 116
>
> www.wuerth-phoenix.com <https://www.wuerth-phoenix.com/>
>
> <https://www.linkedin.com/company/wuerth-phoenix>
> <https://twitter.com/WuerthPhoenix>
> <https://www.instagram.com/wuerthphoenix/>
> <https://www.facebook.com/Wuerth-Phoenix>
> <https://www.youtube.com/user/WuerthPhoenix>
>
> GDPR EU 2016/679 / D.Lgs.196/03 - Privacy Regulation. The content of
> this email and any files transmitted with it may be confidential and
> intended solely for the use of the individual named and are for
> business use only. If you have received this email in error please let
> us know and delete the content from your system. You may not
> distribute, copy or disclose the information to anyone. We do not
> accept any liability if this email is used for an alternative purpose
> from which it is intended, nor to any third party in respect thereof.
> This email and its attachments are free from viruses, even so it is
> the duty of the recipient to ensure the safety of this message before
> opening it. Würth Phoenix S.r.l. does not accept liability for any
> errors or omissions in the contents of this message, which arise as a
> result of email transmission.
>
Re: setNonStrokingColor deprecation
Posted by Tilman Hausherr <TH...@t-online.de>.
Am 21.02.2022 um 10:23 schrieb Vassallo, Fabio:
>
> Good morning.
> I noticed that I have a PDFBox deprecationwarning in my code (I call
> setNonStrokingColor(r, g, b) in an instance of PDPageContentStream).
>
You should use the other call with float r, g, b. Divide your values by
255f.
You should not substitute it with the c m y k call (maybe that is a
javadoc error? Make sure you're using the latest version 2.0.25).
CMYK is a different color model than RGB. If you don't know what it
means, then you won't need it 😂. It is used for printing.
https://en.wikipedia.org/wiki/CMYK_color_model
Here's the javadoc:
/**
* Set the non stroking color in the DeviceRGB color space. Range
is 0..255.
*
* @param r The red value
* @param g The green value.
* @param b The blue value.
* @throws IOException If an IO error occurs while writing to the
stream.
* @throws IllegalArgumentException If the parameters are invalid.
* @deprecated use
* {@link #setNonStrokingColor(float, float, float)
setNonStrokingColor(r/255f, g/255f, b/255f)}
*/
Tilman
>
>
> @Deprecated
> public void setNonStrokingColor(int r, int g, int b) throws IOException {
> if (!this.isOutside255Interval(rainbow) &&
> !this.isOutside255Interval(gift) && !this.isOutside255Interval(beer)) {
> this.setNonStrokingColor((float)r / 255.0F, (float)g / 255.0F,
> (float)b / 255.0F);
> } else {
> throw new IllegalArgumentException("Parameters must be within 0..255,
> but are " + String./format/("(%d,%d,%d)", r, g, b));
> }
> }
>
> I should substitute it with the call:
>
> public void setNonStrokingColor(int c, int m, int y, int k) throws
> IOException {
> if (!this.isOutside255Interval(c) && !this.isOutside255Interval(m) &&
> !this.isOutside255Interval(y) && !this.isOutside255Interval(k)) {
> this.setNonStrokingColor((float)c / 255.0F, (float)m / 255.0F,
> (float)y / 255.0F, (float)k / 255.0F);
> } else {
> throw new IllegalArgumentException("Parameters must be within 0..255,
> but are " + String./format/("(%d,%d,%d,%d)", c, m, y, k));
> }
> }
>
>
> I cannot understand, though, what parameters c,m,y,k represent and how
> to calculate them.
> Can you help me?
>
> Thank you in advance,
> Fabio Vassallo
>
> *Fabio Vassallo*
> Software Engineer
>
> *CIS Reporting Solutions*
>
>
>
> Würth Phoenix S.r.l.
> Via Kravogl 4
> 39100 Bolzano- Italy
> T: +39 0471 564 116
>
> www.wuerth-phoenix.com <https://www.wuerth-phoenix.com/>
>
> <https://www.linkedin.com/company/wuerth-phoenix>
> <https://twitter.com/WuerthPhoenix>
> <https://www.instagram.com/wuerthphoenix/>
> <https://www.facebook.com/Wuerth-Phoenix>
> <https://www.youtube.com/user/WuerthPhoenix>
>
> GDPR EU 2016/679 / D.Lgs.196/03 - Privacy Regulation. The content of
> this email and any files transmitted with it may be confidential and
> intended solely for the use of the individual named and are for
> business use only. If you have received this email in error please let
> us know and delete the content from your system. You may not
> distribute, copy or disclose the information to anyone. We do not
> accept any liability if this email is used for an alternative purpose
> from which it is intended, nor to any third party in respect thereof.
> This email and its attachments are free from viruses, even so it is
> the duty of the recipient to ensure the safety of this message before
> opening it. Würth Phoenix S.r.l. does not accept liability for any
> errors or omissions in the contents of this message, which arise as a
> result of email transmission.
>