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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chensuCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.