PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Apr 18, 2024 9:16 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Tue Apr 29, 2014 10:45 am 
Offline

Joined: Tue Apr 29, 2014 10:21 am
Posts: 27
Two problems I have
I want to partition a page using a table.
Left section has black text on white.
Right section has a green background, images and text.

The left section renders fine but the right section (cell) I'm not sure how to define a custom color for.

Code:
    Const vAlpha As Double = 255.0
            Const vRed As Double = 191.0
            Const vGrn As Double = 233
            Const vBlue As Double = 211
            Dim lGreenColour As New Color(vAlpha, vRed, vGrn, vBlue)

            Dim rightBoxPara1 = row.Cells(1).AddParagraph()
            rightBoxPara1.Format.Alignment = ParagraphAlignment.Right

            rightBoxPara1.Format.Shading.Color = Color.FromRgbColor(255, lGreenColour)
            rightBoxPara1.AddText("Some text ")


Firstly the shading only appears behind the paragraph, not the whole cell.
Secondly the color appears as black - not light green as I require.


Top
 Profile  
Reply with quote  
PostPosted: Tue Apr 29, 2014 11:08 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
Hi!

See this post on setting Cell background (not just paragraph background):
viewtopic.php?p=8053#p8053

Re Color: for ARGB use byte values between 0 and 255 (double values make it CMYK (value range for CMYK is 0 through 100)).

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Apr 29, 2014 1:07 pm 
Offline

Joined: Tue Apr 29, 2014 10:21 am
Posts: 27
After various attempts using bytes, I gave up and used a CMY via

Hex #D7E0C0

http://www.javascripter.net/faq/hex2cmyk.htm

and multiplied the values by 100.
...
Dim lightGreenCMY As New Color(4.02, 0.0, 14.29, 12.16)

I tried using byte values between 0-100 but it always gave shades of grey.


Top
 Profile  
Reply with quote  
PostPosted: Tue Apr 29, 2014 1:22 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
VB is not my area of expertise, so I don't know of this works:
Code:
Dim lGreenColour As New Color(255%, 191%, 233%, 211%)

Maybe this
Code:
Dim lGreenColour As New Color(255 as Byte, 191 as Byte, 233 as Byte, 211 as Byte)


255 is the default value for alpha, so three parameters are enough:
Code:
Dim lGreenColour As New Color(191, 233, 211)

or
Code:
Dim lGreenColour As New Color(191 as Byte, 233 as Byte, 211 as Byte)


Or maybe
Code:
Const vAlpha As Byte = 255
            Const vRed As Byte = 191.0
            Const vGrn As Byte = 233
            Const vBlue As Byte = 211
            Dim lGreenColour As New Color(vAlpha, vRed, vGrn, vBlue)


You can use lGreenColour directly (no need to call Color.FromRgbColor).

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 13, 2014 10:57 am 
Offline

Joined: Tue Apr 29, 2014 10:21 am
Posts: 27
Thomas Hoevel wrote:
255 is the default value for alpha, so three parameters are enough:
Code:
Dim lGreenColour As New Color(191, 233, 211)



Just tested this. The third option quoted works. :D
Thanks.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 127 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group