Set Page Width and Height Programmatically

// Expert user has replied.
D Derek Russell 3 years 6 months ago
345 1 0

Is there any way to set the page width and height within the driver? Or possibly choose the stock. I have a service that prints labels (created as Crystal Reports) and I need a way to change the size of the label in the driver. My only other option is to create a several printers instances with different sizes for each physical printer. For reference I am using .net with c#.

Please Register or Login to post a reply

1 Replies

R Robin West

You can use the PrintDocument class to set the page size.  Specifically the PrintDocument.PrinterSettings.PaperSizes allows you to access standard sizes and create custome page sizes.

From https://docs.microsoft.com/en-us/dotnet/api/system.drawing.printing.pri…
// Add list of supported paper sizes found on the printer.
// The DisplayMember property is used to identify the property that will provide the display string.
comboPaperSize.DisplayMember = "PaperName";

PaperSize pkSize;
for (int i = 0; i < printDoc.PrinterSettings.PaperSizes.Count; i++){
pkSize = printDoc.PrinterSettings.PaperSizes[i];
comboPaperSize.Items.Add(pkSize);
}

// Create a PaperSize and specify the custom paper size through the constructor and add to combobox.
PaperSize pkCustomSize1 = new PaperSize("First custom size", 100, 200);

comboPaperSize.Items.Add(pkCustomSize1); 

CONTACT
Can’t find what you’re looking for?