Download Pdf File with HTML - html

I would download and view PDF files located in a folder on a server on an html page .
The problem is that when I perform :
Embed src = " D: \\ www \\ \\ xxx xxx xxx \\ \\ xxx.pdf " alt = " pdf " width = " 600 " height = " 700 ">
Google Chrome reads " Not allowed to load local resources " ..
Where does the problem come from and how resolve it ?
Thank you in advance.

Google chrome has inbuilt functionality to read pdf files. You just have to redirect the user to the location of pdf using href and that's all, it will automatically load pdf.
P.S. - There will also be an option to download pdf.

You and use ctrl+p on the html page in the google chrome browser and save that page as an .pdf

Are you trying to do this with code, or within HTML? Is this on a local network path, or are you trying to save it somewhere from an external site?
If you've put the PDFs where they belong (assuming network) and you want the user to be able to open it by clicking on a webpage link, write your tag out with something like:
<embed src="D:\Thepath\ToYour\File.pdf width="600" height="700" type='application/pdf'> Web page Text here for your PDF </embed>
Also, it shouldn't be necessary to double-up on the backslashes, as HTML doesn't use escape characters this way (UNLESS it's actually happening in code from somewhere).
It may be worth looking into some of the responses from this article here, about whether to use an embed or object tag: Recommended way to embed a PDF in HTML

You need to pass a server relative path for the file, like this:
<Embed src="http://10.0.0.1/files/xxx.pdf " alt="pdf" width="600px" height="700px"></Embed>
When 10.0.0.1 is your server IP, also, you can use a server name like http://myserver
You also can check this for more info Recommended way to embed PDF in HTML?

Related

How to embed a Word file in a html page? [duplicate]

I have few files in doc/docx/pdf format stored on server's folder and their path are saved in database. I wish to fetch the path of these files from database and then display it on my website.
In the database the files are stored in this format
id path
1 abc/request/file1.docx
2 abc/request/file2.pdf
3 abc/request/file3.docx
To display the file i used the following method
$a = $data->path;
$b = 'http://example.com/';
$r = $b.$a;
<iframe src="http://docs.google.com/gview?url=<?php echo $r; ?>&embedded=true" style="width: 100%; height: 600px;" frameborder="0"></iframe>
Issue
Earlier the file was getting displayed but all of a sudden it is not getting displayed now
I did the following checks to see the validity of file
1) File is in proper format and is not corrupted and does exist on server folder
2) The console is not giving any errors
3) Tried to run http://docs.google.com/gview?url=http://example.com/abc/request/file1.docx on browser, there also the file is not getting displayed, however the other example url given on net are working
Can anyone please tell how to correct the error. And I would also appreciate if anyone could tell any other way(using jquery, javascript or any but reliable way) to display the files on website without disturbing the formatting of the original file
For PDF, you can use ViewerJS to render.
For doc/docx, consider using Microsoft Office Viewer as a walkaround if Google Docs Viewer is not stable enough to you
<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=http%3A%2F%2Fieee802%2Eorg%3A80%2Fsecmail%2FdocIZSEwEqHFr%2Edoc' width='100%' height='900px' frameborder='0'>This is an embedded <a target='_blank' href='http://office.com'>Microsoft Office</a> document, powered by <a target='_blank' href='http://office.com/webapps'>Office Online</a>.</iframe>
P/S: Don't know why the code snippet is not working, but you can take a look here: https://jsfiddle.net/gcuzq343/
you can use
1. google docs viewer
<iframe src="http://docs.google.com/gview?url=http://example.com/my-document.doc&embedded=true"></iframe>
2. Microsoft viewer
<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=http://example.com/my-document.doc.doc' width='800px' height='600px' frameborder='0'>This is an embedded <a target='_blank' href='http://office.com'>Microsoft Office</a> document, powered by <a target='_blank' href='http://office.com/webapps'>Office Online</a>.</iframe>

embedded image in htm document not visible while signing in Docusign

C# restapi client was used to create envelope with document
doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
doc.Name = "TestFile.htm";
For embedding image in htm document i have unsuccessfully used these options
Option1 img src data:image/png;base64
Option 2 img src data:image/svg+xml;
Reference for option 2 https://css-tricks.com/probably-dont-base64-svg/
I guess with option 1 ,there is issue of double encoding as base64 .
Request help. Thanks in advance
You can create an mhtml style of html and upload it as an html file. It can include images.
See https://en.m.wikipedia.org/wiki/MHTML

Email Blast - Adding an .ics ( Calendar Event ) to an anchor tag and having it open within Outlook

Link to JSfiddle
My first attempt at an HTML email blast and I'm kind of stuck on attaching an .ics and having it open within outlook or whatever their preferred email client is instead of downloading the .ics file directly.
The requirement
1. Clicking on the image adds an event to your calendar. (I prefer this not to be a hosted .ics file, but my searching has not led me to a way to hardcode the .ics within the HTML email)
Here's the offending HTML:
<a href="webcal://http://mathiasprovinggrounds.com/WinterWunderman/WundermanWinterParty.ics"><img class="image_fix" src="http://i.imgur.com/SvlJYLU.jpg" alt="Wunderman Winter Party!" title="We Survived the Holidays! Until next year..." width="x" height="x" /><a href="">
Currently when the email is sent and the user clicks on the image, the calendar is downloaded via their preferred web browser and not opened directly in outlook.
I've tried the following:
Hosting the .ical directly and using href="http://mathiasprovinggrounds.com/WinterWunderman/WundermanWinterParty.ics"
Using the webcal attribute as found here.
Is there a specific way I could hard code an .ics instead of hosting it on my server? That seems to be the ideal solution, but the only results I have found would include PHP and I would like to keep everything within a single HTML.
I believe the answer you were looking for could be found on this page under Creating a single-event link: https://msdn.microsoft.com/en-us/library/hh846807.aspx
Your URL, with the values replaced:
http://calendar.live.com/calendar/calendar.aspx?rru=addevent&dtstart=START_DATE_AND_TIME&dtend=END_DATE_AND_TIME&summary=EVENT_TITLE&location=LOCATION_TEXT
START_DATE_AND_TIME = yyyymmddThhmmss, required.
END_DATE_AND_TIME = yyyymmddThhmmss, required.
EVENT_TITLE = Escaped string, optional.
LOCATION_TEXT = Escaped string, optional.

How to convert en-media to img when convert enml to html

I'm working with evernote api on iOS, and want to translate enml to html. How to translate en-media to img? for example:
en-media:
<en-media type="image/jpeg" width="1200" hash="317ba2d234cd395150f2789cd574c722" height="1600" />
img:
<img src="imagePath"/>
I use core data to save information on iOS. So I can't give the local path of img file to "src = ". How to deal with this problem?
The simplest way is embedding image data using Data URI:
Find a Evernote Resource associated with this hash code.
Build the following Data URI (sorry for Java syntax, I'm not very familiar with Objective C):
String imgUrl = "data:" + resource.getMime() + ";base64," + java.util.prefs.Base64.byteArrayToBase64(resource.getData().getBody());
Create HTML img tag using imgUrl from (2).
Note: the following solution will allow you to display the image outside of the note's content.
On this page, you'll find the following url template:
https://host.evernote.com/shard/shardId/res/GUID
First compile the url from some variables, then point the html image src = the url.
In ruby, you might compile the url with a method similar to this one:
def resource_url
"https://#{EVERNOTE_HOST}/shard/#{self.note.notebook.user.evernote_shard_id}/res/#{self.evernote_id}"
end
...where self references the resource, EVERNOTE_HOST is equivalent to the host url (i.e. sandbox.evernote.com), evernote_shard_id is the user's shardId, and evernote_id is the user's guid.

View a PDF file in HTML not to download it

I have a very simple pure html file in which I have many PDF files. I have link it like this:
PDF 1 here
When I click the link, the PDF file is downaloaded and viewed in the native Reader program. I want it to open in another window of the browser, and read it there, rather then saving a copy manually to my computer and opening it.
2018 Update
Almost all modern browsers have built-in PDF viewers. You can directly link to the PDF file and the browser will view it. You can also use an <iframe> if you want to view it inside an HTML page (e.g. with your website headers, etc.).
Another approach, but more complicated and not necessary except for very special circumstances, is to convert the PDF files to HTML (as described in #1 of the 2012 answer below).
Original Answer (Outdated, from 2012)
Viewing the PDF file in the browser (without download) requires an add-on to the client's browser. Google Chrome, for example, has a built-in PDF viewer and can open files directly, while IE and Firefox require that you install a plug-in (the one that comes with Adobe Reader).
There are two other approaches:
Convert the file to HTML, image, or any other format that can be directly viewed in the browser. This conversion can be on-the-fly using a server-side (written in PHP, Python, ASP, whatever language), or you can just pre-convert all files to a readable one.
The other approach, which is the best, is to use a Flash-based PDF viewer (such as http://flexpaper.devaldi.com/). This is easy, flexible and doesn't require writing server-side code. This approach is used by many Document-sharing sites (e.g. http://www.scribd.com/, http://www.slideshare.net/, http://www.docstoc.com/)
i use this
for the HTML
<img src="images/view.png" alt=" " border="0"/>
and the view.php file for viewing it through PDF.
<?php
$path = $_SERVER['DOCUMENT_ROOT']."/demo/documents/"; // change the path to fit your websites document structure
$fullPath = $path.$_GET['download_file'];
if ($fd = fopen ($fullPath, "r")) {
$fsize = filesize($fullPath);
$path_parts = pathinfo($fullPath);
$ext = strtolower($path_parts["extension"]);
switch ($ext) {
case "pdf":
header("Content-type: application/pdf"); // add here more headers for diff. extensions
header("Content-Disposition: inline; filename=\"".$path_parts["basename"]."\"");
break;
default;
header("Content-type: application/octet-stream");
header("Content-Disposition: filename=\"".$path_parts["basename"]."\"");
}
header("Content-length: $fsize");
header("Cache-control: private"); //use this to open files directly
while(!feof($fd)) {
$buffer = fread($fd, 2048);
echo $buffer;
}
}
fclose ($fd);
exit;
?>
Make sure the your browser has PDF add-on on it.
Mozilla created the PDF.js library. It displays pdf files in a web page without an external reader or plugin.
Your browser needs a PDF reader plug in to read PDFs in browser. A quick google search should provide you with one for whatever browser you are using.
If the file is not cached, it has to be downloaded. That is, if you grab it using HTTP. If it's on your local filesystem, you could use the file URI scheme.
right click
Open with
Choose default programme
Select
Adobe Reader
OK
If you want open chrome any other app
Same steps
Last Step
Select
Chrome