Search code examples
vb.netvb.net-2010printform

Printing scrollable form


I have a scroll-able form which I would like to print entirely.

I have already tried using this code to print it:

    Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
    Me.PrintForm.PrintAction = Printing.PrintAction.PrintToPreview
    Me.PrintForm.Print(Me, PowerPacks.Printing.PrintForm.PrintOption.Scrollable) 
End Sub

And the result isn't accurate at all.

To demonstrate my issue, here are some photos:

This is the result I want (Of course I want it to ALSO print all of the scroll-able content)

As you can see, This image contains all of the width I need for the image, but because it's a print screen image, it doesn't contain the scroll-able area which I would like to have in my printable version of the form. Good result

and this is what I get from my code:

As you can see here, I only get about 60% of the form width, and 50% of the height, and clearly, I don't get the scroll-able area.

Bad result

I don't really care about the quality I just want it to print the whole form including the Scroll-able area.


Solution

  • I Think your answer is in the article
    All you need is to reference to FormPrinting library (or import the source to your solution).

    Private Sub btnPrint_Click(object sender, EventArgs e)
            {
                var fp = new FormPrinting.FormPrinting(this);                
                fp.Print();
            }
    

    will do the printing job.
    I have tested the library, having no problems with scrollable contents like images and ....