Setting Print Job Form Length

I need to be able to change the formlength of a print job midstream. In other words I ...

hPrinterDc =
 CreateDC(Spooler,Printer,NULL,NULL);

// Set Document Info Structure;
memset( &di, 0, sizeof( DOCINFO ) );
di.cbSize = sizeof( DOCINFO );
di.lpszDocName       = "Document";
di.lpszOutput    = NULL;
      
StartDoc( hPrinterDc, &di );
...
Now how can I change the form length say to 1/3 of a normal page so that when I call EndDoc(hPrinterDC), a whole page doesn't spit out?

Thanks!
 
AndrewRAsked:
Who is Participating?
 
chensuConnect With a Mentor Commented:
Set the dmPaperLength member of DEVMODE.

HOWTO: Modify Printer Settings with DocumentProperties()
http://support.microsoft.com/support/kb/articles/Q167/3/45.ASP

HOWTO: Modify Printer Settings by Using SetPrinter
http://support.microsoft.com/support/kb/articles/Q140/2/85.asp
0
 
NickRepinCommented:
I'm afraid, paper will be ejected in any case on EndDoc(). Especially on laser printers.
0
 
AndrewRAuthor Commented:
I realize I am going to get a whole sheet of paper with a laser printer, but I am looking to implement this on a Lexmark 2380 dot matrix printer. I need the formfeed to stop on 1/3 sheet intervals...
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
AndrewRAuthor Commented:
The DM_PAPERLENGTH bit of the dmFields isn't set when calling DocumentProperties() for this printer. Am I out of luck?
0
 
chensuCommented:
It is unlikely that the dot matrix printer driver supports it. You need to find some alternatives.
0
 
AndrewRAuthor Commented:
I tried sending the raw printer codes to set the formlength using the suggested function...
....
RawDataToPrinter(Printer, Buf,lenbuf);
StartDoc( hPrinterDc, &di );  
....

StartDoc()resets the values...

If I try StartDoc() before RawDataToPrinter(), RawDataToPrinter() never returns...

Andy suggestions for alternatives? :-)










        
0
 
chensuCommented:
How about using the Escape function?
0
 
AndrewRAuthor Commented:
I will try that next...
0
 
AndrewRAuthor Commented:
This simple test still does not do it...
....
hPrinterDc =
  CreateDC (Spooler,Printer,NULL,NULL);

// Set Document Info Structure;
memset( &di, 0, sizeof( DOCINFO ) );
di.cbSize = sizeof( DOCINFO );
di.lpszDocName = "Document";
di.lpszOutput    = NULL;
      
StartDoc( hPrinterDc, &di );

sprintf(Buf,
   "%c%c%c%c%)",27,67,22,32,8);  

*(WORD *)pOutput = 5;
memcpy( &(pOutput[sizeof(WORD)]), Buf, 5 );
 
Escape( hPrinterDc, PASSTHROUGH, 0, pOutput, NULL );

wsprintf(Buf,"TEST TEST TEST");
TextOut(hPrinterDc,0,0,Buf,14);

EndDoc(hPrinterDc);
....
0
 
chensuCommented:
The 3rd parameter of Escape is the number of bytes in input structure. It should not be zero. What's the type of pOutput? The memcpy seems strange.
0
 
AndrewRAuthor Commented:
I copied an example out of the developer studios online help. Sorry if I didn't paste here verbatum...
I will look at it again though...
0
 
NickRepinCommented:
AndrewR,
Probably, you have to go to Control Panel->Printers->Lexmark->Properties->General->Print processor

Now select winprint(if I'm not wrong), then select data type RAW (not RAW FF). RAW FF will always add form feed escape seq after EndDoc().
0
All Courses

From novice to tech pro — start learning today.