Language Support for Clarion

To use the Image to PDF DLL with Clarion you will need to use the Clarion specific files as outlined below:

  • Put "Image2PDF Clarion.lib", "Image2PDF.inc" and "Image2PDF.DLL" into your Clarion application directory
  • Load your Clarion Application into the Clarion IDE
  • Under Project/Properties > "Library, object, and resource files", press the "Add File" button to add "Image2PDF Clarion.lib"
  • Under Application/Global/Embeds > "Inside the Global Map", add: INCLUDE('Image2PDF.inc')


  • Here is an example code snippet for Clarion (kindly provided by Sylvain Provencher of VertiSoft):

    PreparerPDF   ROUTINE
    
    !Title variable: title of the report -> pdf file name
    !QueueWMF: Queue containing list of ".tmp" files produced by Clarion report engine
    
      DATA
    
    !Translate Off
    NomFicherPDF        CSTRING(200)
    Resul               LONG
    MessErr             CSTRING(200)
    CodeLicence         CSTRING('YOUR LICENSE CODE HERE')
    logfile             CSTRING('.\Pdf\PdfLogFile.txt')
    ImageExtensionWmf   CSTRING('.wmf')
    TempSubFolderName   CSTRING('.\Pdf')
    !Translate On
    
      CODE
      IF RECORDS(QueueWMF) = 0
        EXIT
      .
    
      NoVersionConvertisseurPDF = I2PDF_GetDLLVersion() / 100
    
      ! Prepare PDF filename
      NomFicherPDF = ''
      IF Title
        LOOP I = 1 TO LEN(Title)
          IF Title [I] = ' '
            NomFicherPDF = NomFicherPDF & '_'
    !Translate Off
          ELSIF INSTRING(UPPER(Title [I]), '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-') OR INSTRING(Title [I], 'àâéèêëîôùûüÀÂÉÈÊËÎÔÙÛÜ')
    !Translate On
            NomFicherPDF = NomFicherPDF & Title [I]
          .
    
          IF LEN(NomFicherPDF) > SIZE(NomFicherPDF) - 5  ! Keep sapce for ".pdf"
            BREAK
          .
        .
      .
    
      IF NOT NomFicherPDF
        NomFicherPDF = 'Report'
      .
    
      !Translate Off
      NomFicherPDF = NomFicherPDF & '.pdf'
      !Translate On
    
      ! Creating PDF
      Resul = 0
      SETCURSOR(CURSOR:Wait)
      I2PDF_Reset()
      I2PDF_License(CodeLicence)
      I2PDF_MetaToNativePDF()
      I2PDF_SetBorderColor_Int(255,255,255)
      I2PDF_SetBorder(37, 25, 0, 0)
    
      Resul = I2PDF_TreatImageTmpExtensionAs(ImageExtensionWmf)
      IF Resul <> 0
        CASE Resul
        OF 1
          MessErr = 'invalid imageExtension parameter (I2PDF_TreatImageTmpExtensionAs)'
        ELSE
          MessErr = 'Erreur inconnue (I2PDF_TreatImageTmpExtensionAs) #' & Resul
        .
      .
    
      IF Resul = 0
        LOOP I = 1 TO RECORDS(QueueWMF)
          GET(QueueWMF, I)
          Resul = I2PDF_AddImage(FichierWmf)
          IF Resul <> 0
            CASE Resul
            OF 1
              MessErr = 'invalid parameter (I2PDF_AddImage)'
            OF 2
              MessErr = 'maximum number of images already added (I2PDF_AddImage)'
            OF 3
              MessErr = 'invalid image type (I2PDF_AddImage)'
            ELSE
              MessErr = 'Erreur inconnue (I2PDF_AddImage) #' & Resul
            .
            BREAK
          .
        .
      .
    
      IF Resul = 0
        Resul = I2PDF_SetDPI(0)
        IF Resul <> 0
          CASE Resul
          OF 1
            MessErr = 'invalid parameter - dpi specified is less than 9 (I2PDF_SetDPI)'
          OF 2
            MessErr = 'invalid parameter - dpi specified is greater than 2880 (I2PDF_SetDPI)'
          ELSE
            MessErr = 'Erreur inconnue (I2PDF_SetDPI) #' & Resul
          .
        .
      .
    
      IF CFG:LogNextTime
        I2PDF_Log(logfile, 3)
      .
    
      IF NOT EXISTS(TempSubFolderName)
        MkDir(TempSubFolderName)
      .
    
      !Translate Off
      NomFichierPDFTemp = TempSubFolderName & '\FichierPFD_' & RANDOM(100000, 999999) & '.pdf'
      LOOP WHILE EXISTS(NomFichierPDFTemp)
        NomFichierPDFTemp = TempSubFolderName & '\FichierPFD_' & RANDOM(100000, 999999) & '.pdf'
      .
      !Translate On
    
      IF Resul = 0
        Resul = I2PDF_MakePDF(NomFichierPDFTemp, 0, MessErr, SIZE(MessErr))
        IF Resul <> 0
          NomFichierPDFTemp = ''
        .
      .
    
      SETCURSOR()
    
      IF Resul > 0
        MESSAGE(MessErr, 'Impossible de créér le fichier PDF', ICON:Exclamation)
      END