The attached code is a simple (verbose) test showing some Quick PDF library basics. The code is based on snippets provided by Joe Byrne, as is, it generates a silly report and saves it to a file.
You will need to download the trial library, enter the trial key and provide a file/path to save the PDF.
The trial download link: http://www.quickpdflibrary.com/produ...kpdf/trial.php
I've attached the "silly" report produced by the code in case you don't want to compile...
You will need to download the trial library, enter the trial key and provide a file/path to save the PDF.
The trial download link: http://www.quickpdflibrary.com/produ...kpdf/trial.php
I've attached the "silly" report produced by the code in case you don't want to compile...

Code:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Quick PDF test, released to the public domain on March 1st, 2009 ' ' based on code snippets provided by Joe Byrne at the following link: ' http://www.powerbasic.com/support/pbforums/showthread.php?t=39904 ' ' this is (verbose) sample code, use at will but at your own risk ' ' compliled using PowerBASIC 9 for Windows ' tested on Windows XP SP3 ' no error checking provide ' ' Quick PDF library version 5.11 (download version) ' page numbers refer to the PDF version of the manual (5.11) ' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' #COMPILE EXE "QPDF_Test.exe" #DIM ALL #INCLUDE "iSQP0511PB.inc" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' FUNCTION PBMAIN( ) AS LONG FUNCTION = TestQuickPDF( ) END FUNCTION ' PBMAIN FUNCTION TestQuickPDF( ) AS LONG LOCAL Result AS LONG ' function returned result LOCAL Font_Bold AS LONG ' id of a non-standard bold font LOCAL Font_Body AS LONG ' id of font used for the report body LOCAL Font_Header AS LONG ' id of font used for the report header LOCAL ReportId AS LONG ' id of the report LOCAL ReportTitle AS ASCIIZ * 60 ' the title of the report LOCAL ReportFile AS ASCIIZ * 60 ' the full name of the file to be saved LOCAL AppLog AS STRING ' application result log ReportTitle$ = "FlowerBASIC Quick PDF Report (Test)" ' adjust to suit your system/needs ReportFile$ = "D:\Projects\QuickPDF_Test\PDF_Report.pdf" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' unlock the library Result& = iSEDUnlockKey( "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ) ' use your key here ' Unlocks the library. The library must be unlocked before it can be used. ' page 160 AppLog$ = "UnlockKey = " + STR$( Result& ) + $CRLF ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' add some standard fonts Font_Header& = iSEDAddStandardFont( 5 ) ' Helvetica bold AppLog$ += "AddStandardFont/Font_Header = " + STR$( Result& ) + $CRLF Font_Body& = iSEDAddStandardFont( 4 ) ' Helvetica ' Adds a standard font to the document. These standard fonts will always be ' available on all PDF viewers. ' page 107 AppLog$ += "AddStandardFont/Font_Body = " + STR$( Result& ) + $CRLF ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' add a non standard font Font_Bold& = iSedAddTrueTypeFont( "Arial Rounded MT Bold", 1 ) ' embed font ' Adds a TrueType font to the document. The font must be installed on the ' system. If the font is not embedded, then the reader of the PDF document ' must have the font installed on their system too. If font is embedded, ' then the reader does not need the font installed on their system. ' Embedding a font makes the PDF file much larger. Some fonts are not ' licensed to be embedded. ' page 109 AppLog$ += "AddTrueTypeFont/Font_Bold = " + STR$( Result& ) + $CRLF ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' create a new document ReportId& = iSedNewDocument( ) ' Creates a new blank document. 'page 30 AppLog$ += "NewDocument/Report Id = " + STR$( ReportId& ) + $CRLF ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' select the document to work on Result& = iSedSelectDocument( ReportID& ) ' Selects a document. ' page 32 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' set the measurement units Result& = iSedSetMeasurementUnits( 2 ) ' inches ' Set the units to use for all drawing functions. Default user space is ' exactly 1/72 inches per unit, which is approximately the same as a ' "point", a unit used in the printing industry. ' 25.4 millimetres is one inch. ' page 52 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' set the page size and orientation Result& = iSEDSetPageSize( "Letter" ) ' letter size, portrait mode ' Use this function to set the current page to a named size, for example ' "A4" or "Letter Landscape". ' page 209 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' set the page origin Result& = iSEDSetOrigin( 1 ) ' top left corner ' Sets the origin for all subsequent drawing operations. ' page 53 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' set the text colour Result& = iSEDSetTextColor( 0, 0, 0 ) ' Set default colors ' Sets the color for any subsequently drawn text. ' page 92 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' select a font to use Result& = iSEDSelectFont( Font_Header& ) ' select the header font ' Select one of the fonts which have been added to the selected document. ' The FontID must be a valid ID as returned by one of the Add*Font functions. ' page 114 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' select the font/text size Result& = iSEDSetTextSize( 14 ) ' font size ' Set the size of the text to use for any subsequently draw text. The text ' size is always measured in points, even if the measurement units have been ' changed with SetMeasurementUnits. ' page 97 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' select the text alignement Result& = iSEDSetTextAlign( 0 ) ' left aligned on the page ' Set the alignment of subsequent text drawn with the DrawText, ' DrawWrappedText or DrawMultiLineText functions. ' page 91 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' draw report tile text Result& = iSedDRAWTEXT( 0.5, 0.5, ReportTitle$ ) Result& = iSedDRAWTEXT( 6.0, 1.0, "Invoice #ABC-1234567" ) ' Draws text on the selected page, using the selected font at the ' predetermined font size. If no fonts have been added, then 12 pt ' Helvetica will automatically be added and selected. The alignment of the ' text can be changed with the SetTextAlign function. ' page 80 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' draw the lines iSedDrawLine( 0.25, 1.125, 8.25, 1.125 ) ' horizontal iSedDrawLine( 0.25, 1.25, 8.25, 1.25 ) ' horizontal iSedDrawLine( 6.0, 1.25, 6.0, 10.75 ) ' vertical iSedDrawLine( 0.25, 10.5, 8.25, 10.5 ) ' horizontal ' Draws a line between two points. ' page 65 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' more of the same Result& = iSEDSelectFont( Font_Body& ) ' select the body font Result& = iSEDSetTextSize( 8 ) ' font size ' line 1 Result& = iSedDRAWTEXT( 0.5, 1.5, "1215" ) Result& = iSedDRAWTEXT( 6.5, 1.5, "$1,341,236.00US" ) Result& = iSedDRAWTEXT( 1.0, 1.5, "FlowerBASIC Version 5343.01 (Win, Mac, OS9 and all *nix OS's)" ) ' line 2 Result& = iSedDRAWTEXT( 0.5, 1.75, "352" ) Result& = iSedDRAWTEXT( 1.0, 1.75, "FlowerFoil (one size fits all protective thinking hats)" ) Result& = iSedDRAWTEXT( 6.5, 1.75, "$2,373.00US" ) ' line 3 Result& = iSedDRAWTEXT( 0.5, 2.00, "352" ) Result& = iSedDRAWTEXT( 1.0, 2.00, "FlowerZap (high voltage, 10K volt, supply for FlowerFoil, a real user motivator!)" ) Result& = iSedDRAWTEXT( 6.5, 2.00, "$2,373.00US" ) ' line 4 Result& = iSedDRAWTEXT( 0.5, 2.25, "1215" ) Result& = iSedDRAWTEXT( 1.0, 2.25, "FlowerLeather (one size fits all leather T-Shirts... HOT geek magnet)" ) Result& = iSedDRAWTEXT( 6.5, 2.25, "$384,194.00US" ) ' line 5 Result& = iSEDSetTextColor( 1.0, 0, 0 ) Result& = iSedDrawLine( 0.25, 2.5, 8.25, 2.5 ) Result& = iSedDRAWTEXT( 1.0, 3.75, "Invoice is due on receit and payable in full, don't push it!" ) Result& = iSedDRAWTEXT( 1.0, 4.00, "Overdue invoices will result in buggy unmaintainable code" ) ' line 6 Result& = iSEDSelectFont( Font_Header& ) Result& = iSEDSetTextColor( 0, 0, 0.75 ) Result& = iSEDSetTextSize( 14 ) Result& = iSedDRAWTEXT( 5.0, 2.75, "TOTAL" ) Result& = iSedDRAWTEXT( 6.5, 2.75, "$152.48US" ) ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' save to a file file Result& = iSedSaveToFile( ReportFile$ ) ' Saves the selected document to a file on disk. ' page 30 AppLog$ += "SaveToFile = " + STR$( Result& ) + $CRLF ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' house cleaning, remove documentfrom memory Result& = iSedRemoveDocument( ReportId& ) ' Removes the specified document, freeing up memory. ' page 30 AppLog$ += "RemoveDocument = " + STR$( Result& ) + $CRLF MSGBOX AppLog$ ,, "App Log" FUNCTION = 0 END FUNCTION ' TestQuickPDF
Comment