C# webbrowser control - I want to use / link a specific font - c#

I'm writing a simple textviewer for the famous .nfo files.
For easy layout stuff I'm using the webbrowser control to display the nfo file.
I have font - nonstandard ofcourse - that I'd like to use.
What's the best way to include / link the font in my application ?
Do I have to include it in my application-folder and register it, or is there a way to use a font in my control that's not standard installed ?

The fonts are not part of the web control. The fonts come from the HTML of the web page that you're viewing with the web control.
So, the first step is to make a sample HTML page that displays correctly in a browser (with the fonts you want), then you can load that page into the webcontrol later.
To load fonts in the html page, see: How to embed fonts in HTML?
Once you have that, then the second step is to simply generate the HTML page text dynamically (with the font code in it and your NFO) and then stick that into the WebBrowser control.

Related

ASP:NET MVC: How can I render two styles in one page without any overlaps of CSS classes?

I am working on a web based application that generates documents with some data.
I have a new feature in the document generator, you can paste an Atlassian Confluence (in our company we use this as wiki) link in a textbox and on save the content from this specific page will appear in the document.
1. Problem: I have no possibility to get row data from the API of Atlassian Confluence without CSS-Classes.
2. Problem: I use in the document generator Bootstrap 3 and Atlassian Confluence use some Bootstrap classes too.
This means: The Atlassian Confluence stylesheet recolor and resize the element on my page and I cannot create a new stylesheet for the content from Confluence because there are some special things and I don’t have the time to do that.
Question: Is there any possibility or workaround to fix this problem with the options of ASP.NET and Razor?
Solution for my Case:
I created a new cshtml Page called "WikiContent". In this Page I render the Content from Attlasian Confluence with the Styling from Confluence. In my Document Page I created an <iframe> which renders the Page "WikiContent" with some Parameters.
I used the Answer from this Question to style and resize the <iframe> with JavaScript. I also added a Width of 100% to the <iframe>.

Is it possible to embed MS Word Editor in web Browser Control

I wonder is it possible to embed word editor as a control within Web Browser Control to write text etc and then can retrieve it?
We have telerik rad editor which can be embedded into HTML page. You can perform text formatting in the same manner that you do in MS Word. You can even retrieve the text that you have entered into rad editor

Render HTML and take screenshot/thumbnail

As part of an application I am developing, a user can create document templates using HTML (or rather, a web based rich text editor that uses HTML). When the user then saves their template, I want to be able to render this HTML 'in memory' and grab a thumbnail sized screenshot of the output, so the user can see their template looks in a thumbnail.
Is this possible in C#?

Windows Forms WebBrowser control: DocumentText vs Document.Body.OuterHtml

I am trying to obtain html from the WebBrowser control, but it must include the value attributes of input elements on the page as well.
If I use webBrowser.DocumentText, I get the full HTML of the page as it was initially loaded. The input field values are not included.
If I use webBrowser.Document.Body.OuterHtml, I get the values, but not the other contents of (), which I need so I can get the stylesheet links, etc.
Is there a clean dependable way to obtain the full HTML of the DOM in its current state from the WebBrowser? I am passing the HTML to a library for it to be rendered to PDF, so suggestions for programmatically saving from the WebBrowser control to PDF will also be appreciated.
Thanks
There are some undocumented ways (changing registry, undocumented dll export) to print the document to XPS or PDF printers without parsing the page, that is, if your can afford to roll out required printer drivers to your customer's network.
If you want to parse the web page, documentElement.outerHTML should give you the full canonicalized document, but not the linked image, script or stylesheet files. You need to parse the page, enumerate elements and check element types and get resource urls before digging the WinInet cache or downloading for additional resources. To get the documentElement property, you need to cast HtmlDocument.DomDocument to mshtml.IHTMLDocument2 if you use Windows Forms, or cast WebBrowser.Document to mshtml.IHTMLDocument2 if you use WPF. If you need to wait before the Ajax code finishes execution, starting a timer when the DocumentComplete event is raised.
At this stage, I would parse the HTML DOM and get the necessary data in order to generate a report via a template, so you always have the option to generate other formats supported by the report engine, such as Microsoft Word. Very rarely I need to render the HTML as parsed, for example, printing a long table without adding customized header and footer on each page. That said, you can check Convert HTML to PDF in .NET and test which one of the suggested software/components works best with your target web site, if you do not have long tables.

Pager HTML viewer

We are currently developing a Windows Forms application in VS 2008 C#. This application is for reading long (200 - 300 pages) law documents, and it handles about 30 - 40 docs. The application searches in document text, switches between documents, etc.
Our customer has sent the docs in separate *.rtf files for us to "put it into the application". We decided to convert the rtf files into HTML, using the MS Word's "Save as" function, and then selecting "filtered HTML". In this solution, the application can show the documents in a WebBrowser control.
Our problem is: the Customer wants an additional "Pager view" function, where the user can read the documents like it would be a book. He can see the pages on a virtual paper sheet, and then click next page, previous page, etc. Like in the browser's Print preview dialog.
I have searched the internet for any Pager HTML viewer, but I haven't found anything. Could you suggest any solution or component for showing the HTML pages in pager mode?
In last case, we can hold the original rtf files too for Pager View showing. In this case, is there any solution for view RichText files in pager mode? (We want to avoid it, if it's possible.)
Waiting for your answer:
Peter
I don't know of any components that can display HTML in pages, but a couple possible solutions could be:
edit the HTML documents and manually separate them into linked pages (or hidden divs with javascript to hide/unhide divs for navigating)
convert the RTF docs to XPS format and use WPF's DocumentViewer control - but since your app is WinForms, then you'd probably have to do something like this:
http://www.codeproject.com/KB/dialog/WinFormWPFIntegration.aspx
(though someone commented on that page about a memory-leak :S that's something to keep an eye open for...)

Categories