C# Define page orientation for a Webbrowser control

Asked

Viewed 20 times

0

Hello. Referent: Windows Forms.

I have a Webbrowser control on a form that is displayed to the user. This Webbrowser displays an HTML document in its Documenttext property. I can display the form perfectly, but when printing the orientation: Landscape is what I want to define.

What I’ve already tried: Create a Printdocument control and assign Webbrowser HTML, so you could configure the page in the Printdocument properties. Unfortunately it is not possible to transfer from a String to Drawing.Printdocument;

What might solve, I don’t know if I’m on the right track: A Printdialog control that will receive page settings. Apparently you need a Printdocument with the page settings, but return to the problem of the previous paragraph

Below is the code that displays the form, where dhtml is from the Stringbuilder class:

FrmVisualizadorHTML f = new FrmVisualizadorHTML(dHTML.ToString());
f.ShowDialog();

Form Frmvisualizadorhtml

    public partial class FrmVisualizadorHTML : Form
    {
        private string DocHtml;
        public FrmVisualizadorHTML(string HtmlParaMostrar)
        {
            InitializeComponent();

            DocHtml = HtmlParaMostrar;
        }

        private void FrmVisualizadorHTML_Load(object sender, EventArgs e)
        {
            webBrowser.DocumentText = DocHtml;
            
        }
    }

I am printing the document using the standard Crtl+P shortcut.

1 answer

0

Leandro, when trying to print by PDF virtual printer choose the orientation (Landscape) Tell me if it works that way.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.