Convert html to image - c#

Is there a way to use the firefox (or chrome or any other good browsers) rendering engine to convert html (as a text string) to an image?
I have full access to the server I'm using, so no limitations there.

You could use Awesomium and its managed wrapper WPF Chromium which contains a small utility allowing you to achieve this very easily.

if i understood your question correctly:
This article uses asp.net c# code to capture IE page and render it as image
Here

Related

Does MuPdf library have unicode or text search functionality?

Background
I am working on a WPF windows application and I want add embedded PDF viewer with only basic functionalities including PDF view, text search and page navigation.
I tried embedded Internet Explorer and Adobe PDF Reader installed method (this way ) but this method is not suitable for our requirement as Adobe PDF Reader has too may external links which can not be allowed because of the security reasons of the application.
Therefore, I am trying to use moonpdf library. This library works fine with our requirements but the only problem is there is no text search functionality in this library. (I think it shows PDF as images)
Then, I have download moonpdf source code and realized that moonpdf is using libmupdf.dll wrapping to c#.
I can modify the moonpdf source code and mupdf source code for our requirement if needed.
My Question
Is there any text search functionalities in mupdf? if so how can I use it?
In the basic mupdf library, there are several functions for searching for text. These work by searching a page for a text string, in a few different variants, and returns the area for all hits of the given text. You need to iterate over the pages yourself (in order to do forward or reverse search).
fz_quad hits[1000];
count = fz_search_page(ctx, page, needle, hits, nelem(hits));
That said, I do not know how or even if "moonpdf" has wrapped these functions.
You can certainly extract the text from a document, the MuPDF library will do that. I believe it's up to you to apply your own search criteria after that. I'm afraid I'm not expert enough to answer the 'how to' part of it though. I imagine one of the mutool examples would be helpful here though. I'll see if I can get one of the developers to answer.

WPF WebBrowser control: Disable download or how to find out all displayable filetypes

I'm writing a document view and I'd like to use the capabilities of the WebBrowser control for some file formats (pdf, e-mail).
Now I have the problem, that for every file format that is unknown to the WebBrowser control, it offers to download the file.
So the question is: How to find out what file formats (file extensions) can be displayed by the browser, so that I can display a message to the user that the current fileformat is not supported for displaying instead of getting a "Do you want to download" dialog box.
If I was you I wouldn't use a WebBrowser control for following reasons:
WebBrowser is just a wrapper around IE engine. It uses old version of IE by default, so it can have troubles displaying correctly HTML documents with basic CSS styling. It can be forced to use newer versions of IE or even other engines, but it takes some effort.
WebBrowser control purpose is to display and navigate throught web pages. And navigating is essentially downloading. I believe it's gonna be hard if not impossible to prevent WebBrowser from downloading files. I believe one way you can do it is by modifying html files like this: Remove hyperlink but keep text? Also you would probably want to prevent context menu from openning.
WebBrowser control is capable of displaying PDF as described here Displaying a PDF in a WPF Application Not Working - WebBrowser or Adobe Control But I have no idea how would you prevent following the links placed in pdf
Instead of using WebBrowser I suggest you to use one of many royalty-free PDF viewing controls and convert your html documents to PDF. I believe suggested approach will take you less time and will be more robust

how can i use zxing in html5?

I currently have the zxing lib running on my silver-light project.
It's not lightning fast but it works fine and accurate.
However... the limitations are that some people use Linux and silver-light don't run very well (If at all) on some Linux platforms even with mono (moonlight)
So I'm trying to develop something that will decode bar-codes directly from an html5 page then send this information to my server by calling a service.
I am using c# at present.
I have the zxing jar files but have very little to no idea how to utilize them in an html5 page.
I have the webcam up and running using the html5 getUserMedia and can grab a frame from the stream and put it into a canvas, but can not work out how to integrate it with the zxing library.
Any and all help will be well appreciated.
There are a few native JS barcode scanning libraries out there that you could use:
http://badassjs.com/post/654334959/barcode-scanning-in-javascript
https://github.com/manuels/unix-toolbox.js-exact-image/
https://github.com/LazarSoft/jsqrcode
The last one is apparently a port of zxing, though it looks like it is tailored to QR code scanning.
I'm working on something similar. Trouble is, I've not gotten it to completely work either. But maybe this can help:
Like you, I've gotten an HTML5 webcam with a canvas to capture stills of the barcode. To use the ZXING stuff, you'll need to either compile the java files from source yourself, or get a pre-compiled .war file and find some way to host the servlets. I'm hosting mine using tomcat with the pre-compiled war pulled down from the maven repository (http://repo1.maven.org/maven2/com/google/zxing/zxingorg/2.2/) .
Once that's set, the ZXING decoding servlet is expecting either a URL or a file from an html form that has its action set to the url of your decode servlet. So you could take captured barcode on the canvas, save it to a file, and then have the user manually submit the file via the html page(exactly like the zxing.org web version) and that would work. However, if you wanted to seamlessly take the captured still and send it to the ZXING decoder, it's a bit more difficult and that's where I'm stuck as well.
I used javascript to convert the canvas's image to a blob first (and mind you, this only works in Firefox, since Chrome doesn't support canvas blobs yet. no idea about IE). Then I created a new FormData object, giving it the existing id of a form on the webpage, and appended the blob to that form. Then I used a submit button on the webpage to do the actual submitting of the form, which sends it via post to the decode servlet. I then get a nice white page with a console error about the character encoding of a plain text document not being declared.
I've also tried creating a new XMLHttpRequest in the javascript file, appending the canvas blob to that rather than an existing html form, and submitting via that. According to the console, that seems to get a bit farther (the console will show whether it redirected to a "results not found" page or to the results page), but I can't actually see/manipulate the output data.
Sorry I can't be of more assistance. I'd love to see someone get a completely web based version of this working since ZXING seems to be really good at the decoding process.

How do you display HTML in windows app?

I have a bunch of HTML code that I need to display in a label/textbox in a windows app written in c#. It should be in such a way that the output shows the HTML formatted text, rather than the HTML code itself.
How can I do this?
Render your HTML in WebBrowser control. It has special events for document and you can iterate by tags like this Hope it will help you;)
Check out WebBrowser
There's a web browser control using IE's rendering engine to display HTML content. You might as well be able to do some simple parsing yourself and use a RTF control but that way you will be rather restricted.
If WebBrowser doesn't suit your needs you can check out these libraries with HTML label/control support
Telerik Controls for WinForms (Not Free)
http://www.telerik.com/products/winforms.aspx
GDI+ HTMLRenderer (Free, Open Source)
http://www.codeproject.com/KB/GDI-plus/HtmlRenderer.aspx?msg=2934040
The HTML Editor (a wrapper for MSHTML, the rendering portion of Internet Explorer) in read-only mode might be what you need.

How can I display flashfilms in ASP.net?

In my current project I have the following situation: A multipage PDF gets rendered by some nasty software into a flash film. My job is to display that rendered flashfilm (will be rendered as file) in my current asp.net application.
I don't know what the rendered flashfilm will look like, but I assume all flash files behave the same? Or are there differences I should know about.
What options do I have to display that flashfilm? Does ASP.net support some built-in object oriented control that allows me to display flashfilm?
You can easily display any flash file by using a plethora of techniques. And it's not built-in, but there are a number of controls and other libraries built by the community to deal with displaying flash content in asp.net, such as Flash Control (http://flash-control.net/)
what you refer to as a flash film is a .swf file. the recommended way to embed .swf files is SWFOBject , a javascript library
http://code.google.com/p/swfobject/
now, i'm no asp specialist , but you may be able to fill the gap between javascript & asp.
hope it helps!

Categories

Resources