Solved

Set Papersize vb 2005 express

Posted on 2006-11-09
5
276 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Find value in LINQ result ? 4 18
Expando 4 34
Check if number is currency 15 29
Hide Tab Page 3 19
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
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 …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now