Platforms to show: All Mac Windows Linux Cross-Platform

/PDF/Ghostscript/Ghostscript Test
Feedback.

Function:
You find this example project in your Plugins Download as a Realbasic project file within the examples folder: /PDF/Ghostscript/Ghostscript Test
This example is the version from Tue, 18th Jan 2010.
Notes: Last modified: Tue, 18th Jan 2010
Class Window1
Inherits Window
// Controls
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance

// Event implementations
Sub Open()
dim g as GhostScriptMBS

g=new MyGhostScriptMBS

if targetmachO then
g.loadAPIlibrary "/Users/cs/Desktop/libgs.8.61.dylib"
elseif TargetWin32 then
g.LoadAPIdll "gsdll32.dll"
else
MsgBox "no dll for this platform."
Return
end if

msgBox g.loadErrorString

if g.LoadError=0 then
StaticText4.text=g.Product
StaticText5.text=g.Copyright
StaticText6.text=str(g.Revision)+" "+Format(g.RevisionDate,"0")

TestSimple g
TestComplex g



end if
End Sub

// Methods
Protected Sub TestSimple(g as ghostScriptMBS)
dim e as integer
dim a(9) as string

// Just run it like a command line utility

a(0) = "ps2pdf"
a(1) = "-dNOPAUSE"
a(2) = "-dBATCH"
a(3) = "-dSAFER"
a(4) = "-sDEVICE=pdfwrite"
a(5) = "-sOutputFile=out.pdf"
a(6) = "-c"
a(7) = ".setpdfwrite"
a(8) = "-f"
a(9) = "tiger.eps"

e=g.RunParams(a, "")
End Sub
Protected Sub TestComplex(g as ghostScriptMBS)
const e_Quit=-101
const e_NeedInput=-106

// this is example 3 of the API examples from C:

dim p(-1) as string // no parameters needed

'int code, code1;
'int exit_code;

dim code,code1,exitcode as integer

'const char *command = "1 2 add == flush\n";

dim command as string

command="1 2 add == flush"+chr(13)

'code = gsapi_new_instance(&minst, NULL);

code=g.GSNew
system.debuglog "GSNew: "+str(code)+" "+hex(g.InstanceHandle)

'if (code < 0)
'return 1;

if code<0 then
MsgBox "Failed on GSNew. "+str(code)
Return // Failed
end if

' code = gsapi_init_with_args(minst, argc, argv);

code=g.GSInit(p)
system.debuglog "GSInit: "+str(code)

'if (code == 0) {
if code=0 then

'gsapi_run_string_begin(minst, 0, &exit_code);

code=g.GSRunStringBegin(0,exitcode)
system.debuglog "GSRunStringBegin: "+str(code)

'gsapi_run_string_continue(minst, command, strlen(command), 0, &exit_code);

code=g.GSRunStringContinue(command, 0, exitcode)
system.debuglog "GSRunStringContinue: "+str(code)

'gsapi_run_string_continue(minst, "qu", 2, 0, &exit_code);

code=g.GSRunStringContinue("qu", 0, exitcode)
system.debuglog "GSRunStringContinue: "+str(code)

'gsapi_run_string_continue(minst, "it", 2, 0, &exit_code);

code=g.GSRunStringContinue("it", 0, exitcode)
system.debuglog "GSRunStringContinue: "+str(code)

'gsapi_run_string_end(minst, 0, &exit_code);

code=g.GSRunStringEnd(0,exitcode)
system.debuglog "GSRunStringEnd: "+str(code)

'}
end if

'code1 = gsapi_exit(minst);

code1=g.GSExit
system.debuglog "GSExit: "+str(code)

'if ((code == 0) || (code == e_Quit))
'code = code1;

if (code=0) or (code=E_QUIT) then
code=code1
end if

'gsapi_delete_instance(minst);

g.GSDeleteInstance

'if ((code == 0) || (code == e_Quit))
'return 0;

'return 1;

if code=0 or code=e_Quit then
// ok if you see the 3 in the window text.
'MsgBox "ok"
else
MsgBox "Failed "+str(code)
end if



End Sub
End Class

Class MyGhostScriptMBS
Inherits Object
// Event implementations
Function OutputError(s as string) As integer
Window1.out.text=Window1.out.text+s

Return lenb(s)

End Function
Function Output(s as string) As integer
Window1.out.text=Window1.out.text+s

Return lenb(s)

End Function
Function Input(byref s as string) As integer
Return -1 // no more output
End Function
End Class

Class App
Inherits Application
End Class





Links
MBS Filemaker Plugins - Pfarrgemeinde St. Arnulf Nickenich