Skip to main content

Hi,

I want to use the NovaPDF creator in a Net Express 5.1 project but dont know to add the reference to the "com" so I can access its features.

Pls see link below showing how to do this in either C or Visual Basic

C code link - http://www.novapdf.com/kb/hello-world-c-sdk-sample-313.html

Visual Basic link - http://www.novapdf.com/kb/hello-world-visual-basic-sdk-sample-325.html

Can any one convert this to Net Express Cobol code.

Thanks

Neil

Hi,

I want to use the NovaPDF creator in a Net Express 5.1 project but dont know to add the reference to the "com" so I can access its features.

Pls see link below showing how to do this in either C or Visual Basic

C code link - http://www.novapdf.com/kb/hello-world-c-sdk-sample-313.html

Visual Basic link - http://www.novapdf.com/kb/hello-world-visual-basic-sdk-sample-325.html

Can any one convert this to Net Express Cobol code.

Thanks

Neil

The following is the source for the VB-->COBOL conversion of the Hello World example which prints a line to the novaPDF COM server, which will create a PDF file and display it.

This has been modified to use the PC_PRINTER_OPEN and PC_PRINTER_WRITE library routines to print to the Nova Printer. PC_PRINTER_OPEN is set with flags = 3 which will cause a Printer Settings and Font Selection Dialog Boxes to be displayed prior to printing.

When the Printer Open Dialog Box appears, select the Nova PDF printer in the list of printers.

You can modify this to use your own print functionality as long as you select the Nova printer as the one to print to.

     $set ooctrl( p) case
      id division.
      program-id.  COM_novapi.
      environment division.
      object section.
      class-control.
     *----Register names of classes and their files
          exceptMgr is class "exptnmgr"
          oleExceptMgr is class "oleexpt"
          olesup is class "olesup"
          entrycallback     is class "entrycll"
          chararray is class "chararry" *> character array class
          novaPDF is class "$OLE$novapi.NovaPdfOptions.7"
          Base is class "base"
          .

      data division.
      working-storage section.
      78 ExceptionHandler      value "OLException".
      78 pfx                             value "*--> ".
      78 PGID                         value "COM_novapi: ".
      78 h                                value pfx & PGID & ": ".
      78 LF                              value x"0D0A".
      01 novaPDFhandle    object reference.
      01 PRINTER_NAME          pic x(64) value z"novaPDF for SDK v7".
      01 NOVAPDF_INFO_SUBJECT  pic x(64) value z"Document Subject".
      01 PROFILE_IS_Public     pic s9(9) comp-5 value 0. *> LONG
      01 RESULT                       pic  9(9) comp-5 value 0.
      01 activeProfile                  pic x(64) value z" ".
      01 newProfile                     pic x(64) value z" ".
      01 dt                                   pic x(4)  comp-5 value 0.
      01 osException      object reference.
      01 lnksize                           pic s9(9) comp-5 value 0.
      01 anindex                         pic s9(9) comp-5 value 0.
      01 anElement        object reference.
      01 MFOLEmessageText    pic x(256) is external.
      01 wsIterator         object reference.
     *** PC_PRINTER call data
      01 printer-handle               pic x(4) comp-5.
      01 document-title.
          05 cblte-pn-name-length pic x(2) comp-5 value 18.
          05 cblte-pn-name          pic x(64)
          value "novaPDF for SDK v7".
      01 flags                             pic x(4) comp-5 value 3.
      01 window-handle             pic x(4) comp-5 value 0.
      01 status-code                  pic x(2) comp-5.
      01 print-buffer                   pic x(100)
         value "This is a test from COBOL".
      01 print-buffer-len             pic x(4) comp-5 value 25.
      local-storage section.
      linkage section.
      01 lnkErrorNumber           pic x(4) comp-5.
      01 lnkErrorObject   object reference.
      01 lnkErrorText      object reference.
      01 lnkElement        object reference.
      procedure division.
      Main section.
     ***** Set up the OLE Exception Handler
          invoke entrycallback "new"
             using ExceptionHandler
             returning osException
          end-invoke
          invoke exceptmgr "register"
             using oleExceptMgr
                   osException
          end-invoke
          invoke novaPDF "new" returning novaPDFhandle
          invoke novaPDFhandle "initialize2"
            using PRINTER_NAME
                  z""
                  z""
                  z""
          end-invoke
          invoke olesup "setDispatchType"
             using by value dt   *> Set dt to 0 to force the next message as a method invoke
          end-invoke
          invoke novaPDFhandle "GetActiveProfile2"
             using by reference activeProfile
                   by reference PROFILE_IS_Public
             returning RESULT
          end-invoke
          move z"Test COBOL" to newProfile
          invoke novaPDFhandle "DeleteProfile2"
             using by reference newProfile
                   by reference PROFILE_IS_Public
             returning RESULT
          end-invoke
          invoke novaPDFhandle "CopyProfile2"
             using by reference activeProfile
                   by reference newProfile
                   by value PROFILE_IS_Public
             returning RESULT
          end-invoke
          invoke olesup "setDispatchType"
             using by value dt   *> Set dt to 0 to force the next message as a method invoke
          end-invoke
          invoke novaPDFhandle "SetOptionString2"
             using by reference NOVAPDF_INFO_SUBJECT
                   by reference z"COBOL Hello document"
                   by reference activeProfile
                   by value PROFILE_IS_Public
             returning RESULT
          end-invoke
         call "PC_PRINTER_OPEN"
             using printer-handle
                   document-title
                   by value  flags
                   by value  window-handle
             returning status-code
          end-call
          call "PC_PRINTER_WRITE"
             using printer-handle
                   print-buffer
                   by value  print-buffer-len
             returning status-code
          end-call
          call "PC_PRINTER_CLOSE"
             using printer-handle
             returning status-code
          end-call
          invoke novaPDFhandle "SetActiveProfile2"
             using z"Default Profile"
                   PROFILE_IS_Public
             returning RESULT
          end-invoke
          invoke novaPDFhandle "finalize" returning novaPDFhandle
          stop run.
     *----------------------------------------------------------------*
      entry ExceptionHandler using by reference lnkErrorObject
                                   by reference lnkErrorNumber
                                   by reference lnkErrorText.
          display "==================================================="
          display LF h ExceptionHandler " Starts" LF
          display "OLE Exception:-"
          display "The COBOL exception number was: " lnkErrorNumber
          display "The exception occured on:"
          invoke lnkErrorObject "display" *> orderedcollection
          invoke lnkErrorText "size" returning lnksize
          perform varying anIndex from 1 by 1
             until anIndex > lnksize
             invoke lnkErrorText "at"
                using anIndex
                returning anElement
             end-invoke
             invoke anElement "getValueZ" returning MFOLEmessageText
          end-perform
          invoke EntryCallback "new"
             using z"DispError"
             returning wsIterator
          end-invoke
          invoke lnkErrorText "do" using wsIterator
          display "Terminating.."
          display LF h ExceptionHandler " Ends" LF
          display "==================================================="
          goback
          .
      entry "DispError" using lnkElement.
           display "    " with no advancing   *> Indent Slightly
           display " "
           invoke lnkElement "display"
           invoke lnkElement "getValueZ" returning MFOLEmessageText
           display " "
           goback.


Hi,

I want to use the NovaPDF creator in a Net Express 5.1 project but dont know to add the reference to the "com" so I can access its features.

Pls see link below showing how to do this in either C or Visual Basic

C code link - http://www.novapdf.com/kb/hello-world-c-sdk-sample-313.html

Visual Basic link - http://www.novapdf.com/kb/hello-world-visual-basic-sdk-sample-325.html

Can any one convert this to Net Express Cobol code.

Thanks

Neil

many thanks for that info chris much appreciated i will give it a go.