Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Set Papersize vb 2005 express

Posted on 2006-11-09
5
303 Views
Last Modified: 2012-06-27
This is the code I used ...
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
Dim MyNormalFont As New Font("Arial", 8, FontStyle.Regular)
        Dim PaperK As New PaperKind
        Dim PaperS As New PaperSize
        PaperK = PaperKind.A4
        PaperS.RawKind = PaperK

        Me.PrintDocument1.DefaultPageSettings.Landscape = True
        Me.PrintDocument1.DefaultPageSettings.PaperSize = PaperS
        With Me.PrintDocument1.DefaultPageSettings.Margins
            .Bottom = 50
            .Left = 50
            .Right = 50
            .Top = 50
        End With
        Me.PrintPreviewDialog1.Document = Me.PrintDocument1
        Me.PrintPreviewDialog1.ShowDialog()

End Sub

But when I clicked the btnPrint ...

The papersize of the print preview becomes very small...

why?

What is the proper way of setting the papersize of the print preview to A4?

Jack...
0
Comment
Question by:JackOfPH
  • 3
5 Comments
 
LVL 16

Accepted Solution

by:
Hillwaaa earned 500 total points
ID: 17905414
Hi JackOfPH,

Not sure on this one - but it could be your margin settings - default from memory is cm or inches - either of which is going to be a problem...

Also, try setting your DefaultPageSettings.PaperSize.Height and .Width values manually.

Cheers!
0
 
LVL 5

Expert Comment

by:maralans
ID: 17905829


        Dim intY As Integer = Screen.PrimaryScreen.Bounds.Height
        Dim intX As Integer = Screen.PrimaryScreen.Bounds.Width
        Try
            PrintPreviewDialog1.Document = Me.PrintDocument1
            PrintPreviewDialog1.Width = intX
            PrintPreviewDialog1.Height = intY
            PrintPreviewDialog1.ShowDialog()
        Catch exp As Exception
            MessageBox.Show("An error occurred while trying to load the " & _
                "document for Print Preview. Make sure you currently have " & _
                "access to a printer. A printer must be connected and " & _
                "accessible for Print Preview to work.", Me.Text, _
                 MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
0
 
LVL 5

Expert Comment

by:maralans
ID: 17905977
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
       
        Dim MyNormalFont As New Font("Arial", 8, FontStyle.Regular)
        Dim PaperK As New Printing.PaperKind
        PaperK = Printing.PaperKind.A4

        Me.PrintDocument1.DefaultPageSettings.Landscape = True
        With Me.PrintDocument1.DefaultPageSettings.Margins
            .Bottom = 50
            .Left = 50
            .Right = 50
            .Top = 50
        End With
        Dim intY As Integer = Screen.PrimaryScreen.Bounds.Height
        Dim intX As Integer = Screen.PrimaryScreen.Bounds.Width
        Try
            PrintPreviewDialog1.Document = Me.PrintDocument1
            PrintPreviewDialog1.Width = intX
            PrintPreviewDialog1.Height = intY
            PrintPreviewDialog1.ShowDialog()
        Catch exp As Exception
            MessageBox.Show("An error occurred while trying to load the " & _
                "document for Print Preview. Make sure you currently have " & _
                "access to a printer. A printer must be connected and " & _
                "accessible for Print Preview to work.", Me.Text, _
                 MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub
0
 
LVL 5

Expert Comment

by:maralans
ID: 17909067
or:

PrintPreviewDialog1.Width = 700
PrintPreviewDialog1.Height = 500
PrintPreviewDialog1.ShowDialog()
0
 
LVL 15

Author Comment

by:JackOfPH
ID: 17910816
What would be the height and width of a A4 paper in hundredths of inches...
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question