I have a requirement. I have to enable users to attach documents and that will get saved in the db in binary format.
Now the challenge is, I have to display the document list in the silverlight application and when user clicks on any of the link it should not ask for downloading the document instead it should open the document in the next tab. (the document could be pdf, png, excel, doc).
I have gone through multiple threads but all those thread ends on either third party tool or OOB. I cannot have OOB enabled.
I just want to check is there any way we can achieve this using silverlights inbuilt functions.
I think a combination of #Blam's comment of sending the proper mime type coupled with a Silverlight HyperlinkButton with the Target set for the new window would be your ticket. The XAML would look like this :
<HyperlinkButton Content="Name of PDF" Target="PDFWindow" NavigateUri="/DownloadPDF.aspx?id=BINDING OF UNIQUE ID" />
You'd add a page to your Silverlight project called DownloadPDF and it would take in one argument in the request variables; the unique ID of the PDF to grab from the database. DownloadPDF would change the mime type to "application/pdf" and then write the bytes from the SQL server to the response stream.
Related
hey i'm working on project in which I have webform which includes some editfields. I don't want to enter the data manually into that editfield. what I want is to extract data from a word document and fill that editfields. But the catch is, through which MS doc I fill the editfield?
Suppose We have a bunch of lectures uploaded on some page. so what should I do to retrieve the data from a particular document?
Is it necessary to open the MS-doc file first?
or I should download the file first?
If I goes with option 1 when should I have to use some library? what opens the file within browser, retrieve the data and the a pop-up message appears "the data has been retrieved now you can close the file". and next I can fill the form with that data.
or should I goes with the 2 Option when an individual hit the download button then the file will be stored into the local machine. how can I keep the track that which ms-file is downloaded or stored into the local machine?and is it necessary to open that file for retrieving the data again?
These are my point of views that how I can implement that module. So I need your suggestions? Is this the right way to achieve this goal or should I follow the other path? and which libraries are required to achieve this task or any tutorial similar to this problem ?
Thanks in Advance
I would suggest considering a third option: since the Word document files exist on the server, the cleanest place to pre-populate a form would be by extracting data from the document while it is on the server and filling in the form's fields before sending it down to the user in a codebehind. Trying to extract data on the client side from a recently-downloaded file via an application other than the browser seems ripe for kludgy-ness. Articles such as http://support.microsoft.com/kb/257757 should help get you started in the right direction.
For extracting data from ms word document using free .net word component and fill data to webform,
extract data,
Document doc = new Document();
doc.LoadFromFile("YouDocOrDocx.Docx");
string content = doc.GetText();
How to disable the pdf Toolbar because I don't want to give the download option to the pdf viewers.
I have used Iframe for showing Pdf File please find the following code
<iframe ID="iFrame2" runat="server" align="bottom" frameborder="2" name="iframe1" height="500" width="600" src="~/pdffiles/example.pdf"></iframe>
Please help me to disable the download option using c#.
Thanks
You cant. It is a browser feature which means you have no control over it.
You can use third party tools like Google Document Viewer or change the format of your document to an image.
Google Document Viewer
If you want to avoid that an end user saves a PDF document, you are asking something that is impossible. The only way to avoid that an end user doesn't have a copy of the PDF is by not sending him the PDF. A PDF can't be opened in Adobe Reader without having the actual bytes on the disk. Even if you would disable saving (for instance in the context of a web application), you'd always find the PDF somewhere in the temp files and people would be able to copy that file as many times as they want.
Trying to hide the toolbar (a viewer preference) doesn't make sense. Whether or not this viewer preference will be respected entirely depends on the PDF viewer. For instance: in Adobe Reader X and later, you have a special widget (HUD or Heads Up Display) that appears when you hover over the document. This widget allows users to save the document.
Let me quote Adobe:
the "Heads Up Display" (HUD) is not customizable. There are no APIs to
HUD. You can’t use JavaScript to enter Read Mode, exit Read Mode or
detect that the document is in Read Mode. Though it might seem like
it, this wasn’t an oversight. There are some very sound engineering
reasons why this is the case but I won’t go into those here.
Even with Adobe Reader 9, hiding the toolbar isn't sufficient: if the user chooses the appropriate menu item or hits the appropriate "hot key", the toolbar would appear and they could happily click the Save button. In addition, they could have right-clicked and chosen "Save" as well.
In short, you're asking the wrong question (and that probably explains the downvotes given by several people).
Suppose in .NET (don't care what language) I want to show a user a PDF, Word and Excel file together. I am trying to replicate a document process where a user might have a PDF file and he would like to attach a WORD file and an Excel file let's say to make a stack of documents (that I would save in some directory). Then he would like to click on a button and see a stack of these documents in 1 application of some sort.
How can I display the stack of documents WITHOUT first opening WORD, then openinig EXCEL and then openining ADOBE ACROBAT - this would be really annoying for the user. I would like one unified application or some idea to mimic one in .NET that can just show all 3 documents as if they were printed one after the other on paper. (I hope I am explaining this clearly)
The only thing I can think of to do this would be to leverage some sort of PDF conversion process to create one PDF file containing all three of these documents in "printed" (page-by-page) form, and then show that. The one application I can think of that could show all of these files is a web browser with appropriate Office and Acrobat viewer plugins, and you might find it difficult to leverage that, as browser preference and other user OS settings can cause various strategies for application launching to fail.
I would convert the documents in PDF and develop a pdf viewer inside your application.
I would use a ready made library for that, don't reinvent the wheel.
For example: http://www.quickpdflibrary.com/products/quickpdf/index.php
i am using c# to create a button for IE and this button performs certain actions that all depend on the document being a PDF document. I am trying to setup a guard to prevent any action taking place if the document type is not a PDF but not sure how as IE hands over the document to adobe and reader takes charge. I am using both SHDocWv have looked at the WebBrowserClass objects and not sure how to figure this out. any suggestions?
It's a little bit problematic to do this AFAIK.
Value of IWebBrowser2::Type property depends on what plug-in you have installed that handles PDFs, because some plug-ins creates HTML wrapper for PDF file (like Adobe) so you get "HTML Document" as type and some plug-ins don't do this (like Foxit), so you can't relay on this exclusively.
So if you got PDF with HTML wrapper you can use IHTMLDocument2::mimeType to find out exact type of the document (JPEG/GIF/PNG/etc. files are all wrapped in HTML by the browser). But as I know it is unreliable too, for instance on my machine it returns "Firefox Document" for HTML documents because .html files are associated with Firefox :s But I didn't test to see if this is the case with PDFs alos.
Another options is to use GetUrlCacheEntryInfoEx API call to obtain file in local browser cache which stores document, then read it (only the beginning of the file, I think only the first 256 bytes are important) and call FindMimeFromData with data you just read and it will return mime type.
Check mime type of the document or see the window.location.href of webbrowser... If pdf is being displayed, you would be able to find it...
Another good way is to do the following..
1] Cast the Document object to IPersist and then extract the CLSID using .GetClassID(..).
2] pInvoke ProgIDFromCLSID to extract the progId
3] Match the progID against known COM objects / applications.
I have an ASP.NET 2.0 (C#) webpage with a link that pulls a blob from a MS SQL database and ouputs it in the appropriat file format, i.e., Word, WordPerfect, PDF.
My users would like to print these files with one click. Right now they have to click the link to open the file, then click the "Print" button within the application that they file opened.
In addition, I would like to send multiple documents to the printer, using one click, if possible.
Thanks.
Do you want to print to a Printer attached to the Server, or attached to the client?
If you want to print on the Client, you won't have much chance. For HTML Content, maybe some JavaScript or Flash could trigger the Print Dialog (not sure), but if it's a File that has to be opened in a third party application (i.e. PDF, DOC, XLS etc.), you're out of luck.
If it's an internal Network, you could possibly create a Desktop Application that is installed on every Client's PC that then triggers the Print.
If it is a Printer Attached to the Server, you can use the standard .net facilities for Printing, although you again may have to work around situations where you are trying to print PDF/DOC/XLS etc., because then you need to use Automation (either COM or something like SendKeys), which will cause you headaches on a Server.
So in Short: Not much you can do with only ASP.net at your disposal.
The closest I've gotten to this is using Javascript:
<body onload="window.print()">
...
</body>
which will pop-up the print dialog when the page loads (see this post for more). If you think about it, you probably won't be able to do much else unless you are on an internal network. How would you like your computer to start printing pop-ups "automatically"?