0 Replies - 424 Views - Last Post: 15 April 2021 - 09:44 AM Rate Topic: -----

#1 pj18limited   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 09-September 19

Print bitmap size

Posted 15 April 2021 - 09:44 AM

I'm new to writing print code. My code prints a picture box. I want to set the image size to fit 8.5 x 17 paper. The right paper size is selected but the image is not the desired size. The picture comes out the size to fit on a 8.5 x 11 paper. I need the image to fill the 8.5 x 17 paper. Also the image is not centered on the page. Can someone look at my code and tell me what I need to have the image come out right?
    Private Sub dgvDFile_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvDFile.CellContentClick

        If e.ColumnIndex = 1 And dgvDFile.Rows(e.RowIndex).Cells(2).Value IsNot "" Then
            PictureBox1.Image = Image.FromFile(dgvDFile.Rows(0).Cells(2).Value)
            PictureBox1.Image = Nothing
        End If

    End Sub

    Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ToolStripButton1.Click

        PrintDocument1.DefaultPageSettings.Landscape = True
        Dim psize As Printing.PaperSize

        ' The parameter of Item method is any kind of paper size avaliable on the printer
        psize = PrintDocument1.PrinterSettings.PaperSizes.Item(2)

        ' This line set the Page size of the document
        PrintDocument1.DefaultPageSettings.PaperSize = psize


    End Sub

    Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

        Dim b As New Bitmap(1632, 1056)
        PictureBox1.DrawToBitmap(b, PictureBox1.ClientRectangle)

        e.Graphics.DrawImage(PictureBox1.Image, e.MarginBounds.Left, e.MarginBounds.Top)

    End Sub

Is This A Good Question/Topic? 0
  • +

Page 1 of 1