Let me explain the problem, I'm stuck in it
If I changed the dpi settings in the "Printing Preferences for a Virtual Printer, such as PDF Creator" dialog box or on any printer that allows me to change this setting, then set a breakpoint, such as the code below:
PrintDialog printDialog = new PrintDialog(); if ((bool)printDialog.ShowDialog().GetValueOrDefault()) { System.Printing.PrintCapabilities capabilities = printDialog.PrintQueue.GetPrintCapabilities(printDialog.PrintTicket); ...... insert breakpoint here }
I see that the properties of printDialog.PrintTicket.PageResolution.X; and printDialog.PrintTicket.PageResolution.Y changes correctly when printingDialog.PrintTicket.PageMediaSize.Width and printDialog.PrintTicket.PageMediaSize.Height do not change despite changing printer resolution ... A4 paper in portrait mode will always have PageMeiaSize. 1122.5196850393702 and PageMediaSize.Width = 793.70078740157476 no matter what resolution is set to ..... for WPF, the block size of these sizes is set to 1 / 96th inch, but when Ok is displayed on the screen, since the default screen resolution is 96 pixels the other side is wrong on the printer because it has a different resolution in other words, recognizing that the height and width of the paper are read-only properties if I cannot find a way to tell WPF that the size of the device on the printer is not 1/96 inch, but, for example, 1/300 inch ( if the printer that I previously installed 300 dpi) is absolutely impossible to print at a higher resolution than 96dpi
Last note, in my particular case, I cannot use RenderTargetBitmap, and then resize all to fit the height and width of the printing paper, because I print high-definition barcode images, and this will result in a rescaling of the image that will make the barcode the code is unreadable because I create it for printing with a resolution of 300 dpi, which will go beyond the size without resizing, because WPF tells me the size of the printer paper in the wrong size (1 / 96th inch), carried otrya the real dpis preset in the printer
Hoping enough to clarify the problem,
thanks in advance,
Dave
source share