So I gave up and wrote my own binary print filter. So far, so good.
Except, now large print jobs like screen dumps take over 4-1/2 minutes
to come out of the printer!
Would posting code do any good? I doubt it. We’re using a proprietary
string class, CMN_CString… Even if I write the filter to just send it
straight through, it takes 4-1/2 minutes, so I don’t believe for a
second that it has anything to do with what the filter is doing to the
PostScript.
The invocation of phs-to-ps in the code below is REPLY blocked on
/sbin/pipe while the filter is running. I don’t get it.
Here’s the entire guts of the filter:
int PrintFilter(char* zPHSFileName)
{
int RetStat = 0;
CMN_CString cReadLine;
int iPageWidth = 0;
int iPageHeight = 0;
FILE *fpPSPipe = NULL;
char zSystemCommand[CMN_MAX_FNAME_LEN + 1];
sprintf(zSystemCommand, “phs-to-ps %s”, zPHSFileName);
fpPSPipe = popen(zSystemCommand, “r”);
if ( fpPSPipe == NULL )
{
RET_STAT_SET_FAIL(RetStat, CMN_TRUE);
}
if (int_PASS(RetStat))
{
char zChar = NULL;
while( (zChar = getc(fpPSPipe)) != EOF)
{
while ( (zChar != ‘\n’) && (zChar != EOF) )
{
cReadLine += zChar;
zChar = getc(fpPSPipe);
}
if ( cReadLine.FindString("/setpagedevice") == 0 )
{
int iStartIndex = cReadLine.FindChar(’[’) + 1;
int iEndIndex = cReadLine.FindChar(’]’);
CMN_CString cPageDims(cReadLine.mid(iEndIndex - iStartIndex,
iStartIndex));
int iHeightIndex = cPageDims.FindChar(’ ');
CMN_CString cPageWidth(cPageDims.left(iHeightIndex));
CMN_CString cPageHeight(cPageDims.right(cPageDims.Length() -
iHeightIndex));
iPageWidth = atoi(cPageWidth.GetString());
iPageHeight = atoi(cPageHeight.GetString());
cReadLine.Empty();
}
else if ( (cReadLine.FindString(“2 setlinecap”) == 0) && (iPageWidth >
iPageHeight) )
{
cout << cReadLine << endl;
do
{
zChar = getc(fpPSPipe);
cReadLine += zChar;
} while ( zChar != ‘\n’ );
cReadLine.Empty();
cout << “90 rotate” << endl;
}
else
{
cout << cReadLine << endl;
cReadLine.Empty();
}
}
}
pclose(fpPSPipe);
return(RetStat);
}