Active8 months ago
I have an auto generated PDF file by itext and I need to display that PDF file in HTML. My question is: How to display a local PDF file in HTML using pdf.js? Should that PDF file be generated by s. PDF file is called readme.pdf and is located in the PDF folder. Our link is located in the index. Relative path. As to the above conditions link to the PDF file will looks as follows: link text. As you can see in the link href attribute we specified the directory where the pdf file is located and the pdf file name. The path to the. Add the code to the place where you want the link to the PDF file to show up in your HTML code. It's actually the same link code that you would use for a normal web page link. You can make the text for the PDF file link say anything you want it to.
I have a problem with:
href='file://'
Well I want to point a link in html to file, in browser if I write like It works to open a file, but if I point it to:
It doesn't work. link is changed to:
The
Brian Webstercolon
after file disappears. Any suggestions as to what to do?21.4k4343 gold badges132132 silver badges209209 bronze badges
SangsomSangsom32711 gold badge55 silver badges1515 bronze badges
4 Answers
The reason your URL is being rewritten to
file///K:/AmberCRO%20SOP/2011-07-05/SOP-SOP-3.0.pdf
is because you specified http://file://
The
http://
at the beginning is the protocol being used, and your browser is stripping out the second colon (:) because it is invalid.Note
If you link to something like
The above represents a link to a file called
k:/yourfile.pdf
on the k: drive on the machine on which you are viewing the URL. You can do this, for example the below creates a link to
C:temptest.pdf
By specifying file:// you are indicating that this is a local resource. This resource is NOT on the internet.
Most people do not have a K:/ drive.
But, if this is what you are trying to achieve, that's fine, but this is not how a 'typical' link on a web page works, and you shouldn't being doing this unless everyone who is going to access your link has access to the (same?) K:/drive (this might be the case with a shared network drive).
You could try
Html Link Pdf File To Access
Note that
inspiteinspitehttp://file:///K:/AmberCRO%20SOP/2011-07-05/SOP-SOP-3.0.pdf
is a malformed15.6k2121 gold badges6969 silver badges8888 bronze badges
%20
is the space between AmberCRO SOP.Try -
Or rename the folder as AmberCRO-SOP and write it as -
DipakDipak10.4k11 gold badge2525 silver badges2828 bronze badges
Html Link Pdf Files
Share your folder for 'everyone' or some specific group and try this:
Maximiliano BecerraMaximiliano Becerra
Although the ffile:////.exe used to work (for example - some versions of early html 4) it appears html 5 disallows this.Tested using the following:
as well as ..1/ substituted the 'ffile' with just 'file'2/ all the above variations with the http:// prefixed before the ffile or file.
The best I could see was there is a possibility that if one wanted to open (edit) or save the file, it could be accomplished. However, the exec file would not execute otherwise.
Roger BrowneRoger Browne