I am beginner in programming. My problem is, I want to show PDF files in Google Doc Viewer in my website page. I put my PDF files in folder named as Bullettin, it is in App_Data folder.
How can I view this PDF file in my website through Google Doc Viewer using C# MVC4 application?
i used the following code in view page
http://docs.google.com/viewer?url=http://localhost:3907/App_Data/Bullettin/JCI.pdf&embedded=true" target="_blank" class="embed">View
You should use the following url for embed: http://docs.google.com/viewer?url=http://localhost:3907/App_Data/Bullettin/JCI.pdf for previews
and: Preview
for links, and finally:
<iframe src="http://docs.google.com/viewer?url=http://localhost:3907/App_Data/Bullettin/JCI.pdf&embedded=true"></iframe>
For Iframes.
Well, localhost will not work for you, so get your project on a live server or use an IP address to link your server.
Good luck with it.
Related
I am trying to download a file from one of this sites:
1cloudfile
bowfiles
games-database
Mainly games-database.com
I think all of this sites are using a similar System
For example games-database.com:
An example link: https://games-database.com/1JD4
There is one button on this website that opens a new window with a link
<button style="margin-bottom: 30px;" class="btn btn--primary type--uppercase" onclick="window.location = 'https://games-database.com/1JD4?pt=ZUVGTGRtaExNa3hIYkdJMllrcHZkbkJ6TjBGU1p6MDlPbWFXZ3IrNnZDMzI1MnZzVlVJU2hKQT0%3D'; return false;">download</button>
Link: https://games-database.com/1JD4?pt=ZUVGTGRtaExNa3hIYkdJMllrcHZkbkJ6TjBGU1p6MDlPbWFXZ3IrNnZDMzI1MnZzVlVJU2hKQT0%3D
This link is different everytime I refresh the page
It's easy to get this link with HTMLAgility Pack
using HtmlAgilityPack;
var link = doc.DocumentNode.SelectNodes("/html/body/div[2]/section/div/div/div/div[3]/div[2]/button")
.Select(p => p.InnerText).FirstOrDefault();
But when I try to download this I only get the page not the file
The working generated download link after the redirect looks like this:
https://dl5.cdnrobot.xyz/1JD4/Anomic_THE_NEW_GUI.txt?download_token=f58c9315280ed7474c15a329888ac8532e2af1cdaec045f4048bc51fcacd7e75
I don't know if the sites uses cookies or something else but maybe you can load the page in the background and then get the download link by tracking the redirects.
Thanks for everyone who wants to help!
I am on WPF .NET 6.0 btw
[EDIT]
I found a website called https://wheregoes.com and it manages to track the correct download URL
Then it tell me:
Status Code: 200 - Meta-Refresh Redirect
In conclusion I need a way to trace this redirect to get the download URL
I am making a app for SharePoint and have a form with several inputs for text and for files as well. The input for files works fine for regular files such as Word, Excel, PowerPoint, images etc... but wont work with videos. Is it possible to upload a video to a document library by code? Or cant you do that simply because the files is usually to big and would take long to upload?
The files is of the type HttpPostedFileBase and sent by a normal mvc form.
And this is the code for uploading it to the folder
FileCreationInformation attachFileInfo = new FileCreationInformation();
attachFileInfo.ContentStream = pNewRequest.FileToUpload1.InputStream;
attachFileInfo.Url = Path.GetFileName(pNewRequest.FileToUpload1.FileName);
newFolder.Files.Add(attachFileInfo);
According to this StackExchange answer, SP videos are organized in special VideoSet folders which seem to be similar to doc sets.
You said you're using MVC to submit the files so I'm assuming you're using CSOM on an external server. Here's an example for handling video uploads via CSOM.
I developed some integration between Jira and TFS.
Some bugs in TFS have image in Description like this:
<span style="color:black;font-family:"Segoe UI",sans-serif;font-size:9pt;"><img style="width:606px;" src="http://server:8080/tfs/IT_Systems/WorkItemTracking/v1.0/AttachFileHandler.ashx?FileNameGuid=7d796b11-588f-4266-a783-8d3fa61cb4bd&FileName=temp1465385989194.png"><br> </span>
How can I download this image programmatically using c#?
I know I should parse HTML and so on. But problem is I don't know how to extract data from URL.
In TFS web part I select image, copy it, open for example Paint, past image and save it as jpg-file.
I need the same in my c# code.
Can anyone help me?
I would use Regex to parse the HTML description and pull out the img URL then download the image using a HttpWebRequest.
You could use the following Regex:
(?<=<img.*src=")[^"]*
I'm trying to open a document on server through google docs.
I can get the path and name of the file on the server.
And then on Button click event I wrote a method to open the file through google document reader.
string path = \\xxx-yyyyy-zzz\DocShare\sample1.doc //path of the file on server
Response.Redirect("http://docs.google.com/viewer?url=" + path);
When I run this code, I'm getting something like below
Can some one help me to find where did I go wrong? Is there any other method to open any document(ppt, doc, pdf etc) using google document reader.
TIA
What is \\xxx-yyyyy-zzz\DocShare\sample1.doc and where it is ?
A relative url dosen't specify a protocol & domain which makes the
browser to assume the document is referd from the same site/domain.
Please verify if you can access the document itself with the relative path.
http://docs.google.com/viewer?url=https://s3.amazonaws.com/scotchio/First-Node-App.pdf works for me as i can access the pdf. Try using the absolute url of the document
It doesn't work most likely because the file is not accessible from the Internet. The google doc previewer needs to be able to access the file in order to display it.
The general problem: I have some code that needs a URL to a PDF file. It seems to work for URLs I find online, but not the ones I create myself.
For example, when I use a random URL from Xamarin it works fine, but when I try to generate a URL from either DropBox or Amazon Cloud Drive it does not work.
Example URLs:
These links open harmless PDF files. Please try it:
Xamarin (works fine)
DropBox (does not work)
Amazon Cloud Drive (does not work)
As you see, in a browser (I have used Chrome to test) you will get the PDF documents to open, but not without some kind of context (except for the Xamarin one).
The code: I am developing in MonoTouch and I am using a component called mTouch PDF Reader. The code is simply:
var documentViewController = new DocumentViewController (1, "Some name here", "http://someurlhere.pdf");
ActivateController (documentViewController);
This opens a nice PDF reader inside my app, but, as I can't use my own created URLs this does not help me. This is a 3rd party library so I can't look at the code. By the way, when I use one of my URLs, the code crashes with a System.NullReferenceException with this stacktrace:
MonoTouch.Foundation.NSArray.FromNativeObjects (items={MonoTouch.UIKit.UIViewController[1]}, count=1) in /Developer/MonoTouch/Source/monotouch/src/shared/Foundation/NSArray.cs:109
MonoTouch.Foundation.NSArray.FromNativeObjects (items={MonoTouch.UIKit.UIViewController[1]}) in /Developer/MonoTouch/Source/monotouch/src/shared/Foundation/NSArray.cs:96
MonoTouch.Foundation.NSArray.FromNSObjects (items={MonoTouch.UIKit.UIViewController[1]}) in /Developer/MonoTouch/Source/monotouch/src/shared/Foundation/NSArray.cs:48
MonoTouch.UIKit.UIPageViewController.SetViewControllers (viewControllers={MonoTouch.UIKit.UIViewController[1]}, direction=MonoTouch.UIKit.UIPageViewControllerNavigationDirection.Forward, animated=false, completionHandler={MonoTouch.UIKit.UICompletionHandler}) in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIPageViewController.g.cs:144
mTouchPDFReader.Library.Views.Core.DocumentViewController.ViewDidLoad () in
MonoTouch.UIKit.UIApplication.UIApplicationMain () in
MonoTouch.UIKit.UIApplication.Main (args={string[0]}, principalClassName=(null), delegateClassName="AppDelegate") in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
Exam936.Application.Main (args={string[0]}) in /Users/EdGriMac/Dropbox/Quiz/Code/Exam926/Exam936/Main.cs:16
The frustration:
Is there a specific way to create URLs that work in this way? It does seem like DropBox does something different as it sort of iFrames the document or something. I don't know what Amazon Cloud Drive does. What has Xamarin done? Is it, as pointed out in the comments, because of http vs https?
I am completely lost. Am I missing something simple? Do you have any other way to create URLs to suggest? Googling this is really difficult as I continue to hit examples of how to share a URL in DropBox and so on...
By the way, I do not want to have the documents as part of the app as this means I will have to create a new version of the app just to change something in a document.
Update 1: I have added links above. I will try some other suggestions later and will leave more updates. Thanks in advance for any further suggestions!
Update 2: I have used Fiddler to look at the response on each of the URLs. The Xamarin URL has Content-Type: application/pdf while both DropBox and Amazon Cloud Drive has Content-Type: text/html; charset=UTF-8. This explains a lot. I will try andersr's suggestion later today as I do have a web server to put files on.
Update 3 When I put the PDF file on my Amazon EC2 server, created a virtual directory under my web site in IIS, the URL to my website + virtual directory + filename worked! Turns out the Content-Type had to be application/pdf for the mTouch PDF Reader to open it through a URL.
Thanks everyone for your help!
It seems to me that the first two URLS, link directly to the PDF files, but the latter one, ie. the one on Amazon Cloud Drive links to a page which again links to the PDF. I suggest the following potential solutions:
Find a reliable way to extract the direct url to the document on cloud drive. The link to the document is not the one you provided, but this: link . Perhaps Amazon has documentation on how you can avoid the html interface in order to retrive your file. I am not familiar with cloud drive at all. Note that the url provided has some time limited token attached to it.
Host the document on infrastructure you have more control over. IE. setup your own web server and host the documents there. Alternatively use another cloud storage provider which gives you the ability to link to files directly.