Been having some more fun testing the latest Quick PDF 7.12 release (beta 2). The following code show some of the changes, please read the comments at the top of the code. I've also posted a new PDF file showing the output from the code.
This is a really powerful and simple to use library, please, feel free to add more samples/examples.
This is a really powerful and simple to use library, please, feel free to add more samples/examples.
Code:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Quick PDF library version 7.12 (beta 2) test ' ' sample code released to the public domain on March 1st, 2009 ' use where and how you will but, always at your own risk ' ' based on code snippets provided by Joe Byrne at the following link: ' http://www.powerbasic.com/support/pbforums/showthread.php?t=39904 ' ' compliled using PowerBASIC 9.01 for Windows ' tested on Windows XP SP3 ' no error checking provide ' ' WARNING: the PowerBASIC include (QuickPDFDLL0712.inc) provided with beta 2 has ' errors and will not compile as is. I found and corrected some but there are over ' 500 functions and I've not tested them all. My corrected file compiles and ' I'll be forwarding it to Quick PDF. ' ' IMPORTANT: the prefix for all function names has changed from "iSED" to "QuickPDF" ' and you must now use the function "QuickPDFCreateLibrary( )" to get the "library ' instance id", this value is required by all other functions ' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' #COMPILE EXE "QPDF_712_Test.exe" #DIM ALL #INCLUDE "QuickPDFDLL0712.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 LibInstance AS LONG ' id of library instance LOCAL LogoId AS LONG ' id of logo picture LOCAL ReportTitle AS ASCIIZ * 70 ' the title of the report LOCAL ReportFile AS ASCIIZ * 70 ' the full name of the file to be saved LOCAL AppLog AS STRING ' application result log ReportTitle$ = "Quick PDF Test Report" ' adjust to suit your system/needs ReportFile$ = "D:\Projects\QuickPDF_712_Test\PDF_Report.pdf" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' NEW: create a libray instance, all other functions use the return value ' from this function LibInstance& = QuickPDFCreateLibrary( ) AppLog$ = "CreateLibrary = " + STR$( LibInstance& ) + $CRLF ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' unlock the library, use your key here Result& = QuickPDFUnlockKey( LibInstance&, "put your key here" ) AppLog$ += "UnlockKey = " + STR$( Result& ) + $CRLF ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' add some standard fonts Font_Header& = QuickPDFAddStandardFont( LibInstance&, 5 ) ' Helvetica bold AppLog$ += "AddStandardFont/Font_Header = " + STR$( Font_Header& ) + $CRLF Font_Body& = QuickPDFAddStandardFont( LibInstance&, 4 ) ' Helvetica AppLog$ += "AddStandardFont/Font_Body = " + STR$( Font_Body& ) + $CRLF ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' add a non standard font Font_Bold& = QuickPDFAddTrueTypeFont( LibInstance&, "Arial Rounded MT Bold", 1 ) ' embed font AppLog$ += "AddTrueTypeFont/Font_Bold = " + STR$( Font_Bold& ) + $CRLF ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' create a new document ReportId& = QuickPDFNewDocument( LibInstance& ) AppLog$ += "NewDocument/Report Id = " + STR$( ReportId& ) + $CRLF ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' select the document to work on Result& = QuickPDFSelectDocument( LibInstance&, ReportID& ) ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' set the measurement units Result& = QuickPDFSetMeasurementUnits( LibInstance&, 2 ) ' inches ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' set the page size and orientation Result& = QuickPDFSetPageSize( LibInstance&, "Letter" ) ' letter size, portrait mode ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' set the page origin Result& = QuickPDFSetOrigin( LibInstance&, 1 ) ' top left corner ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' set the text colour Result& = QuickPDFSetTextColor( LibInstance&, 0, 0, 0 ) ' Set default colors ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' select a font to use Result& = QuickPDFSelectFont( LibInstance&, Font_Header& ) ' select the header font ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' select the text alignement Result& = QuickPDFSetTextAlign( LibInstance&, 0 ) ' left aligned on the page ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' load an image from file LogoId& = QuickPDFAddImageFromFile( LibInstance&, "D:\Projects\QuickPDF_712_Test\LogoEye.jpg", 0 ) AppLog$ += "AddImageFromFile = " + STR$( LogoId& ) + $CRLF ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' select the image Result& = QuickPDFSelectImage( LibInstance&, LogoId&) AppLog$ += "SelectImage = " + STR$( Result& ) + $CRLF ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' draw the image on the page Result& = QuickPDFDrawImage( LibInstance&, 0.25, 0.25, 3.0, 2.0 ) AppLog$ += "DrawImage = " + STR$( Result& ) + $CRLF ' Result& = QuickPDFDrawScaledImage( LibInstance&, 0.25, 0.25, 1) ' AppLog$ += "DrawScaledImage = " + STR$( Result& ) + $CRLF ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' select the font/text size Result& = QuickPDFSetTextSize( LibInstance&, 30 ) ' font size ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' draw report tile text Result& = QuickPDFDRAWTEXT( LibInstance&, 3.50, 0.75, ReportTitle$ ) Result& = QuickPDFSetTextSize( LibInstance&, 14 ) ' font size Result& = QuickPDFSetTextColor( LibInstance&, 1.0, 0, 0 ) ' change text colour to red Result& = QuickPDFDRAWTEXT( LibInstance&, 6.5, 2.25, "7.12 Beta #2" ) Result& = QuickPDFSetTextColor( LibInstance&, 0, 0, 0 ) ' change text colour to black ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' add a barcode, 3 of 9 Result& = QuickPDFDrawBarcode( LibInstance&, 6, 1.5, 2.0, 0.5, "7.12 Beta #2", 1, 0 ) ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' draw some lines QuickPDFDrawLine( LibInstance&, 0.25, 2.50, 8.25, 2.5 ) ' horizontal QuickPDFDrawLine( LibInstance&, 0.25, 2.75, 8.25, 2.75 ) ' horizontal QuickPDFDrawLine( LibInstance&, 6.0, 2.755, 6.0, 10.75 ) ' vertical QuickPDFDrawLine( LibInstance&, 0.25, 10.5, 8.25, 10.5 ) ' horizontal ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' add a water mark Result& = QuickPDFSelectFont( LibInstance&, Font_Bold& ) ' select bold font Result& = QuickPDFSetTextSize( LibInstance&, 75 ) ' select font size Result& = QuickPDFSetTransparency( LibInstance&, 99 ) ' add transparency Result& = QuickPDFDrawRotatedText( LibInstance&, 1.0, 9.0, 45, "Sample Report" ) ' rotate text Result& = QuickPDFSetTransparency( LibInstance&, 0 ) ' remove transparency ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' save to a file file Result& = QuickPDFSaveToFile( LibInstance&, ReportFile$ ) AppLog$ += "SaveToFile = " + STR$( Result& ) + $CRLF ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' house cleaning, remove document from memory Result& = QuickPDFRemoveDocument( LibInstance&, ReportId& ) AppLog$ += "RemoveDocument = " + STR$( Result& ) + $CRLF ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' house cleaning, remove library from memory Result& = QuickPDFReleaseLibrary( LibInstance& ) AppLog$ += "ReleaseLibrary = " + STR$( Result& ) + $CRLF MSGBOX AppLog$ ,, "App Log" FUNCTION = 0 END FUNCTION ' TestQuickPDF
Comment