gget79
2nd August 2008, 17:29
Hello Friends,

I made a work that could print a baan report in PDF format, I used ghostscript program to do it. I made a program 3GL linked to a device


I used the next code.


#pragma used dll "ottstpapihand"
#pragma used dll ottdllbw


STRING correo.partner(50) BASED |Dirección de Correo Partner
COMMON correo.partner
STRING numero.documento(9) BASED |Número del documento (Orden compra / solicitud oferta)
COMMON numero.documento
STRING tipo.documento(20) BASED |Tipo del documento (Orden compra / solicitud oferta)
COMMON tipo.documento
long ret
long page.width | NOVAMMH03.sn
long page.height | NOVAMMH03.en

table ttucpe900 |* Parámetros generación PDF y envío e-mail
table ttucpe901 |* Tabla de log de errores


function main()
{
string tmp.file(1024) | Nombre de Archivo temporal.
string local.path(1024) | Path en el cliente para el reporte.
string error.msg(1024) | Mensajes de error del AFS
long rc, ret | Código de Retorno
string stringargv0(40), stringargv1(40), stringargv2(40), stringargv3(40), stringargv4(40), stringargv5(40)

|* Obtiene datos de la tabla de parámetros.
select tucpe900.*
from tucpe900
selectdo
selectempty
message("No existen parámetros en la tabla tucpe900")
actualiza.tucpe901("No existen parámetros en la tabla tucpe900")
end()
endselect



|* Convertir el archivo del reporte en un archivo temporal POSTSCRIPT.

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

| wait.and.activate("ttstpconv", argv$(1), tmp.file, "POSTSCRIPT",argv$(4))
stringargv0 = argv$(0)
stringargv1 = argv$(1)
stringargv2 = argv$(2)
stringargv3 = argv$(3)
stringargv4 = argv$(4)
stringargv5 = argv$(5)
wait.and.activate("ttstpconv", argv$(1), tmp.file, "POSTSCRIPT", argv$(4))

|* Configurar la ruta sobre el cliente pc y enviar el archivo bajado.
|* Dejar al usuario que ingrese la ruta y el nombre del archivo a bajar
local.path = strip$(shiftl$(spool.fileout))

|* borra archivos .ps y .pdf anteriores con similar nombre
remove.local.file(local.path(1;(len(local.path)-2))& "pdf")
remove.local.file(local.path)

|* Copiar el archivo al pc cliente
send.report.to.client(tmp.file, strip$(local.path))

|* Convierte el POSTSCRIPT a PDF
make.pdf(tmp.file, strip$(local.path))



|* Borrar archivo de trabajo
rc = seq.unlink(tmp.file)
}

|****************************************************************************************
|* send.report.to.client(const string src(), const string dest())
|* Definición: Esta función se encarga de pasar el archivo temporal del servidor al cliente.
|* Inputs: src const string() Nombre del archivo temporal que genera el reporte
|* (archivo.ps en el servidor)
|* dest cosnt string() Directorio de destino en el cliente al cual se copia el
|* archivo (Directorio indicado en el dispositivo).
|* Outputs: Se tiene el archivo.ps en el directorio indicado en el dispositivo (dest).
|****************************************************************************************
function send.report.to.client(const string src(), const string dest())
{
long err
err = server2client(src, dest, 1)
if (err) then
message("Error %d copiando el archivo al PC (Puede que no tenga permisos)", err)
actualiza.tucpe901(sprintf$("Error %d copiando el archivo al PC (Puede que no tenga permisos)", err))
endif
}

|****************************************************************************************
|* make.pdf(const string src(), const string dest())
|* Definición: Esta función se encarga de convertir el archivo.ps en el cliente a un pdf.
|* Inputs: src const string() Nombre del archivo.ps a convertir en pdf
|* dest cosnt string() Directorio en el cliente en el cual se encuentra el
|* archivo.ps
|* Outputs: Se tiene el archivo.pdf en el directorio indicado.
|****************************************************************************************
function make.pdf(const string src(), const string dest())
{
long app.stat
app.stat = 0
|* NOVAMMH03.sn
string comando(1024)
comando = ""

page.width = 842
page.height = 497 |GET.N
comando = trim$(strip$(tucpe900.ghpa) & "\" & strip$(tucpe900.ghsc) &" -q -dSAFER -dNOPAUSE" &
" -dDEVICEWIDTHPOINTS#" & str$(page.width) & " -dDEVICEHEIGHTPOINTS#" & str$(page.height) &
" -dBATCH -sDEVICE#pdfwrite -sOutputFile#" & dest(1;(len(dest)-2))& "pdf" &
" -dnodisplay -dCompatibilityLevel#1.2 -c .setpdfwrite -f " & dest)

ret = app_start(comando, "", "", "", "")


|* NOVAMMH03.en
app.stat = app_status(ret)
if ret = 0 then
actualiza.tucpe901("No se pudo convertir archivo a pdf")
endif
}




My problem is that the report has to print in landscape mode. I is able to put the sheet in landscape mode, but the report is bad printing. I think that file ps is bad generating my question is can I print a postscript in landscape mode?

I attach file printed

günther
4th August 2008, 08:49
Hi,

have a look at this thread:
http://www.baanboard.com/baanboard/showthread.php?t=27695.
There are some different solutions.

Günther