Announcement

Collapse
No announcement yet.

Exploring Quick PDF version 7.12

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Exploring Quick PDF version 7.12

    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.

    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
    Attached Files
    Regards,
    Marc

    #2
    PDF meets DDT

    More fun, now we display a PDF in a graphic window with 4 lines of code. Needs Win XP or add GDI+ to the application directory. I've included the exe (zip).

    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 "PDF_To_Window.exe"
    #DIM ALL
    #INCLUDE "QuickPDFDLL0712_Corrected.inc"
    
    
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    FUNCTION PBMAIN( ) AS LONG
    LOCAL PDFCanvas AS DWORD ' handle to the graphic window
    
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' create a graphic window
    	GRAPHIC WINDOW "PDF Canvas", 0, 0, 1000, 1000 TO PDFCanvas
    
    
    	FUNCTION = TestQuickPDF( PDFCanvas )
    
    END FUNCTION ' PBMAIN
    
    FUNCTION TestQuickPDF( PDFCanvasHdl AS DWORD ) 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
    LOCAL AppPath			AS STRING ' application path
    LOCAL PDFCanvasDC	AS DWORD ' graphic window dc
    
    AppPath$ = EXE.Path$
    
    ' adjust to suit your system/needs
    ReportFile$ = AppPath$ + "\PDF_Report.pdf"
    
    ReportTitle$ = "Quick PDF Test Report"
    
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' 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&, "add 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&, AppPath$ + "\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
    
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' display PDF to a graphic window
    	GRAPHIC ATTACH PDFCanvasHdl, 0, REDRAW
    	GRAPHIC GET DC TO PDFCanvasDC
    	Result& = QuickPDFRenderPageToDC( LibInstance&, 80, ReportID&, PDFCanvasDC )
    	GRAPHIC REDRAW
     
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' 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"
    
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' destroy the graphic window
    	GRAPHIC WINDOW END
    
    FUNCTION = 0
    
    END FUNCTION ' TestQuickPDF
    Attached Files
    Last edited by Marc Giao; 9 Mar 2009, 12:20 AM. Reason: Removed hard coded path
    Regards,
    Marc

    Comment


      #3
      Translated Icludefile for QuickPDFlibrary v.712

      Looks very nice Marc, is it possible that you can share the so fare translated headerfile QuickPDFDLL0712.inc?

      thanks,

      -Kim

      Comment


        #4
        Kim.

        I have fixed the Beta2 inc-file and changed about 50 or more errors.
        I kept the original filename instead.

        QuickPDF is a very nice tool, but I think it will take some time
        before it is fully reliable with PBasic.
        Attached Files
        sigpic
        Regards,
        Hans Rietveld.

        Comment


          #5
          Kim,

          Thanks. Looks like Hans beat me to it and he appears to have found a few more issues with the file.
          Regards,
          Marc

          Comment


            #6
            Hans,

            Thanks for the updated file. Did you forward your corrections on to Rowan at Quick PDF?

            Originally posted by Hans Rietveld View Post
            ...I think it will take some time before it is fully reliable with PBasic.
            Have you found reliability issues with the library?
            Last edited by Marc Giao; 9 Mar 2009, 11:52 AM. Reason: Fat finger issue
            Regards,
            Marc

            Comment


              #7
              Marc.

              I have mailed my corrections to Rowan. As far as I know is he reading the
              posting on this site, so I believe he has got the information.

              Have you found reliability issues with the library?
              The include file is generated by using a software program. However,
              It shows that this is not an error - free process.
              The result will always be able to contain errors.
              The include file must be manually checked and improved.
              There are hundreds of lines and will probably never without errors.

              I think it is a better way to use the ActiveX edition of the DLL.
              This is a standard interface and used by much more users.
              As the new PBasic compilers make it easy to use this mode,
              I have translate the example from Marc to the com version.

              To use this version you must use the ActiveX version 7.12 DLL Beta2.
              This dll must be registered.
              With the Pb-Com browser must the interface be created.
              I have add mine to this posting. You must fill in your licensecode in the file.

              Here is my modified code from Marc's file.

              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 SP2
              ' no error checking provide
              '
              ' Quick PDF activeX version 7.12 Beta2 (download version)
              ' page numbers refer to the PDF version of the manual (7.12)
              '
              '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
              
              #COMPILE EXE "QPDF_Test.exe"
              #DIM ALL
              
              ' Build includefile with Pb com browser
              #INCLUDE  "iSED712.inc"
              
              '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
              FUNCTION PBMAIN( ) AS LONG
              
                  LOCAL PDFCanvas AS DWORD ' handle to the graphic window
              
                  ' create a graphic window
                  GRAPHIC WINDOW "QPDF - Demo", 0, 0, 700, 900 TO PDFCanvas
                  TestQuickPDF( PDFCanvas )
              
              END FUNCTION ' PBMAIN
              
              
              '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
              
              FUNCTION TestQuickPDF( PDFCanvasHdl AS DWORD ) 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
              LOCAL InstanceID         AS LONG
              LOCAL LogoId             AS LONG
              LOCAL PDFCanvasDC        AS DWORD ' graphic window dc
              
              '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
              ReportTitle = "FlowerBASIC Quick PDF Report (Test)"
              
              ' adjust to suit your system/needs
              ReportFile = "PDF_Report.pdf"
              
              '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
                  ' create object
              LOCAL oQuickpdf AS Int_IPDFLibrary
              
                  LET oQuickpdf = NEWCOM CLSID $CLSID_QuickPDFAX0712_PDFLibrary
              
                  ' Is object valid
                  IF ISFALSE ISOBJECT(oQuickpdf) THEN
                      MSGBOX "Unable to open or start Ised712.dll!"
                      EXIT FUNCTION
                  END IF
              
              
              ' unlock the library
                  Result = oQuickPDF.UnlockKey (UCODE$("insert your license key here")) ' use your key here !!!!!!!!!!!!!!!!!
                      ' Unlocks the library. The library must be unlocked before it can be used.
                      ' page 160
              
                  Result = oQuickPDF.Unlocked
                      AppLog = "UnlockKey = " + STR$( Result ) + $CRLF
              
              '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
              ' add some standard fonts
                  Font_Header = oQuickPDF.AddStandardFont( 5 )     ' Helvetica bold
              
                  AppLog + = "AddStandardFont/Font_Header = " + STR$( Result ) + $CRLF
              
                  Font_Body   = oQuickPDF.AddStandardFont( 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 = oQuickPDF.AddTrueTypeFont("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   = oQuickPDF.NewDocument
                      ' Creates a new blank document.
                      'page 30
              
                  AppLog + = "NewDocument/Report Id = " + STR$( ReportId ) + $CRLF
              
              
              '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
              ' set the measurement units
                  Result     = oQuickPDF.SetMeasurementUnits( 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 = oQuickPDF.SetPageSize( UCODE$("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 = oQuickPDF.SetOrigin( 1 ) ' top left corner
                      ' Sets the origin for all subsequent drawing operations.
                      ' page 53
              
              '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
              ' set the text colour
                  Result = oQuickPDF.SetTextColor( 0, 0, 0 ) ' Set default colors
                      ' Sets the color for any subsequently drawn text.
                      ' page 92
              
              '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
              ' select a font to use
                  Result  = oQuickPDF.SelectFont( 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  = oQuickPDF.SetTextSize( 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  = oQuickPDF.SetTextAlign( 0 ) ' left aligned on the page
                      ' Set the alignment of subsequent text drawn with the DrawText,
                      ' DrawWrappedText or DrawMultiLineText functions.
                      ' page 91
              
              '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
              ' load an image from file
                  LogoId = oQuickPDF.AddImageFromFile( UCODE$("LogoEye.jpg"), 0 )
                      AppLog + = "AddImageFromFile = " + STR$( LogoId ) + $CRLF
              
              '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
              ' select the image
                  Result = oQuickPDF.SelectImage( LogoId)
                      AppLog + = "SelectImage = " + STR$( Result ) + $CRLF
              
              '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
              ' draw the image on the page
                  Result = oQuickPDF.DrawImage( 0.25, 0.25, 3.0, 2.0 )
                      AppLog + = "DrawImage = " + STR$( Result) + $CRLF
              
                 Result = oQuickPDF.DrawScaledImage( 0.25, 0.25, 0.75)
                     AppLog + = "DrawScaledImage = " + STR$( Result) + $CRLF
              
              '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
              ' draw report tile text
                  Result = oQuickPDF.DRAWTEXT( 4.75, 0.75, UCODE$(ReportTitle))
                  Result = oQuickPDF.DRAWTEXT( 6.0, 2.0, UCODE$("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
                  oQuickPDF.DrawLine( 0.25, 2.50, 8.25, 2.5 ) ' horizontal
                  oQuickPDF.DrawLine( 0.25, 2.75, 8.25, 2.75 ) ' horizontal
                  oQuickPDF.DrawLine( 6.0, 2.755, 6.0, 10.75 ) ' vertical
                  oQuickPDF.DrawLine( 0.25, 10.5, 8.25, 10.5 ) ' horizontal
                   ' Draws a line between two points.
                   ' page 65
              
              '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
              ' add a barcode, 3 of 9
                  Result = oQuickPDF.DrawBarcode( 6, 1.0, 2.0, 0.5, UCODE$("7.12 Beta #2"), 1, 0 )
              
              '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
              ' more of the same
                  Result  = oQuickPDF.SelectFont( Font_Body ) ' select the body font
                  Result  = oQuickPDF.SetTextSize( 8 ) ' font size
                  ' line 1
                  Result = oQuickPDF.DRAWTEXT( 0.5, 3.0, UCODE$("1215" ))
                  Result = oQuickPDF.DRAWTEXT( 6.5, 3.0, UCODE$("$1,341,236.00US" ))
                  Result = oQuickPDF.DRAWTEXT( 1.0, 3.0, UCODE$("FlowerBASIC Version 5343.01 (Win, Mac, OS9 and all *nix OS's)" ))
                  ' line 2
                  Result = oQuickPDF.DRAWTEXT( 0.5, 3.25, UCODE$(" 352" ))
                  Result = oQuickPDF.DRAWTEXT( 1.0, 3.25, UCODE$("FlowerFoil (one size fits all protective thinking hats)" ))
                  Result = oQuickPDF.DRAWTEXT( 6.5, 3.25, UCODE$("$2,373.00US" ))
                  ' line 3
                  Result = oQuickPDF.DRAWTEXT( 0.5, 3.50, UCODE$(" 352" ))
                  Result = oQuickPDF.DRAWTEXT( 1.0, 3.50, UCODE$("FlowerZap (high voltage, 10K volt, supply for FlowerFoil, a real user motivator!)" ))
                  Result = oQuickPDF.DRAWTEXT( 6.5, 3.50, UCODE$("$2,373.00US" ))
                  ' line 4
                  Result = oQuickPDF.DRAWTEXT( 0.5, 3.75, UCODE$("1215" ))
                  Result = oQuickPDF.DRAWTEXT( 1.0, 3.75, UCODE$("FlowerLeather (one size fits all leather T-Shirts... HOT geek magnet)" ))
                  Result = oQuickPDF.DRAWTEXT( 6.5, 3.75, UCODE$("$384,194.00US" ))
                  ' line 5
                  Result = oQuickPDF.SetTextColor( 1.0, 0, 0 )
                  Result = oQuickPDF.DrawLine( 0.25, 2.5, 8.25, 2.5 )
                  Result = oQuickPDF.DRAWTEXT( 1.0, 9.75, UCODE$("Invoice is due on receit and payable in full, don't push it!" ))
                  Result = oQuickPDF.DRAWTEXT( 1.0,10.00, UCODE$("Overdue invoices will result in buggy unmaintainable code" ))
                  ' line 6
                  Result = oQuickPDF.SelectFont( Font_Header )
                  Result = oQuickPDF.SetTextColor( 0, 0, 0.75 )
                  Result = oQuickPDF.SetTextSize( 14 )
                  Result = oQuickPDF.DRAWTEXT( 5.0, 10.75, UCODE$("TOTAL" ))
                  Result = oQuickPDF.DRAWTEXT( 6.5, 10.75, UCODE$("$152.48US" ))
              
              '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
              ' save to a file file
                  Result = oQuickPDF.SaveToFile( UCODE$(ReportFile) )
              
                  ' Saves the selected document to a file on disk.
                  ' page 30
              
                  AppLog + = "SaveToFile = " + STR$( Result ) + $CRLF
                                                                                     
              '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
              ' display PDF to a graphic window
              
                  GRAPHIC ATTACH PDFCanvasHdl, 0 ', REDRAW
                  GRAPHIC GET DC TO PDFCanvasDC
                  Result = oQuickPDF.RenderPageToDC( 80, ReportID, PDFCanvasDC )
                  GRAPHIC REDRAW
              
              '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
              ' house cleaning, remove documentfrom memory
                  Result = oQuickPDF.RemoveDocument( ReportId)
                  ' Removes the specified document, freeing up memory.
                  ' page 30
              
                  AppLog + = "RemoveDocument = " + STR$( Result ) + $CRLF
              
              '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
              ' release comserver, release memory, remove graphic window
              
                  MSGBOX "License info:" & $CRLF & ACODE$(oQuickPDF.LicenseInfo) & $CRLF & _
                  AppLog ,, "App Log"
              
                  GRAPHIC WINDOW END
                  SET oQuickpdf = NOTHING
                  FUNCTION = 0
              
              END FUNCTION ' TestQuickPDF
              The result is about the same as the DLL version, but I think more reliable
              and easier to use.

              You will find the "LogoEye.jpg" in the last posting from Marc.
              Attached Files
              sigpic
              Regards,
              Hans Rietveld.

              Comment


                #8
                Updated include files received

                Hi Guys,

                Just confirming that we've received the updated include files and our developers will make these changes (as well as some others) in the official include files before the next release -- which should be within a week.

                March, Hans, the samples look great. I'm sure people will find them very useful.

                Cheers,
                Rowan
                __________________________________
                Quick PDF Library
                www.quickpdflibrary.com
                The Unrivaled PDF Developer Toolkit™

                Comment

                Working...
                X
                😀
                🥰
                🤢
                😎
                😡
                👍
                👎