Can Visual Studio change printer orientation and direction

Michael Chapman 25 Reputation points
2024-08-07T20:23:08.6566667+00:00

I've been trying all day to get the printer orientation set up like this. Is it even possible?

is_this_possible

Developer technologies | VB
0 comments No comments
{count} votes

Accepted answer
  1. Jiachen Li-MSFT 34,221 Reputation points Microsoft External Staff
    2024-08-08T01:38:31.58+00:00

    Hi @Michael Chapman ,

    You can set the printer's orientation to landscape or portrait using the PageSettings property of the PrintDocument.

    You can use the TranslateTransform and RotateTransform methods to change the direction of the drawing.

        Private WithEvents PrintDocument1 As New PrintDocument
        Private WithEvents PrintPreviewDialog1 As New PrintPreviewDialog
    
        Public Sub Printit()
            PrintDocument1.DefaultPageSettings.Landscape = True
    
            PrintPreviewDialog1.Document = PrintDocument1
            PrintPreviewDialog1.ShowDialog()
        End Sub
    
        Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs) Handles PrintDocument1.PrintPage
            Setup_printer(e)
        End Sub
    
        Public Sub Setup_printer(ByVal e As PrintPageEventArgs)
            e.Graphics.TranslateTransform(0, e.PageBounds.Height)
            e.Graphics.RotateTransform(-90)
        End Sub
    

    Best Regards.

    Jiachen Li


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.