vb.net PrintDocument custom paper size

While using PrintDocument class for printing on vb.net, It won’t allow you to change PaperSize Width and Height values. In order to set those values manually, you need to define a custom paper size first. Use the code below to create a new custom paper size and then set it to PrintDocument’s PaperSize property:

Dim pkCustomSize1 As New System.Drawing.Printing.PaperSize("Custom Paper Size", 800, 600)
PrintDocument1.PrinterSettings.DefaultPageSettings.PaperSize = pkCustomSize1

I hope this helps, cheers!