J
Jos Roijakkers
I am writing a program in Visual Studio 2005 (VB) that can print scanned
images (saved as jpg-files). The printing is done by the following code:
Private Sub pdoc_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
Handles PrintDocument.PrintPage
Dim i As Integer
Dim intPrintAreaHeight, intPrintAreaWidth, marginLeft, marginTop
As Int32
With PrintDocument.DefaultPageSettings
intPrintAreaHeight = .PaperSize.Height - .Margins.Top - .Margins.Bottom
intPrintAreaWidth = .PaperSize.Width - .Margins.Left - .Margins.Right
marginLeft = .Margins.Left ' X coordinate
marginTop = .Margins.Top ' Y coordinate
End With
'
If PrintDocument.DefaultPageSettings.Landscape Then
Dim intTemp As Int32
intTemp = intPrintAreaHeight
intPrintAreaHeight = intPrintAreaWidth
intPrintAreaWidth = intTemp
End If
Dim rectPrintingArea As New RectangleF(marginLeft, marginTop, intPrintAreaWidth,
intPrintAreaHeight)
e.Graphics.DrawImage(Picturebox.Image, marginLeft, marginTop)
End Sub
Before calling this procedure Picturebox is loaded with the desired JPG-file
using:
Picturebox.image = image.fromwile("picture.jpg")
The picture files (jpg-files) should all be printed on a single page, but
they were scanned and saved in different resolutions (varying from 150 dpi
to 400 dpi). The result is, that the high resolution images do not fit on
a single page.
My question is: how can I ensure, that the image fits a single page, regardless
its resolution?
images (saved as jpg-files). The printing is done by the following code:
Private Sub pdoc_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
Handles PrintDocument.PrintPage
Dim i As Integer
Dim intPrintAreaHeight, intPrintAreaWidth, marginLeft, marginTop
As Int32
With PrintDocument.DefaultPageSettings
intPrintAreaHeight = .PaperSize.Height - .Margins.Top - .Margins.Bottom
intPrintAreaWidth = .PaperSize.Width - .Margins.Left - .Margins.Right
marginLeft = .Margins.Left ' X coordinate
marginTop = .Margins.Top ' Y coordinate
End With
'
If PrintDocument.DefaultPageSettings.Landscape Then
Dim intTemp As Int32
intTemp = intPrintAreaHeight
intPrintAreaHeight = intPrintAreaWidth
intPrintAreaWidth = intTemp
End If
Dim rectPrintingArea As New RectangleF(marginLeft, marginTop, intPrintAreaWidth,
intPrintAreaHeight)
e.Graphics.DrawImage(Picturebox.Image, marginLeft, marginTop)
End Sub
Before calling this procedure Picturebox is loaded with the desired JPG-file
using:
Picturebox.image = image.fromwile("picture.jpg")
The picture files (jpg-files) should all be printed on a single page, but
they were scanned and saved in different resolutions (varying from 150 dpi
to 400 dpi). The result is, that the high resolution images do not fit on
a single page.
My question is: how can I ensure, that the image fits a single page, regardless
its resolution?