Thread: Graphics to PDF
View Single Post
  #24  
Old February 9th, 2010, 08:50 PM posted to microsoft.public.access
arlene ramirez[_2_]
external usenet poster
 
Posts: 41
Default jeramie bellmay



arlene ramirez" wrote:

On Oct 23, 4:20 pm, Proposal Doctor
wrote:
I am interested in knowing which graphics format works best in Access 2007
when the destination is PDF. I have tried gif, jpeg, and tiff. And I have
tried copying a graphic directly from PowerPoint into an Access Report, which
works best.

Does anyone have a better solution? My problem is with an oval. It is
jagged. Text looks great.


For those creating PDF files directly from Access or from a PDF
creation tool (i.e., without using the A2K7 PDF Add-In), perhaps the
following solution for a vector ellipse will work until I come up with
something better.

Objective: Draw an ellipse centered at (X, Y) pts with eccentricity e
used to stretch a circle along the X-Axis using the existing brush
color, or (R,G,B) values if they are specified.

Although stretching out a circle is simpler than creating an ellipse
from scratch, it has a disadvantage that the width of the line also
stretches, making the boundary tenuous near the minor axis. That
might look O.K. for smaller ellipses or ones having only a slight
eccentricity (1 = perfectly round). I checked that the center of the
circle did not change when stretching by marking the center of the
original circle after the ellipse was created and the graphics
environment restored, but I didn't actually measure it on the printed
page, so it's possible that the origin moves when the circle is
stretched.

'Begin module code
Public Function DrawFlatEllipse(ByVal dblEccentricity As Double, ByVal
dblX As Double, ByVal dblY As Double, ByVal dblR As Double, ByVal
dblLineWidth As Double, Optional dblRed As Double = -1, Optional
dblGreen As Double, Optional dblBlue As Double) As String
Dim P1x As Double
Dim P1y As Double
Dim P1ux As Double
Dim P1uy As Double
Dim P1dx As Double
Dim P1dy As Double
Dim P2x As Double
Dim P2y As Double
Dim P2rx As Double
Dim P2ry As Double
Dim P2lx As Double
Dim P2ly As Double
Dim P3x As Double
Dim P3y As Double
Dim P3ux As Double
Dim P3uy As Double
Dim P3dx As Double
Dim P3dy As Double
Dim P4x As Double
Dim P4y As Double
Dim P4rx As Double
Dim P4ry As Double
Dim P4lx As Double
Dim P4ly As Double
Dim strTemp As String
Dim strCR As String

strCR = Chr(13)
P1x = dblX + dblR
P1y = dblY
P1ux = P1x
P1uy = P1y + CRatio * dblR
P1dx = P1x
P1dy = P1y - CRatio * dblR
P2x = dblX
P2y = dblY + dblR
P2rx = P2x + CRatio * dblR
P2ry = P2y
P2lx = P2x - CRatio * dblR
P2ly = P2y
P3x = dblX - dblR
P3y = dblY
P3ux = P3x
P3uy = P3y + CRatio * dblR
P3dx = P3x
P3dy = P3y - CRatio * dblR
P4x = dblX
P4y = dblY - dblR
P4rx = P4x + CRatio * dblR
P4ry = P4y
P4lx = P4x - CRatio * dblR
P4ly = P4y
strTemp = "q" & strCR
strTemp = strTemp & CStr(dblLineWidth) & " w" & strCR
If dblRed -1 Then
strTemp = strTemp & CStr(dblRed) & " " & CStr(dblGreen) & " " & CStr
(dblBlue) & " rg" & strCR
End If
'Set a new graphics origin at P4x, P3y
strTemp = strTemp & "1 0 0 1 " & CStr(P4x) & " " & CStr(P3y) & " cm" &
strCR
'Change the scale in the x direction, use dblEccentricity
strTemp = strTemp & CStr(Round(1 / dblEccentricity, 4)) & " 0 0 1 0 0
cm" & strCR
'Move to the right side of the circle
strTemp = strTemp & CStr(P1x - P4x) & " " & CStr(P1y - P3y) & " m" &
strCR
strTemp = strTemp & CStr(P1ux - P4x) & " " & CStr(P1uy - P3y) & " " &
CStr(P2rx - P4x) & " " & CStr(P2ry - P3y) & " " & CStr(P2x - P4x) & "
" & CStr(P2y - P3y) & " c" & strCR
strTemp = strTemp & CStr(P2lx - P4x) & " " & CStr(P2ly - P3y) & " " &
CStr(P3ux - P4x) & " " & CStr(P3uy - P3y) & " " & CStr(P3x - P4x) & "
" & CStr(P3y - P3y) & " c" & strCR
strTemp = strTemp & CStr(P3dx - P4x) & " " & CStr(P3dy - P3y) & " " &
CStr(P4lx - P4x) & " " & CStr(P4ly - P3y) & " " & CStr(P4x - P4x) & "
" & CStr(P4y - P3y) & " c" & strCR
strTemp = strTemp & CStr(P4rx - P4x) & " " & CStr(P4ry - P3y) & " " &
CStr(P1dx - P4x) & " " & CStr(P1dy - P3y) & " " & CStr(P1x - P4x) & "
" & CStr(P1y - P3y) & " c" & strCR
strTemp = strTemp & "S" & strCR
strTemp = strTemp & "Q" & strCR
DrawFlatEllipse = strTemp
End Function
'End module code

How I made the layout for importation into the PDFLayoutViewer
database:

'Begin code behind form
Private Sub cmdMakeFlatEllipse_Click()
Dim strOut As String
Dim strFileOut As String

strFileOut = "C:\FlatEllipseLayout.txt"
strOut = DrawFlatEllipse(0.5, 200, 350, 50, 1.35, 0.7, 0.3, 0.5)
Open strFileOut For Output As #1
Print #1, strOut
Close
MsgBox ("Done.")
End Sub
'End code behind form

A sample output PDF file (produced from A97) is available at:

https://files.oakland.edu/users/fort...latEllipse.pdf

I used the Landscape option that I recently added to my
PDFLayoutViewer database. The vector based curves look good even at a
6400% PDF zoom level. Perhaps I can come up with something better in
time. The fact that Bezier curves must be used to create ellipses
having constant line widths in PDF documents complicates their
creation. To create a circle using Bezier curves, I used a technique
found at:

http://www.tinaja.com

James A. Fortune


Disclaimer: Any programming examples shown are for illustration
purposes only, without warranty either expressed or implied. This
includes, but is not limited to, the implied warranties of
merchantability or fitness for a particular purpose. This post assumes
that you are familiar with the programming language that is being
demonstrated and with the tools that are used to create and to debug
procedures. I might explain the functionality of a particular
procedure, but I am under no obligation to modify these examples to
provide added functionality or to construct procedures to meet your
specific requirements. Any code samples posted contain no known
hidden material defects. However, anyone who uses any code sample
posted does so with the understanding that they are responsible for
any testing of any illustrative code sample for any particular use.
Furthermore, anyone using an illustrative code sample I provide or
code derived from it does so at their own risk.
.