This commit is contained in:
@@ -52,21 +52,10 @@ namespace Elwig.Helpers.Printing {
|
||||
throw new InvalidOperationException($"Unable to load PDF page {pageIndex}.");
|
||||
|
||||
try {
|
||||
// PDF coordinates are points (1/72 inch).
|
||||
//
|
||||
// HORZRES/VERTRES are the printable area in
|
||||
// device pixels for the current printer DC.
|
||||
int widthPx = printer.PixelWidth;
|
||||
int heightPx = printer.PixelHeight;
|
||||
|
||||
// Preserve aspect ratio.
|
||||
double scaleX = widthPx / pageWidthPt;
|
||||
double scaleY = heightPx / pageHeightPt;
|
||||
double scale = Math.Min(scaleX, scaleY);
|
||||
int renderWidth = Math.Max(1, (int)Math.Round(pageWidthPt * scale));
|
||||
int renderHeight = Math.Max(1, (int)Math.Round(pageHeightPt * scale));
|
||||
int offsetX = (widthPx - renderWidth) / 2;
|
||||
int offsetY = (heightPx - renderHeight) / 2;
|
||||
int renderWidth = (int)Math.Round(pageWidthPt / 72.0 * printer.DpiX);
|
||||
int renderHeight = (int)Math.Round(pageHeightPt / 72.0 * printer.DpiY);
|
||||
int offsetX = (printer.PrintableWidth - renderWidth) / 2;
|
||||
int offsetY = (printer.PrintableHeight - renderHeight) / 2;
|
||||
|
||||
printer.StartPage();
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user