Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Set Papersize vb 2005 express

Posted on 2006-11-09
5
Medium Priority
?
322 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
[X]
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
  • 3
5 Comments
 
LVL 16

Accepted Solution

by:
Hillwaaa earned 2000 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
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 …
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

721 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