I'm trying to print to an HP printer and it's crashing. We found that the graphics mode for the printer is set to HP-GL/2.
There's two options in the HP printer options dialog for graphics mode. HP-GL/2 and Raster. When we use raster, everything
works fine but the default is HP-GL/2.
I didn't see anything in the documentation or in the sample code, but Is there a way to change a setting like this. Shouldn't
it automatically print in raster mode?
The device context is a wxPrinterDC.
Thank you.
wxWidgets: 3.1.0
OS: Windows 7, Pro
Compiler: Visual Studio 2015
Setting Printer Options
Setting Printer Options
- Attachments
-
- PrinterGraphicsMode.PNG (43.3 KiB) Viewed 1047 times
Re: Setting Printer Options
What crashes and where?I'm trying to print to an HP printer and it's crashing.
What happens when you use the "printer" sample to print to that printer?
I don't think these settings can be changed programmatically, especially since they seem to be different for different printers/drivers.
Use the source, Luke!
Re: Setting Printer Options
It's not really crashing. The printer hangs and takes a long time to finish. Sometimes more than 30 minutes.
The sample does print correctly.
I have a feeling it may have something to do with the page margins. It only happens when the margins are
set to 0.
Thanks.
The sample does print correctly.
I have a feeling it may have something to do with the page margins. It only happens when the margins are
set to 0.
Thanks.
Re: Setting Printer Options
If it finishes, is the result correct?It's not really crashing. The printer hangs and takes a long time to finish. Sometimes more than 30 minutes.
Hard to tell who's at fault here. Have you tried very small margins > 0, e.g. 0.01?It only happens when the margins are set to 0.
Use the source, Luke!
Re: Setting Printer Options
We're past this problem now. We have a similar application that used GDI to print and it didn't have the same problem.
It took into account the unprintable area of the printer. Once we included this in our existing code the problem went away.
Here's the code we used to determine the unprintable area.
int offsetX = GetDeviceCaps( dc->GetHDC(), PHYSICALOFFSETX ) ;
int offsetY = GetDeviceCaps( dc->GetHDC(), PHYSICALOFFSETY ) ;
int horSIZE = GetDeviceCaps( dc->GetHDC(), HORZRES ) ;
int verSIZE = GetDeviceCaps( dc->GetHDC(), VERTRES ) ;
int dpi = GetDeviceCaps( dc->GetHDC(), LOGPIXELSX ) ;
unprintable_area->minimum.x_coordinate = ( conversion__inches_to_coordinate( (double)offsetX / dpi ) ) ;
unprintable_area->minimum.y_coordinate = ( conversion__inches_to_coordinate( (double)offsetY / dpi ) ) ;
unprintable_area->maximum.x_coordinate = ( paper_size.x_coordinate - unprintable_area->minimum.x_coordinate - conversion__inches_to_coordinate( (double)horSIZE / dpi ) ) ;
unprintable_area->maximum.y_coordinate = ( paper_size.y_coordinate - unprintable_area->maximum.y_coordinate - conversion__inches_to_coordinate( (double)verSIZE / dpi ) ) ;
One thing I didn't mention was that the printout was clipped on all sides. So clipped on all sides and no margins.
It took into account the unprintable area of the printer. Once we included this in our existing code the problem went away.
Here's the code we used to determine the unprintable area.
int offsetX = GetDeviceCaps( dc->GetHDC(), PHYSICALOFFSETX ) ;
int offsetY = GetDeviceCaps( dc->GetHDC(), PHYSICALOFFSETY ) ;
int horSIZE = GetDeviceCaps( dc->GetHDC(), HORZRES ) ;
int verSIZE = GetDeviceCaps( dc->GetHDC(), VERTRES ) ;
int dpi = GetDeviceCaps( dc->GetHDC(), LOGPIXELSX ) ;
unprintable_area->minimum.x_coordinate = ( conversion__inches_to_coordinate( (double)offsetX / dpi ) ) ;
unprintable_area->minimum.y_coordinate = ( conversion__inches_to_coordinate( (double)offsetY / dpi ) ) ;
unprintable_area->maximum.x_coordinate = ( paper_size.x_coordinate - unprintable_area->minimum.x_coordinate - conversion__inches_to_coordinate( (double)horSIZE / dpi ) ) ;
unprintable_area->maximum.y_coordinate = ( paper_size.y_coordinate - unprintable_area->maximum.y_coordinate - conversion__inches_to_coordinate( (double)verSIZE / dpi ) ) ;
One thing I didn't mention was that the printout was clipped on all sides. So clipped on all sides and no margins.