How to print an ACROBAT file without a dialog box

Tony Marston - 24th May 2002

My thanks to Michael J Levene of www.computalink-systems.com for supplying me with the following tip.

If you have ADOBE ACROBAT version 5.0 this shows how you can completely automate the generation of PDF files without any user intervention. Apparently someone else has been trying to sell a driver to do this, but this method is completely FREE, and even works on a network.

Here are the steps you need to go through:-

  1. Install Acrobat Distiller version 5.0 or above.
  2. Adjust Acrobat Distiller Printer settings (right mouse click - properties). Go to the TAB page labeled DETAILS and add a new port, select other and PDF port and then specify the directory name where the final prints will be located. See example below using the directory c:\windows\desktop\*.pdf

    Figure 1 - Acrobat Distiller Printer settings

    tip30_01.gif

  3. Go the tab page labeled 'ADOBE PDF Settings' and ensure the properties below are set up:

    Figure 2 - ADOBE PDF Settings

    tip30_02.gif

  4. Create the following entries in the [logicals] section of your Uniface assignment file (these are used by the print procedure shown below):
    tempdir = c:\windows\temp
    acrobat = true
    acrodir = c:\windows\desktop
    
    Note: acrodir MUST match the directory used for the port in step (2)
  5. Within your application set up the following printer:

    Figure 3 - define Uniface printer

    tip30_03.gif

  6. Define a logical to physical mapping for the printer. Within your application left-click on the icon in the top left-hand corner of the screen and select 'setup...', then select the tab labeled 'Printer' and map the logical printer called ACROBAT to the printer name defined in step (5).

    Figure 4 - logical to physical mapping for the printer

    tip30_04.gif

    These logical print definitions are stored in the user section of the Registry at the following location:

  7. Create a procedure similar to the following:
    entry PRINT_PROC
    params
       string  po_FileName   : OUT
    endparams
    
    variables
       string  lv_TempDir
       boolean lv_Acrobat
       string  lv_AcroDir
       numeric lv_Count
       numeric lv_Error
    endvariables
    
    lv_TempDir = $logical("tempdir")
    if (lv_TempDir = "")
       message "TEMPDIR not defined in [logicals] section of assignment file"
       return(-1)
    endif
    
    ; is acrobatic writer installed?
    lv_Acrobat = $logical("acrobat")
    lv_AcroDir = $logical("acrodir")
    
    ; Generate a unique reference number for the report
    call GET_NEXT_NUMBER("PRINT", v_count)
    
    if (lv_Acrobat)
       ; the acrobat name is the form title therefore
       ; change the formtitle to be the report name we want
       $formtitle = "Acro_%%lv_Count"
       print "ACROBAT", "C"
       if ($status = 0)
          po_FileName = "%%v_AcroDir%%%\%%$formtitle%%%.pdf"
          return(0)
       else
          message "Print to PDF file failed"
          return(-1)
       endif
    else
       print "FILE","C"
       if ($status = 0)
          po_FileName = "%%lv_TempDir%%%\rpt_%%lv_Count%%%.txt"
          activate "WINAPI".COPYFILE($result, po_Filename, lv_Error)
          if (lv_Error < 0)
             message "COPY failed"
             return(-1)
          endif
          return(0)
       else
          message "Print failed"
          return(-1)
       endif
    endif
    
    return(0)
    
    end PRINT_PROC
    

    This proc puts the printed output into a file and returns the name of that file to the calling procedure. What happens next is entirely up to you. One possible option would be to e-mail the file to someone.


Tony Marston
24th May 2002

mailto:tony@tonymarston.net
mailto:TonyMarston@hotmail.com
http://www.tonymarston.net

counter