raikar_raviraj
22nd April 2009, 10:35
Hi,

I am trying to create a pdf file using ghost script writer.
.ps file is getting created but .pdf file isnt getting created.

Find below the code that i have written for the same

function create_pdf()
{
long fp1 | File to create PDF File.
string tmp.file1(1024)

| Convert file.
convert_file("POSTSCRIPT")
local.path = local.path & ".PDF"


|Create some temp files.
tmp.file1 = creat.tmp.file$( bse.tmp.dir$() )

|Open the temp files.
fp1 = seq.open(tmp.file1, "w")

| Put Ghostwriter stuff
seq.puts("-q -dNOPAUSE -dBATCH -sDEVICE#pdfwrite", fp1)
seq.puts("-sOutputFile#"&local.path, fp1)
|seq.puts("-sPAPERSIZE=a4",fp1)
|seq.puts("-dDEVICEWIDTHPOINTS = 880",fp1)
|seq.puts("-dDEVICEHEIGHTPOINTS=1200",fp1)
|seq.puts("-sPDFPassword=baan",fp1)
seq.puts("-q -dNOPAUSE -dBATCH -sDEVICE#pdfwrite -c save pop -sOutputFile#"&local.path & " -f " & local.path(1;(len(local.path)-3))&"ps", fp1)


| Close the files.
seq.close(fp1)

| Move these two files to the c drive.
send.report.to.client(tmp.file1, "c:\_.gs1")

|Move the postscript file to the client.
server2client( tmp.file, local.path(1;(len(local.path)-3))&"ps",1)

| Setup filename to start.
ret = rdi.domain.enum.value( "tugs",1,"2",app1,appl,fval)
ret = app_start("gswin32c.exe" & "@_.gs1", "c:\out","","","")
|ret = app_start(appl & " @_.gs1", "c:\baan\","","","")
| Make sure GS is completed before launching Acrobat.
if ret >= 0 then
| not equals
| while app_status(ret) <> 0
| suspend(500)
| endwhile
else
message("Error %d encountered while starting Ghostscript", (-1 * ret))
endif
|Delete old temp file.
ret = seq.unlink(tmp.file)
ret = seq.unlink(tmp.file1)

| Start adobe acrobat
ret = rdi.domain.enum.value( "tugs",4,"2",app1,appl,fval)
| start= "C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe" & " " & local.path
start= "AcroRd32.exe" & " " & local.path
| Start the aplication.
start_app()

}

I have downloaded gs863w32.exe and installed it. Have set the environment variables to point to gswin32c.exe

please let me know if any changes needs to be made in the code.

boXer14
23rd April 2009, 11:52
Hello,

i have no idea how GS works with Windows, but on Unix, GS comes with ps2pdf


i just did that in my baan script to have an A4 pdf from ps file :

shell_command = "ps2pdf -sPAPERSIZE#a4 " & strip$(file.in) & " baan.pdf"
shell(shell_command, SHELL_NO_OUTPUT)

where file.in is ps file

u can also add background or merge this "baan.pdf" with another pdf file using pdftk utility... nice to add logo or footer

Olivier

Marioth
23rd April 2009, 16:25
Maybe this is usefull.

start.application.local()
Syntax:

function boolean start.application.local (string commandline, boolean waitFlag, ref long exitCode [, const string verb])

Description


This starts the client application specified in the commandline argument.


Arguments

string commandline This specifies the command that starts the application. If commandline does not include a directory path, Windows searches for the executable file in the following directories, in the order shown below:

The Windows system directory.
The Windows directory.
The directories listed in the PATH environment variable.
This argument may also contain the full pathname of a local document. In this case the application associated with this document extension will be started.

The commandline parameter may one or more times include the string ${BSE_TMP} which indicates the ${BSE}\tmp directory in case of Baan Windows or Windows temp directory in case of Webtop.

boolean waitFlag Indicates whether the application must wait for the local application to exit.

ref long exitCode Exit code of local application. Only contains a valid exit code when the waitFlag attribute was true

[const string verb ] When the commandline argument contains a document pathname, the optional verb argument may contain the action to be performed on this document. The default action is "open". Another useful verb is: "print". In case this argument is supplied, the waitFlag argument will be ignored and the execution will always by asynchronous.


Return values

true Application started successfully.
false Application failed to start.

Context

This function can be used in all script types.

~Vamsi
24th April 2009, 01:49
Raviraj,

What is the OS of the Baan Server?