Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Feedback on VFP->PDF utiliites
Message
From
19/10/2002 17:05:06
Peter Easson
Catalina Trading
Sydney, Australia
 
General information
Forum:
Visual FoxPro
Category:
Third party products
Miscellaneous
Thread ID:
00712270
Message ID:
00713230
Views:
54
Gerard,
IsedQuickPDF IS a dll solution, lightweight and fast. The only caveat is that you will need to create the wrapper classes for use in VFP, but once said and done, it's very easy to use and create PDF documents on the fly WITHOUT any PDF print drivers etc etc.

Here is a quick example when I was playing with it...

# DEFINE d_AlignLeft 0
# DEFINE d_AlignCentre 1
# DEFINE d_AlignRight 2
# DEFINE d_AlignJustify 3
# DEFINE d_LeftM 72 && points = 1 inch
# DEFINE d_RightM 72
# DEFINE d_TopM 72
# DEFINE d_BottomM 72
# DEFINE d_FontSize 12
# DEFINE Twips2Pts 1/20
CLEAR
set path to c:\galaxypos\pdf\

PRIVATE nCurrentX,nCurrentY,nMaxWidth,aValues
Dimension aValues[20]
for m.i = 1 to 20
aValues[m.i] = transform(m.i)
endfor

oPDF = CreateObject("iSED.QuickPDF")
*? vartype(oPDF)
With oPDF
.UnlockKey("You need to get this from them")

*? .Unlocked()
? oPDF.NewDocument()
Endwith
cStr = "This is documentation for installing Apache 1.3.9 , PHP 3.011, Perl 5.00502 and MySQL 3.21.29, " +;
"but should work with ANY recent (or more recent) versions of this software. Note if you have ActiveState " +;
"for Perl installed, either uninstall it, or skip the installation section below for Perl, simply make sure the " +;
"the shebang line (the first line of your Perl script) points to the path of the ActiveState file 'perl.exe'. " +;
"See more in Step Two below. The ability to develop locally on my laptop has been a fantastic time saver. " +;
"Saving, uploading and testing to a remote server is an arduous task. It's easier to develop locally and then " +;
"upload once everything is tested.Configuring for Windows is easy,but the documentation for " +;
"installation from the software companies is hideous. "


With oPDF
*.SetInformation
.SetPageDimensions((11911*72)/1440,(16832*72)/1440) &&convert to points
nCurrentY = .PageHeight - d_TopM
nCurrentX = d_LeftM
nMaxWidth = .PageWidth - d_LeftM - d_RightM
.AddTrueTypeFont("Arial",.t.)

AddPara(oPDF,@cStr,d_AlignJustify,8,1,0,1)
AddTable(oPDF,5,4,0,15)

.SaveToFile("C:\Windows\Desktop\IsedTest.pdf")



EndWith

FUNCTION AddTable(oObj,nRows,nCols,nFill,nBorderWidthTwips)
local aDrawLines,nLines,i,mTableH,mTableW,mXInc,aRows,y,nDown,aText,mStartX,mStartY
&& aDrawLines StartX,StartY,EndX,EndY
&& Calculate total Table Height from summing row PointSizes
Dimension aDrawLines[nRows + nCols,4]
Dimension aRows[5]
Dimension aText[nRows * nCols,3] && Text as xPos,yPos,cText
aRows[1] = 8
aRows[2] = 8
aRows[3] = 8
aRows[4] = 8
aRows[5] = 8
mTableH = 8 + 8 + 8 + 8 + 8 && example
mTableW = nMaxWidth - nCurrentX + d_LeftM
mStartX = nCurrentX
mStartY = nCurrentY

&& Now work out vertical lines
mXInc = mTableW/nCols
for m.i = 1 to nCols
aDrawLines[m.i,1] = nCurrentX + (m.i * mXInc)
aDrawLines[m.i,2] = nCurrentY
aDrawLines[m.i,3] = nCurrentX + (m.i * mXInc)
aDrawLines[m.i,4] = nCurrentY - mTableH
endfor
&& Now add horizontal lines
nDown = 0
m.y = 1
for m.i = nCols + 1 to nRows + nCols
aDrawLines[m.i,1] = nCurrentX
nDown = nDown + aRows[m.y]
aDrawLines[m.i,2] = nCurrentY - nDown
aDrawLines[m.i,3] = nCurrentX + mTableW
aDrawLines[m.i,4] = nCurrentY - nDown
m.y = m.y + 1
endfor
&& Now Add Text as xPos,yPos,cText
m.y = 0
for m.i = 1 to nRows * nCols
nPoints = oObj.GetTextWidth(aValues[m.i]) + 2 && Add an extra 2 points
*aText[m.i,1] = nCurrentX + (m.y * mXInc) + mXInc - nPoints && right align and move left 15 points
aText[m.i,1] = nCurrentX + (m.y * mXInc) + mXInc/2 - nPoints && move right centre align
aText[m.i,2] = mStartY - 8 + 1 && move up 1 points into grid
aText[m.i,3] = aValues[m.i]
if m.y = nCols -1
m.y = 0
mStartY = mStartY - 8
else
m.y = m.y + 1
endif
endfor
With oObj
.SetLineWidth(nBorderWidthTwips* Twips2Pts)
.SetFillColor(0.7,0.7,0.7)
nFill = 2
.DrawBox(nCurrentX,nCurrentY,mTableW,mTableH,nFill)
for m.i = 1 to nRows * nCols
.DrawText(aText[m.i,1],aText[m.i,2],aText[m.i,3])
endfor

for m.i = 1 to nCols + nRows
.DrawLine(aDrawLines[m.i,1],aDrawLines[m.i,2],aDrawLines[m.i,3],aDrawLines[m.i,4])
endfor
EndWith
ENDFUNC


FUNCTION AddPara(oObj,cStr,nAlign,nPointSize,nR,nG,nB)
local nTextHeight,cX,mLines
With oObj
.SetTextAlign(nAlign)
.SetTextSize(nPointSize)
.SetTextColor(nR,nG,nB)
nTextHeight = .GetWrappedTextHeight(nMaxWidth,cStr)
if (nCurrentY - nTextHeight) > 0 && fits on page
.DrawWrappedText(nCurrentX,nCurrentY,nMaxWidth,cStr)
nCurrentY = nCurrentY - nTextHeight - nPointSize && add a paragraph space
else
&& How many lines can we print?

mLines = nTextHeight - nCurrentY && the 'over' position
&& Can Print && number of lines && the lines over
mLines = (nTextHeight / nPointSize) - (mLines/nPointSize)
cX = .GetWrappedText(nMaxWidth,'#',cStr)
cY = substr(cX,at("#",cX,mLines))
cX = substr(cX,1,at("#",cX,mLines))
cX = strtran(cX,"#","")
cY = strtran(cY,"#","")
.DrawWrappedText(nCurrentX,nCurrentY,nMaxWidth,cX)
.NewPage
nCurrentY = .PageHeight - d_TopM
AddPara(oObj,cY,nAlign,nPointSize,nR,nG,nB)
*!* .DrawWrappedText(nCurrentX,nCurrentY,nMaxWidth,cY)
*!* nTextHeight = .GetWrappedTextHeight(nMaxWidth,cY)
*!* nCurrentY = nCurrentY - nTextHeight - nPointSize
endif
EndWith
ENDFUNC

Basically, if users were willing to share their Functions/Procedures they have developed with this library, it would be very quick to produce a wrapper that would allow VFP programmers to produce anything in PDF without the limitations and constraints of the crippled VFP report designer AND, all for only 50 bucks each!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform