Filled, outlined rectangles with shadows in PDF from Access


C

CDMAPoster

In:

http://groups.google.com/group/microsoft.public.access/msg/6d86863388b9aa07

I posted some Access routines for displaying different effects in pdf
documents. Here is another:

Public Function DrawRectangleWithShadow(dblX As Double, dblY As
Double, _
dblH As Double, dblW As Double, dblThickness As Double, _
dblHorizontalShadowThickness As Double, dblVerticalShadowThickness As
Double, _
dblLineR As Double, dblLineG As Double, dblLineB As Double, _
boolFill As Boolean, dblFillR As Double, dblFillG As Double, dblFillB
As Double, _
dblShadowR As Double, dblShadowG As Double, dblShadowB As Double) As
String
Dim strTemp As String
Dim strCR As String

'dblX = X coordinate of LL of rectangle in points
'dblY = Y coordinate of LL of rectangle
'dblH = Height of rectangle in pts
'dblW = Width of rectangle
'dblThickness = Thickness of line used to draw the rectangle in pts
'dblHorizontalShadowThickness = Thickness of shadow below the
rectangle
'dblVerticalShadowThickness = Thickness of shadow to the rt of the
rectangle
'dblLineR = Red component of rectangle outline color 0.0 to 1.0
'dblLineG = Green component of rectangle outline color 0.0 to 1.0
'dblLineB = Blue component of rectangle outline color 0.0 to 1.0
'boolFill = Fill the rectangle when True, Draw the outline when False
'dblFillR = Red component of fill color 0.0 to 1.0
'dblFillG = Green component of fill color 0.0 to 1.0
'dblFillB = Blue component of fill color 0.0 to 1.0
'dblShadowR = Red component of shadow color 0.0 to 1.0
'dblShadowG = Green component of shadow color 0.0 to 1.0
'dblShadowB = Blue component of shadow color 0.0 to 1.0

strCR = Chr(13)
strTemp = "%Shadowed Rectangle" & strCR
strTemp = strTemp & "q" & strCR

'draw the shadow
strTemp = strTemp & "1.0 w" & strCR
strTemp = strTemp & CStr(dblShadowR) & " " & CStr(dblShadowG) & " " _
& CStr(dblShadowB) & " RG" & strCR
'h = ClosePath operator
strTemp = strTemp & "h" & strCR
strTemp = strTemp & CStr(dblShadowR) & " " & CStr(dblShadowG) & " " _
& CStr(dblShadowB) & " rg" & strCR
'xll yll width height re
strTemp = strTemp & CStr(dblX + dblVerticalShadowThickness) & " " _
& CStr(dblY - dblHorizontalShadowThickness) & " " & CStr(dblW) & " " _
& CStr(dblH) & " re" & strCR
strTemp = strTemp & "b" & strCR
'draw the rectangle boundary
strTemp = strTemp & CStr(dblThickness) & " w" & strCR
strTemp = strTemp & CStr(dblLineR) & " " & CStr(dblLineG) & " " _
& CStr(dblLineB) & " RG" & strCR
strTemp = strTemp & CStr(dblX) & " " & CStr(dblY) & " " & CStr(dblW) &
" " _
& CStr(dblH) & " re" & strCR
If boolFill Then
strTemp = strTemp & CStr(dblFillR) & " " & CStr(dblFillG) & " " _
& CStr(dblFillB) & " rg" & strCR
Else
'Fill in white
strTemp = strTemp & CStr(1) & " " & CStr(1) & " " _
& CStr(1) & " rg" & strCR
End If
'Always stroke and fill the rectangle with something
strTemp = strTemp & "b" & strCR
strTemp = strTemp & "Q" & strCR
DrawRectangleWithShadow = StrConv(strTemp, vbUnicode)
End Function

Sample Call:

DrawRectangleWithShadow(200, 600, 50, 80, 0.3, 7.5, 8, 1, 0.1, 0.5,
-1, 1, 1, 1, 0.8, 0.8, 0.8)

This creates a rectangle with its lower left at point (1/72 inch)
coordinates (200, 600) that is 50 points high and 80 points wide
{lower left of page = (0,0)}. The outline is 0.3 points thick. The
shadow below the rectangle is 7.5 points thick. The shadow to the
right of the rectange is 8 points thick. The outline is mostly red.
The interior of the rectangle can be something other than white. The
fill color is chosen to be white. The shadow color is a light gray.

In pdf, the red, green and blue values range from 0 to 1 instead of
from 0 to 255 so the RGB values from, say, Paint can be divided by 255
to get close to the desired pdf color.

James A. Fortune
(e-mail address removed)
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top