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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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"
Bob LearnedCommented:
I haven't used the Visual Basic Power Packs, but I would think that you are missing the paper size...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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 LearnedCommented:
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..
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.