Home > BaaN, Infor > Logo printing on BaaN Reports

Logo printing on BaaN Reports


Printing Logos on the Report header of BaaN reports is much discussed topic.Traditional Baan report with devices like D(Display), Windows printer still dont have the facility to print the logos.

“windows printer” device can be used with some workaround (font settings) , but again here there are lots of limitations like you can’t print coloured logos, and some other known system specific issues.

Looking at these limitations people go for other third party tools just for the purpose of logos and formatting.

Creating a HTML device will be the best homemade solution, I would suggest.

You will simply have to create a re-write device, write an extension to the standard “ttstpconv”. Pass “HTML” as first argument to ttstpconv, which will automatically insert html tags in the report and make it in html format. Once you have the HTML file, your extension program will manipulate the file the way you want.

Simply search for the tag <pre> and insert the line <img src=”logo file path” > before <pre> tag and open the file using app_start. Similarly you can format the entire report the way you want in your ttstpconv extension.

The basic code will be as follows

function main()
{
string tmp.file(1024) | Temporary File.
string local.path(1024) | Local file Path for storing the output file

| Convert the report file into the temp file.
tmp.file = creat.tmp.file$(bse.tmp.dir$())

wait.and.activate(“ttstpconv”, argv$(1), tmp.file, argv$(3), argv$(4))

local.path = strip$(spool.fileout)

| Copy file to the client.
customise.report(tmp.file, strip$(local.path))
}

function customise.report(const string source(), const string dest())
{
Line of code for formatting your report
}

Saving the logo on the server and then copying it to the client when the device is used, will avoid your overhead of saving the logo image on every client machine.  Make sure if using server2client function use the mode as binary mode

Source code version 1.0 (Baanboard Link)


|******************************************************************************
|* Title                : ttstpconv extension for HTML Device
|* Description:         : This program is an extension for ttstpconv which will
|*     add color logo to html reports. The logo file will be
|*     on the server and whenever the device is used it will
|*                        copied on the client if it doesnot exists on the client.
|*                        The logo will appear on all the pages. 
|* Original Author      : Niraj N. S. Kakodkar
|* Date                 : 16/02/2008
|******************************************************************************
|* Category             : Utility
|* Platform             : Independent
|* Enhancement ideas : a) Next/Previous Links
|*     b) Configurable fonts/colors/backgorund 
|* Copyright 2011 by Niraj N S kakodkar
|*
|* All Rights Reserved
|*
|* Permission to use, copy, modify, and distribute this software and its
|* documentation for any purpose and without fee is hereby granted,
|* provided that the above copyright notice appear in all copies and that
|* both that copyright notice and this permission notice appear in
|* supporting documentation.
|*
|* NIRAJ KAKODKAR and Baanboard.com DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|* AND FITNESS, IN NO EVENT SHALL NIRAJ KAKODKAR nor Baanboard.com
|* BE LIABLE FOR ANYSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|* OR PERFORMANCE OF THIS SOFTWARE.
|******************************************************************************

|******************************************************************************

#pragma used dll "ottdllbw"
#pragma nowarnings

#define  HEADER   "${BSE}/gif/logo.jpg"
#define  DEFAULT  "c:\windows\temp\logo.jpg"
#define  IMAGE_EMBED  "&lt;img src='c:\windows\temp\logo.jpg'&gt;&lt;hr&gt;&lt;br&gt;"
function main()
{
 string tmp.file(1024)    | Temporary File.
 string local.path(1024)   | Local file Path for storing the output file

 | Convert the report file into the temp file.
 tmp.file = creat.tmp.file$(bse.tmp.dir$())

 wait.and.activate("ttstpconv", argv$(1), tmp.file, argv$(3), argv$(4))

 local.path = strip$(spool.fileout)

 | Copy file to the client.
 customise.report(tmp.file, strip$(local.path))
}

function customise.report(const string src(), const string dest())
{
       
|* File Pointer Variables
 long    input_fp
        long    output_fp
 long    logo_fp
        long    ret
 
|* index variables 
 long    i
 long first_line
 long    file_size
 long  position

|* Buffer Variables
        string read.str(2048)  |Read Buffer
        string write.str(2048)  |Write Buffer
 string tmp.file2(1024)  |Temporary File
 
|* App Variables
 long app_id   | Application id.
 
|* Report Variables 
 long  page_count  | Page Count
 long  line_count  | Line Count
 long  cnt   | Count
 double  tmp   | Temporary Variable
 
|* Miscellenious Variables
 long    next

 tmp.file2 = creat.tmp.file$( bse.tmp.dir$() )

        input_fp = seq.open(src, "r")
 if input_fp &lt; 1 then
             message("Error %d opening the file %s", input_fp, src)
             input_fp = 0
 else
         output_fp = seq.open(tmp.file2, "w")
        endif

 logo_fp = file.stat(DEFAULT,file_size)
 
 if logo_fp &lt; 0 then
  ret = server2client(HEADER, DEFAULT, 0)
  if  ret &lt; 0 then
   message("Logo not available")
  endif
 endif 
 
 page_count = 0
 line_count = 0
 first_line = 0
 
 while seq.gets(read.str, 2048, input_fp) = 0
  
  if not first_line then
   position = rpos(read.str,"&lt;pre&gt;")
   ret = seq.puts(read.str(1;position-1) &amp; IMAGE_EMBED &amp; read.str(position;2048), output_fp)
   first_line = 1
  else 
   if(isspace(read.str)) then
    if (line_count &gt; 15) then
     next = 1
    endif 
   else
    position = rpos(read.str,"&lt;span")
    if position and next then
     ret = seq.puts(IMAGE_EMBED &amp; read.str, output_fp)
    else
     next = 0
     ret = seq.puts(read.str, output_fp) 
    endif 
   endif
    
  endif
  
  line_count = line_count + 1
  if line_count &gt; 66 then
   cnt = line_count
   line_count = 0
   page_count = page_count + 1
  endif
 endwhile
 
 ret = seq.puts("&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;" , output_fp)
 
        ret = seq.close(input_fp)
 ret = seq.close(output_fp)
 
 ret = server2client(tmp.file2, dest, false)
 app_start(dest, "", "", "", "")
}
Advertisements
Categories: BaaN, Infor Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: