• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 614
  • Last Modified:

Changing Paper Size

I have one last issue with my application.  I have to change the paper size to what the user selects in the web interface.  I pass over the value DMPAPER_... When I set the dmPaperSize in the DEVMODE struct it doesn't work.  It continues to print on the 8.5 x 11.  I even tried hard coding the 11 x 17 paper into DEVMODE but it came out 8.5 x 11.  Do I have to select the tray somehow?  I have messed around with DM_DEFAULTSOURCE with no success and with the DeviceCapabilities function.  Any ideas?  Thanks.
0
paulca
Asked:
paulca
  • 6
  • 6
1 Solution
 
nietodCommented:
Not you again :-)

Do you set the DM_PAPERSIZE bit of the DEVMODE's dmFields member?

If not, that is likely to be the problem.  If so, can you post the code?  
0
 
paulcaAuthor Commented:
Yes, I set that.  So, I guess that's not the problem.

if (pDevMode->dmFields & DM_PAPERSIZE)
 pDevMode->dmPaperSize = DMPAPER_11X17;
0
 
nietodCommented:
Sorry, I meant all the code (all the related code.)

Also, have you tried doing this "manually" (i.e. using the printer dialog from some commercial application.) to make sure the printer and its driver are capable of using the paper sizes you selected.  (some cut-sheet printers support and paper size so long as it is 8 1/2 X 11.)
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
paulcaAuthor Commented:
//  Parse m_printerinfo string
device = strtok(m_dpr.m_printerinfo, cmp);      
driver = strtok(NULL, cmp);
output = strtok(NULL, cmp);

// Start by opening the printer
OpenPrinter(device, &hPrinter, NULL);

dwNeeded = DocumentProperties(hWnd,hPrinter,device,NULL, NULL,0);

pDevMode = (LPDEVMODE)malloc(dwNeeded);

dwRet = DocumentProperties(hWnd,hPrinter,device,pDevMode,NULL,DM_OUT_BUFFER);

if (pDevMode->dmFields & DM_ORIENTATION)
// if the printer supports paper orientation, set it
pDevMode->dmOrientation = DMORIENT_LANDSCAPE;

if (pDevMode->dmFields & DM_COPIES)
// if the printer supports multiple copies, set it
pDevMode->dmCopies = m_dpr.m_copies;

if (pDevMode->dmFields & DM_PAPERSIZE)
pDevMode->dmPaperSize = DMPAPER_11X17; // m_dpr.m_papersize;

dwRet = DocumentProperties(hWnd,hPrinter,device,pDevMode,pDevMode,DM_IN_BUFFER |DM_OUT_BUFFER);

// Done with the printer
ClosePrinter(hPrinter);

0
 
nietodCommented:
That looks pretty good.

Just to check, you did confirm paper size flag was set, right?  if it wasn't you code would skip the if() that sents the paper size.

You might try changing the last DocumentPriperties() call so that it stores the properties in a 2nd (seperate) DEVMODE.  It is possible that the same devmode can't be used for both.  (Although I really doubt that is the case.)
0
 
paulcaAuthor Commented:
I don't know what to tell you.  I am printing to Xerox DocuCenter where the 1st 3 trays are 8.5 x 11 and the 4th tray is 11 x 17.  Do I have to tell the printer to take the paper from Tray 4 somehow?
0
 
nietodCommented:
Try doing this manually from Word or other program that lets you print, and see if you can make it work manually and what you have to do to make it work.
0
 
paulcaAuthor Commented:
I printed from Word.  All I had to do was select 11 x 17 from the Scale to Paper Size drop down list box.  Nothing more to it.  I wonder what that translates to in C++ by selecting the 11 x 17.
0
 
nietodCommented:
Perhaps the problem is the paper bin (tray)--as you suggested.

try setting the dmDefaultSource to DM_LARGERFMT or LARGECAPACITY and set the DM_DEFAULTSOURCE flag if the dmFields member.
0
 
paulcaAuthor Commented:
I have tried both of those.  I think I am going to have to return a list of bins and papersizes from DeviceCapabilites.  If I see anything in here that I can set dmDefaultSource to, I'll try that.  Maybe it's just a matter of setting the dmDefaultSource to the correct bin.
0
 
nietodCommented:
An "A"?  I didn't think I contributed ANYTHING.  You got it to work I assume.
0
 
paulcaAuthor Commented:
Yeah, I got it to work.  I put in the A because you have been very helpful in the past also.
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

  • 6
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now