Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig
SchubYu wrote:We need to generate classes and do not want to use a DLL. Do you provide a ConfMap for it?
initializeResources
"Initialize the receiver's default resource values."
xmNx := 0.
xmNy := 0.
xmNwidth := 0.
xmNheight := 0.
xmNx := 0.
xmNfile := nil.
xmNtitle := ''. "$NON-NLS$"
pageNumber := 0.
resolution := 0 @ 0.
self initializeScreen
createDocInfoStruct
"Answer a newly created OSDocinfo structure."
^OSDocinfo new
lpszDocName: xmNtitle asPSZ copyToOSMemory;
lpszOutput: (xmNfile ifNotNil: [:string | string asPSZ copyToOSMemory]);
cbSize: OSDocinfo fixedSize;
yourself
initiateOutput
"Allocate graphical resources and begin output.
Return value
Not specified."
"Set the title of the print job."
self widget
title: self class printJobTitlePrefix , self template title;
fileName: self template fileName;
startJob.
super initiateOutput
myReport coElement fileName:anyFileName.
myReport printer: printer.
myReport print.
int gsapi_new_instance (void **pinstance, void *caller_handle);
int gsapi_init_with_args (void *instance, int argc, char **argv);
int gsapi_exit (void *instance);
void gsapi_delete_instance (void *instance);
/* Example of using GS DLL as a ps2pdf converter. */
#if defined(_WIN32) && !defined(_Windows)
# define _Windows
#endif
#ifdef _Windows
/* add this source to a project with gsdll32.dll, or compile it directly with:
* cl -D_Windows -Isrc -Febin\ps2pdf.exe ps2pdf.c bin\gsdll32.lib
*/
# include <windows.h>
# define GSDLLEXPORT __declspec(dllimport)
#endif
#include "ierrors.h"
#include "iapi.h"
void *minst;
int main(int argc, char *argv[])
{
int code, code1;
const char * gsargv[10];
int gsargc;
gsargv[0] = "ps2pdf"; /* actual value doesn't matter */
gsargv[1] = "-dNOPAUSE";
gsargv[2] = "-dBATCH";
gsargv[3] = "-dSAFER";
gsargv[4] = "-sDEVICE=pdfwrite";
gsargv[5] = "-sOutputFile=out.pdf";
gsargv[6] = "-c";
gsargv[7] = ".setpdfwrite";
gsargv[8] = "-f";
gsargv[9] = "input.ps";
gsargc=10;
code = gsapi_new_instance(&minst, NULL);
if (code < 0)
return 1;
code = gsapi_init_with_args(minst, gsargc, gsargv);
code1 = gsapi_exit(minst);
if ((code == 0) || (code == e_Quit))
code = code1;
gsapi_delete_instance(minst);
if ((code == 0) || (code == e_Quit))
return 0;
return 1;
}
| wfun wrc winst wptr whnd wgsargc wgsargv wptrgsargv |
" Create GS Instance "
whnd := ' ' asPointer.
wptr := whnd asInteger asBytes asPointer.
wfun := PlatformFunction
language: 'c'
function: 'gsapi_new_instance'
library: 'gsdll32.dll'
parameterTypes: #(pointer)
returnType: #int32.
wrc := (wfun callWith: wptr).
(wrc = 0)
ifFalse:[
^false
].
" Initialize GS interpreter "
wgsargc := 10.
wgsargv := 'ps2pdf -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -sOutputFile=out.pdf -c .setpdfwrite -f input.ps'.
wptrgsargv := wgsarggv asPointer.
wfun := PlatformFunction
language: 'c'
function: 'gsapi_init_with_args'
library: 'gsdll32.dll'
parameterTypes: #(handle int32 pointer)
returnType: #int32.
wrc := (wfun callWith: whnd with: wgsargc with: wptrgsargv).
(wrc = 0)
ifFalse:[
^false
].
" Exit GS interpreter "
wfun := PlatformFunction
language: 'c'
function: 'gsapi_exit'
library: 'gsdll32.dll'
parameterTypes: #(handle)
returnType: #int32.
wrc := (wfun callWith: whnd).
(wrc = 0)
ifFalse:[
^false
].
" Delete GS Instance "
wfun := PlatformFunction
language: 'c'
function: 'gsapi_delete_instance'
library: 'gsdll32.dll'
parameterTypes: #(handle)
returnType: #int32.
wrc := (wfun callWith: whnd).
(wrc = 0)
ifFalse:[
^false
].
^true
ricardovp wrote:Hi Ben!
Thanks for your answer! Now I can create my Post Script files without prompting the user for a filename!
To generate a PDF file from a PS (Post Script) file I'm using Ghostscript... I've managed to do so using the AbtProgramStarter class and setting some parameters, but I want to use the Ghostscript DLL... I'm not used to use the PlatformFunction class, so I'm hoping that you guys may helpe me...
Return to VA Smalltalk 7.0, 7.5 & 8.0
Users browsing this forum: Yahoo [Bot] and 1 guest