Re: Help in using gsapi_set_stdio() to capture stdout into a memory buffer
Ken Sharp <[email protected]>
| Newsgroups | gmane.comp.printing.ghostscript.devel |
|---|---|
| Message-ID | <[email protected]> |
At 01:13 16/03/2016 +0000, Joaquim Luis wrote:
>If I compile it as is than I get this warning that I don't understand
>
>cl gstest.c -Ighostpdl\psi -Ighostpdl\base ghostpdl\debugbin\gsdll64.lib
>/nologo
>gstest.c
>gstest.c(102) : warning C4047: 'function' : 'int (__cdecl *)(void *,const
>char *,int)' differs in levels of indirection from 'int'
>gstest.c(102) : warning C4024: 'gsapi_set_stdio' : different types for
>formal and actual parameter 3
Without seeing your code its impossible to say for certain, but I would
suggest that you :
1) Have not prototyped the function you are using as a replacement for stdio
Or
2) Have the declaration of that function incorrect.
>but It saves the PS test string in the "CRAP.txt" file. But it's not this
>that I want. What I want is to capture what is actually printed to stdout
>(because I choose to do "-sOutputFile=-") and have no idea on how to do it.
>If gsapi_set_stdio() allows redirecting stdout, why is the result still
>printed to stdout?
Because one refers to the system stdout (where the file goes) and the other
refers to PostScript stdout. Any messages sent by the PostScript
interpreter will go to the PostScrip stdout or stderr, these you can
redirect. However setting the output file to the system stdout is
unaffected by altering the PostScript stdout.
The rendered output of a PostScript or PDF program is always (at least
partially) in memory, so you actually need take no special action to get a
memory buffer. *If* the resolution or media size is high then it may be
that there is insufficient memory to hold the entire page, in which case a
display list will be used and only bands of data will be available at a time.
Messing about with stdio isn't going to get you what you want, I suspect.
Ken