Setting the custom papersize using PrintDocument.DefaultPageSettings.Papersize property is not working, How to fix?
RakshithShetty-9008
0
Reputation points
I am using the code snippet shown below to print an image to the receipt printer, I am trying to set maximum height for the paper so that the image gets printed completely. But the paper size doesn't seem to be changing, Please let me know how to fix this?
The papersize which I set in the printer settings in control panel will be applied and the custom papersize applied in the code gets ignored.
PrintDocument pd = new PrintDocument();
pd.DefaultPageSettings.PrinterSettings.PrinterName = MyPrintDialog.PrinterSettings.PrinterName;
pd.DefaultPageSettings.PaperSize = new PaperSize("CustomPageSize", 314, 13000);
pd.PrinterSettings.DefaultPageSettings.PaperSize = pd.DefaultPageSettings.PaperSize;
pd.DefaultPageSettings.PaperSize.RawKind = 119;
pd.PrinterSettings.DefaultPageSettings.PaperSize.RawKind = 119;
pd.PrintPage += (sender, args) =>{
Image i = Image.FromFile(reportFileName)//reportFileName is filepath
args.Graphics.DrawImage(i, 0, 0);
};
pd.Print();
Developer technologies | .NET | Other
Developer technologies | .NET | Other
Microsoft Technologies based on the .NET software framework. Miscellaneous topics that do not fit into specific categories.
Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
Sign in to answer