- PageSize units inconsistancy? UniDrv and .NET
- Posted by Tom on July 29th, 2003
We are developing an application that automatically prints pages based
on data retrieved from a database. The data includes the printer name
and the desired page size. Our printer doesn't support any standard
page sizes. We've created our own printer driver based on UniDriver.
The printing application can successfully select the desired printer.
However, selecting the desired page size doesn't work. We're trying to
select the page size using the PaperSize.PaperName property. Here's
the C# code:
// m_PrinterName is the name recognized by Windows
// pageSizeName is the name of the page size matching that in the
GPD file.
// debug only - look at current default paper size.
PaperSize psDefault = pd.DefaultPageSettings.PaperSize;
// Create a PrintDocument
PrintDocument pd = new PrintDocument();
// Use a standard print controller - to avoid the status/cancel
dialog
pd.PrintController = new StandardPrintController();
// Set the printer name (from the printer device object)
// This name must match the installed Windows printer.
pd.PrinterSettings.PrinterName = m_PrinterName;
if( !pd.PrinterSettings.IsValid )
{
// Log the error and then quit
}
foreach( PaperSize psize in pd.PrinterSettings.PaperSizes )
{
if( psize.PaperName == pageSizeName )
{
pd.DefaultPageSettings.PaperSize = ps; // select this one
break;
}
}
The interesting thing here is that the units for the sizes (width and
height) are not consistant. For the particular test that I'm running I
know that the paper size desired is the same as the default size for
the printer. But when I look at the properties of the default paper
size (psDefault above) and the selected size in the list (when
psize.PaperName == pageSizeName ) they don't match:
default selected
kind: 0x103 0x94
width: 0xde4 = 3556 0x578 = 1400
height: 0x10de = 4318 0x6a4 = 1700
name: "custom" "14INX17IN"
The size units for the default appear to be hundredths of centimeters,
while the size units for the selected paper size are hundredths of
inches. But using the selected paper size doesn't work (the page is
too small). The driver seems to want the metric size. The
documentation indicates that sizes should be hundredths of inches and
that's the unit used in the rendering code. Any idea what's happening
here?
Thanks,
Tom
- Posted by Ashwin [MS] on July 31st, 2003
This newsgroup is mainly for driver related questions. Since this sounds
like more of a .NET issue, I 'd suggest you try
microsoft.public.win2000.printing, microsoft.public.windowsxp.print_fax or
microsoft.public.win32.programmer.gdi.
- Ashwin
This posting is provided "AS IS" with no warranties, and confers no rights.
- Posted by Tom Demler on August 1st, 2003
framework. We've discovered that including a standard
paper size (LETTER) in our GPD file (even though the
printer doesn't support it) makes this problem go away. I
was aware of the need for at least one standard paper
size in the GPD file for Win2K but I thought that this
requirement was fixed for XP.
Regards,
Tom
- Posted by Ashwin [MS] on August 1st, 2003
Yes. The issue of having atleast one standard paper size was fixed on XP.
So that shouldn't be a problem. The best explanation I can think for the
units discrepancy is that one of them is being returned in terms of master
units or in .1mm units. Internally, Unidrv converts paper sizes back and
forth between master units and .1mm or micron units. So this might explain
the discrepancy that you are seeing. But the fact that the problem goes
away if you add the LETTER papersize to the GPD, makes me believe that this
might not be the root cause.
- Ashwin
This posting is provided "AS IS" with no warranties, and confers no rights.