I am creating a web application and I want to print contents of my webpage. I have seen quite a lot of videos and support forums but I cant find what I'm looking for.
Basically PrintDialog is not available in my Visual Studio 2013 toolbox, is there any way of getting it?
Or if possible not use PrintDialog because I cant find it. I have been using C#.
I just want to know the simplest way to print.
P.S I am new at coding, any help and suggestions would be greatly appreciated.
Thank you all
New Info ----
Sorry I should have been more clearer, basically I have different reports on my web page and i want users to be able to print the individual reports. They are mini reports in one page in different sections, I want to be able to print seperate sections
Because the PrintDialog is for forms applications.
Each browser has its own printing implementation that you cannot influence.
To print the content of a webpage, you use the BROWSER's printdialog. In VERY OLD DAYS people added a "Click here to print" on websites, but actually you can just call:
window.print();
from Javascript OR press [CTRL+P] (or whatever key the browser you are using wants) or use the menues in the browser where there will be a print function available too.
The problem is that you dont instantiate the print from a HTML-server aka a webserver, and if you want to simulate that behaviour anyways, you will need a script, like Javascript in the page that will call the window.print() function.
This will still bring out the Printdialog and the user will still need actively to choose to actually print the thing, so you cant force it out on paper from server/site.
Think of the browser as a viewer/reader. Nothing else, and the server as the document storage.
Related
Currently we're making a c# application (using WPF) and everything goes well. The only problem we have right now is that we want our application to be able to print documents directly from our application to the printer.
What we need to print is a list of customers, but not listed on a sheet, instead it should print 1 full page of information from every customer that yet haven't been printed. The document should also contain some formatting such as a "Result" section where you manually fill in information using a pen later on.
I've found several solutions but they all require us to either use iTextSharp and have Acrobat Reader installed. This way works but just complicated things for later on as some of our teachers doesn't even know what google chrome is, and less so even grasp the concept of having to install acrobat reader to be able to run this program.
Our other option is to create a simple report directly in c#, but all the tutorials use windows forms and a datagrid which doesn't feel very effective for what we're trying to achieve. Also we can't find reports in the "add new" menu for the solution explorer and we're not using windows forms.
Basically we want to press a button which automatically prints all the new customers that yet haven't been printed out. We're all good with the other backend stuff like marking the customer to not be printed again and so on, it's just the actual document formatting that've had us stuck for days now. I've searched for "c# create invoice" and so on, but every tutorial uses windows forms or Crystal Reports while we can't.
Any suggestions?
I am creating a program that will schedule classes for me for my upcoming semester, and I have everything working in regards to inputting my username, password, and Schedule ID, however I want it to work as fast as possible. I did some research into disabling images from being downloaded, but have yet to come to a conclusion.
So basically, I want to request the website, but I don't want none of the 'fancy' UI such as images, animations, etc... I just want plain text and the respective fields. Is this even possible using VS WebBrowser? Would this be along the lines of just gathering the HTML and no CSS/JS?
Thanks for reading! Any hints or help in the right direction would be muchas gracias!
As it turns out, this is not possible in a "nice way." The images are loaded and requested after the html loads, and so there would have to be a way to disconnect or abort the request, just after we recieve all of the html. Digging around, you cannot do this natively in VS' WebBrowser.
I need to display PDF preview in WPF control, programmatically search for text in it, highlight found text and be able to copy text. Sounds simple, but I am struggling with different approaches for a week already.
Here what I have considered:
Find PDF controls for WPF
Most of them just render PDF as images or cost too much. Royalty or subscription fee is not an option.
The only suitable control that I found is:
http://www.syncfusion.com/products/wpf/pdf-viewer
I was even able to do searches programmatically with reflection hacks, but it renders text too blurry (Syncfusion promise to fix this soon) and load pages with a noticeable lag during scrolling.
Using AcroPDFlib as an ActiveX component
I was not able to make it work with the latest Adobe reader on Windows 10 64-bit. But I don't see methods for search anyway, so I dropped this. Also, it seems that it is not free for commercial use:
AcroPDFlib, AxAcroPDFLib commercial use
Load PDF in WebBrowser control
It works and even allow searches, but it can search only for single words which make this search useless. If I search for "big apple" it highlights all big and apple and also open this search panel that cover the document.
Send CTRL+F and text to the browser control to trigger search
I have tried to use this library
http://inputsimulator.codeplex.com/
But PDF in browser control seems to ignore keystrokes from there or maybe I am doing something wrong. Still considering this option.
Use pdf.js in browser control
IE7-based control from WPF won't support that, so I need another browser control. And it seems that I also need to start nodejs to make it work. Seems like a too much overhead for this task. And also it is not clear does PDF.js supports search for a phrase or not.
But I am still not discarding this option. Does anyone were able to make it work inside WPF?
Any suggestions?
We are currently using jQuery to populate web forms. jQuery receives its information from parsing the results of an executed php script. This works, but is completely dependent on the web server being accessible and functional.
We'd like to see how to consolidate this and create a C# console, WinForms application - or possibly a toolbar/IE addon of sorts down the road.
Right now we are trying to figure out how we can interact with an external Internet Explorer process (most examples we see are in regards to WebBrowser controls). We're ultimately wanting to fetch elements by name/id and populate them with text. From an end-user standpoint, we want to mimic the functionality of roboform.
We are not interested in form submission - just acqusition of the proper instance of IE and form population.
Are there any resources you could point us to that would have an example similar to our desire?
It used to be possible, I did that for IE7: How to connect to a running instance of Internet Explorer. I haven't verified if it still works for IE8+. You may also have some luck using this technique: How to get IHTMLDocument2 from a HWND.
I am attempting to create a 'find on page' search option for a wp7 webbrowser control named 'TheBrowser' (using the standard webbrowser control in Visual Studio). I have done a lot of research but have not found much in the way of an example or sample where this was implemented. Essentially I will just be activating the search on a click event, from a textbox where the user may type in a word to search in the current webpage. I would also like to highlight the matched words as seen when doing a find on page search on a desktop browser.
I believe that to create this 'find on page' option I should use javascript to search through the lines of text, and then somehow highlight matched words. I have already implemented forward, back, and refresh buttons using TheBrowser.InvokeScript, but I do not know how to format for searching through the entire webpage (I have never done anything like this before). Any advice or assistance would be greatly appreciated, including code samples as I am completely new to this subject! Thanks in advance for your help and hard work!
Try jquery, this should do the trick: http://hugoware.net/blog/more-jquery-magic-search-highlighting You'll just need to inject the jquery script into the page.