Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resize Image to Print On 8.5x11 Paper 1

Status
Not open for further replies.

SgtJarrow

Programmer
Apr 12, 2002
2,937
US
I have a requirement to resize any picture selected (already being viewed on a form) so that it will print and fill an 8.5x11 standard format sheet of paper. I can send the viewed image directly to the printer via a printdocument control, but I can't figure out how to get it to fill the page. Most of the images are LARGER than 8.5x11 so I will be shrinking them. Quality is not much of a concern.

As it stands now, I render a bmp from the filepath and display that in a picturebox control. The SizeMode is set to Zoom on the control and it looks fine on the screen. But when I send it to the printer, only a small portion of it prints due to the size of the image being large than 8.5x11.

I expect the best way to do this is through some GDI+, but I can't figure out how to handle the fact that pixels per inch vary on screen, etc. I don't have anything really to start with yet....

Can anyone point me in the right direction??? I just need a nudge.... Thanks.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB/Access Programmer
 
There is likely another way, but here is a suggestion till you get one. If you have VS2k5 you can get the PrintForm Component Power Pack from Microsoft. It allows you print a form. I don't remember if you can resize on print, but it will print to the current size of the form at least. I think you can resize the print, but it has been awhile since I used it.

-I hate Microsoft!
-Forever and always forward.
 
Thanks Sorwen.....That fits the bill nicely and is quite easy to implement. I am not seeing any resize options, but since the picviewer on my form is already doing the resize, it works just fine for our purposed. Star to you.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB/Access Programmer
 
Just a followup in case anyone stumbles into this thread.... here's what I finally ended up with.

My users complained a bit about the quality. The base images were something like 2048x1024 on a 17" monitor. Why they keep scanning them in at that quality and size is beyond me, but they would not change that.

So I grabbed the image from a file, shrank it to 40% original, used the SizedChanged event of the PictureViewer to resize the form to match the image size, and then displayed the image. The Print button is located in a context menu and only sends the form through the PrintForm control in landscape mode.

Here's all the code I used. Hope it helps someone. [smile]

Code:
Public Class ViewInvoice

#Region "Variables"

    Public strPath As String = String.Empty

#End Region

#Region "Load Form"

    Private Sub ViewInvoice_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim bm As New Bitmap(strPath)
        Dim bm_sized As New Bitmap(Convert.ToInt32(bm.Width * 0.4), Convert.ToInt32(bm.Height * 0.4))
        Dim gr As Graphics = Graphics.FromImage(bm_sized)
        gr.DrawImage(bm, 0, 0, bm_sized.Width + 1, bm_sized.Height + 1)

        Me.picInvoice.Image = bm_sized

    End Sub

    Private Sub picInvoice_SizeChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picInvoice.SizeChanged

        Me.Width = Me.picInvoice.Width
        Me.Height = Me.picInvoice.Width

    End Sub

#End Region

#Region "Print Image"

    Private Sub mniPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mniPrint.Click

        Me.pfPrintTheInvoice.PrinterSettings.DefaultPageSettings.Landscape = True
        Me.pfPrintTheInvoice.Print()

    End Sub

#End Region

End Class

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB/Access Programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top