VB.net Stretch to fit

       Dim Printform1 As New Microsoft.VisualBasic.PowerPacks.Printing.PrintForm(myForm)
        Printform1.PrinterSettings.PrinterName = "Adobe PDF"
        Printform1.PrinterSettings.DefaultPageSettings.Landscape = True
        Printform1.PrinterSettings.DefaultPageSettings.Margins = New System.Drawing.Printing.Margins(0, 0, 0, 0)

I can´t get this to work.. need it to be stretch to on a4 papper..  rightn now It cut 1/6 on the left papper so I can´t se the whole papper...
Who is Participating?
Bob LearnedConnect With a Mentor Commented:
I haven't used the Visual Basic Power Packs, but I would think that you are missing the paper size...
kavvisAuthor Commented:
A littel question that includes in this code..

If I would like to se a name for the output file how do I do that.. I have tried this..

Printform1.PrinterSettings.PrintFileName = "C:\xxxxx.pdf"
kavvisAuthor Commented:
Okey No I know that the problem is´nt the print view.. I have fix that problem with the Marginals setup.

 Dim newMargins As System.Drawing.Printing.Margins
        newMargins = New System.Drawing.Printing.Margins(10, 10, 10, 10)

        Printform1.PrinterSettings.DefaultPageSettings.Margins = newMargins

But still the problem is that when I take the screenshoot then it´s bigger then the A4 Papper so it dosent make it smaller when it goes to the pdf maker.. instead it just cut the left side...

So can I somehow controll the printscreen... to set it to a actually size? Set a fix size so when it´s copied it will fit into my speficic size...  Tips thank you!!

Bob LearnedConnect With a Mentor Commented:
I see now that the problem is that you are printing to something that is generating a PDF, and you need to know how to set the paper size, right?  

I came up with this sample code to set the paper size to A4:

       Dim pf As New PrintForm(Me)
        pf.PrinterSettings.PrinterName = "Adobe PDF"
        pf.PrinterSettings.DefaultPageSettings.Landscape = True
        pf.PrinterSettings.DefaultPageSettings.Margins = New System.Drawing.Printing.Margins(0, 0, 0, 0)

        For Each size As PaperSize In pf.PrinterSettings.PaperSizes
            If size.Kind = PaperKind.A4 Then
                pf.PrinterSettings.DefaultPageSettings.PaperSize = size
                Exit For
            End If


Open in new window

kavvisAuthor Commented:
It worked very well..
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.