display docx file into a winform in c# - winforms

I'm trying to make my program have the ability to display a Microsoft Word file on a form but not having any luck in doing so. I want to be able to open the file and display it on the form as a Read-Only. So basically just display it's contents. Various users on the web have recommended displaying files in the WebBrowser control (under toolbox). I have tried this but failed to get it working. My end goal is to be able to annotate on top of the web browser (or something of similar manner) and subsequently save the annotations along with the opened file.
I'm not that experienced in the C# language too so any help on how to achieve my problem would be greatly appreciated.

Related

How do you run a VTSO Word project in the same solution as the start-up project during run-time and pass variables to the content controls?

In short I want to pass variables to a vsto project from my windows form project and I don't know how.
I currently have a windows forms project that is near completion with one major piece missing. I have been searching for about two work days for a way to open a VTSO word project in the same solution with a procedure in my windows form project. I know I can code my project to open the word document and my code for default values for the content controls in the "ThisDocument.vb" display correctly. I have added references to my VTSO project to refer to my forms project in an attempt to use variables previously collected to fill in my content controls text, but I have no clue how to do this. Will I have to open the word document and use interops to modify the document separately? I would prefer my answer in VB.Net but if C# is what ya know, I'll take anything to help.

How to open the index tree content of a .chm file in the wpf application using the webbrowser?

I am creating a helpbar for my application and having two things to get done :
To provide the online help from the website and display it in a window using webbrowser which i am done with.
now in the same browser i want to open the index tree of the .chm file .
so is it possible to open the index tree of the .chm file?
browser.Navigate(#"mk:#MSITStore:[my .chm file url]");
I am doing this to open a particular content , but i want the starting index tree which is displayed at the left panel of the default help viewer application provided by the microsoft.
Want to know whether it is possible else any suggestions how to approach it.
The CHM index isn't an HTML page — it's stored as binary data in the CHM file. So it can't be displayed in a WebBrowser.
I'd recommend using unpacked HTML help if you need to display the help in a WebBrowser inside the app.

What control can be used to display txt files as well as pfd and .doc

I'm relatively new to windows forms programming and was looking for a control that could be used to display both .txt, pdf, and doc files. When I first started googling for a solution I was led to the possibility of using the wpf xps control, but I would have to figure out how to integrate that within a win form app and still wasn't clear as to whether it would solve all my problems. Any guidance on this will be greatly appreciated.
Thank you!
In general, I wouldn't do that (try to find a single control that can do everything). Instead I'd think about creating different controls for different types of content and toggling the visible state on the control depending on what content you're displaying.

Show pdf inside silverlight application. PDF to XAML

I need to create silverlight application where customer will see some pdf files.
PDF files have to be inside silverlight control and not rendered as images (customer wants to select text)
For this purposes i need some free libriaries or code to convert pdf file to xaml (or just open pdf so i can convert it to xaml).
Which library can read pdf and help me to convert data to xaml?
Can I read somehow pdf file and write custom convertation tool?
I saw iTextSharp. Is this library can read pdf and help me with my issue?
I will be thankfull for any ideas or links.
I make use of the Acrobat Reader plugin to do the displaying for me. It does require a different method depending on whether your application is running inside or outside the browser (I check if the application is running inside the browser and change the means of display accordingly). If running inside the browser, I overlay the application with an IFrame, as I describe in this article: http://www.silverlightshow.net/items/Building-a-Silverlight-Line-Of-Business-Application-Part-6.aspx. Otherwise, I use the WebBrowser control. I have a control which does this all for you in the source code that accompanies my book, which is downloadable from the Apress website here: http://www.apress.com/9781430272076/.
Hope this helps...
Chris

Changing "active content" security settings on WPF WebBrowser control

I'm putting together a WPF application that will allow users to view PowerPoint files through the WebBrowser control, once the files have been saved as either .MHT or .HTML. The problem is that the files contain ActiveX controls, and the WebBrowser control by default will display a warning every time I load these files, saying "To help protect your security, your web browser has restricted this file from showing active content that could access your computer."
I've seen a few different places online talk about putting the mark of the web into each page, but that really doesn't work for me in this case, since the content authors have control over the files, not the developers, and I'd rather not tell them that they have to open every single file in Notepad and add the mark of the web to each one.
Is there any way to just change the WebBrowser control's settings to not display that warning message? IE has a similar setting, but it doesn't carry over into this control.
We eventually found a decent solution to this, although I still wish there were some sort of settings on the control itself. To load the documents, we just set browser.Source to be the following:
file://127.0.0.1/c$/path/to/the/file (where the path is an absolute path without C:\, for example, c$/Users/jschuster/mydocument.html)
For whatever reason, the control will display files referenced by a URL in that format without a warning.
Hope this might help someone even that the question is a bit old ...
As per the link to "The Mark Of The Web" , adding comment like
<!-- saved from url=(0016)http://localhost -->
just under the HTML tag worked.
My index.html is in HTML folder, added as "content" set to "Always copy" in WPF project using WebBrowser control.
The address to the file during execution look like this:
file:///E:/SRC_2013/WebBrowserTestApp/WebBrowserTestApp/bin/Debug/HTML/index.html
Why not insert the MOTW dynamically at the beginning of the file when you load it ?
By the way, thanks for your question : I didn't know about the "mark of the web" and it solved a problem I had :)
file://127.0.0.1/c$/path/to/the/file (where the path is an absolute path without C:\, for example, c$/Users/jschuster/mydocument.html)
This worked for me as well on Win7.

Resources