It's been awhile since I last did anything with printer drivers. If I remember correctly custom paper size is optionally implemented by the driver. Also the range of possible values (height width) can also be limited by the driver.
The area you're looking at is the DMPAPER_USER implementation, though the msdn documentation is a little sparse in this area. A possible way of checking the printers capability is to try print to it with MS Word and use Word's built-in ability to set a custom paper size and see the results from that. ----- Original Message ----- From: "Gary Harpin" <[EMAIL PROTECTED]> To: <ADVANCED-DOTNET@DISCUSS.DEVELOP.COM> Sent: Friday, November 23, 2007 2:45 PM Subject: [ADVANCED-DOTNET] Setting custom paper size... Hello, We are building an application for the Microsoft .net framework (version 2) using the C# language. A major part of the application requires output to be printed on to custom paper size without the user being shown PrintDialog box and having to select or enter the required paper size. The following sample code from the application (variable data have been replaced by fixed values for clarity): /* * Sample Test code */ public void Print() { try { PrintDocument prnDoc = new PrintDocument(); prnDoc.PrintPage += new PrintPageEventHandler(OnPrintPage); // // fixed values used for clarity, real values are depentent // on what is being printed. // PaperSize paperSize = new PaperSize("Custom", 600, 800); // // Direct print to printer named "Samsung ML-2010 Series" // Test code, real code gets name from storage // prnDoc.PrinterSettings.PrinterName = "Samsung ML-2010 Series"; // // Set half inch margins prnDoc.DefaultPageSettings.PaperSize = paperSize; // // Set half inch margins prnDoc.DefaultPageSettings.Margins.Top = 50; prnDoc.DefaultPageSettings.Margins.Left = 50; prnDoc.DefaultPageSettings.Margins.Right = 50; prnDoc.DefaultPageSettings.Margins.Bottom = 50; // // Set to Landscape prnDoc.DefaultPageSettings.Landscape = true; // // Print the Document prnDoc.Print(); } catch (InvalidPrinterException e) { MessageBox.Show(e.ToString()); } catch (Exception e) { MessageBox.Show(e.ToString()); } } This code has been tested against a number of printers from different manufacturers (Samsung, Brother, HP, Oki...) and virtual printers such as PDFCreator. All the printers performed as expected apart from the Samsungs. The Samsung printers tested (ML-2010 ML-2010R, ML-2250, and ML-2510) do not change the paper size and print onto the default size. The margins and page orientation are set. Is there any way around this? Thank you. Regards, Gary Harpin ________________________________ "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are, in short, a perfect match.." Bill Bryson [No Disclaimer] =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.503 / Virus Database: 269.16.0/1137 - Release Date: 18/11/2007 17:15 =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com