Note that there are some explanatory texts on larger screens.

plurals
  1. POPrevent webbrowser from formating html file in c#
    text
    copied!<p>I have some trouble using the webbrowser control in C#, especially when I print it. The thing is, I have a Barcode in my html file and I have to print it (I use a font to create the code). When I open the html file with Firefox or any other Web browser, my barecode is good and I can scan it. But, when I open my file with my webbrowser in c#, or when I print it, the webbrowser ad 2 characters after the barecode. And, when I print the file, my document is not centered, it's like the webbrowser add a margin-left property. So my question is, is there any way to print an html file, using a webbroser, exactly how I see the html file when I use firefox or chrome for example. Here is the code I use.</p> <pre><code>curDir = Directory.GetCurrentDirectory(); webBrowserA4.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(PrintDocument); webBrowserA4.Url = new Uri(String.Format("file:///{0}/print.html", curDir)); private void PrintDocument(object sender, WebBrowserDocumentCompletedEventArgs e) { // Print the document now that it is fully loaded. ((WebBrowser)sender).Print(); // Dispose the WebBrowser now that the task is complete. ((WebBrowser)sender).Dispose(); } </code></pre> <p><strong>EDIT</strong>: So, now, I have another problem, here is the screen of what my file looks like when I print it: <a href="http://imgur.com/q7ovEA1" rel="nofollow">http://imgur.com/q7ovEA1</a> As you can see, there is a "margin-left", and I can't remove it. I also want to remove this "page 1 of 1" and the Title.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload