I have created the PDF file programmatically. For this, I have used the HTML to PDF converting library. In my PDF there are some links for some pages of website.
I have implemented the html by following way and then converted it to PDF programmatically.
<a target="_blank" href="http://mywebsite_url_here.html">Link</a>
But when opening this PDF into chrome or firefox browser and clicking on the any link exist in PDF. Links are opening is same TAB instead of the new TAB. Please help to find out the solution for this. so that my PDF reside in one tab and link will open in another tab in browser.
I have already tried
target="_blank"
target="_top"
<a onclick="window.open ('http://mywebsite_url_here.html', '');
return false" href="javascript:void(0);"></a>
But nothing has worked for me.
Short answer: It is not possible in a cross-plattform, guaranteed-to-work way.
Long answer: Hyperlinks in a PDF are different from Hyperlinks in HTML. PDF was not designed to be viewed as part of a browsing experience. Hence there is no option available for PDF Hyperlinks to open them in a new tab, because PDF does not know about the concept of tabs.
There is some discussion in Adobe's forums about it, which boils down to „not directly possible, but you could embed JavaScript in the PDF to do it“. They give an EPS file as example:
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 0 0 100 100
%%EndProlog
[ /Rect [ 0 0 100 100 ]
/Action << /Subtype /JavaScript /JS (app.launchURL\("PLACE-YOUR-URL-HERE", true\);) >>
/Subtype /Link
/ANN pdfmark
%%EOF
Now before you try and get this EPS file embedded in your PDF, be aware that Chrome's PDF viewer has very little support for embedded JavaScript, so it is not guaranteed to work. It may also issue a warning to the User that there is JavaScript code going to be executed if they click on it. I would say it isn't worth the hassle.
Related
I'm trying to the get a hyperlink to produce a download of a .pdf file when clicked, but instead the pdf is opened directly in the browser.
I've tried moving the pdf from the root folder (that shared with the index) to a subfolder to no avail. I've found other examples of this problem on this site where they seemed to have mis-entered the attribute, but I can't see where I made my mistake if I did.
Download factfile (pdf, 4mb) which contains lots more information, including an FAQ.</p>
It is because Google Chrome is automatically set to open pdf automatically rather than download.
To fix this issue go to 3 dots Options > Privacy & Security > Site Settings > Additional Content Settings > PDF Documents. There you will find "Download PDF files instead of automatically opening them in Chrome". Click on the button ( I don't know what it is in english sorry ) and you will fix the issue.
i am looking for a creative solution for a new task.
my issue is we need a way to preview local files (extentions: doc, docx, ppt, pptx, pdf, tif, jpeg) in a frame or so of a different web page which provides a link.
preview should look like an image of the files or so.
we would like to prevent parsing the files to pdf in order to save time...
we are using angular 7, c# asp.net server side.
we are very limitted in most solutions, as the data is very secure and is used in an inner office net,
that is why we can't use the google docs solution.
i also understood that using iframe tag and pointing it src attribute to the file source doesn't load the page due to security resones.
in addition all users has the ability to preview the above files types when they do it straight from the document by the open with -> IE or other browsers options.
i tried :
<iframe src="file:///C:/Users/cd/Downloads/MyFile.docx"></iframe>
but:
the iframe tag doesn't open the doc file, i can see the iframe in the DOM as a new html but it doesnt have a content of anything
i tried also for images and the same, the frame is blank
If you are using chrome then chrome specifically blocks local file access this way for security reasons.
more detail is this link : here
One possible solution is, render the document pages as images and then display them on the web page i.e. using the iframe.
You may use GroupDocs.Viewer for .NET for rendering the document pages into high-fidelity images (PNG/JPG). You can then embed the images into your web page to preview the document. This is how you can get the image representation of the pages in a Word document:
using GroupDocs.Viewer.Options;
// Set output path
string OutputPagePathFormat = Path.Combine("D:\\output", "page_{0}.png");
// Render document pages
using (Viewer viewer = new Viewer("D:\\sample.docx"))
{
PngViewOptions options = new PngViewOptions(OutputPagePathFormat);
viewer.View(options);
// Rendered images will be saved in the D:\output\ directory.
}
Disclosure: I work as a developer evangelist at GroupDocs.
We would like to display excel file which consist of graphs onto our HTML5 web page.
I tried couple of approach but haven't got exact solution-
If I used iframe then source excel file opens as an attachment and dialog box appears. which I dont want.
If I convert excel file into mht and then open using iframe. This only works with IE and not mozilla or chrome.
Can anyone please suggest how to view entire excel workbook on my HTML5 page?
Note: I do not want to use google docs in my case.
Check out this link: http://www.labnol.org/software/embed-tables-spreadsheet-data-in-websites/7435/
It has multiples ways of embedding spreadsheets into html pages
For my Trac plugin, I have made an export script which converts contents to a different format. The result is an HTML code.
When I click the link, some browsers open the HTML code in a new tab, while others offer to download it as a .print file, depending on their specific settings I think. Opening this .print file shows the same HTML page as opening it directly, but locally instead of from the server.
How can I force it to always open in a new tab?
I think it might be a mimetype issue. If it is, which mimetype can I use to tell the browser to open the HTML code directly? I am currently using text/html as mimetype.
EDIT: some more info
To give some more insight, adapting from a comment of mine below:
I do not create the link myself. The link is provided by Trac, the bug tracking software the plugin is for, and what I do is implement the method that creates the HTML code and let it return the HTML code along with the mimetype. Trac then returns the HTML code either as a file, or as a new tab, when clicking on that content conversion link. What I am searching for is a possibility to specify in the HTML code or mimetype that it gets opened in a new tab directly.
Maybe there is some kind of mimetype specifying the (HTML) text as an HTML web document instead of HTML file (if that distinction even exists).
Or an HTML/XML header or doctype specifying whether it gets downloaded or opened by a browser. I think the browser need to get that information from somewhere.
Or maybe there is an option to set in Trac.
I hope these ideas of mine about what could exist can help those of you who are versed with either or some of these to find a solution. I could not find a solution through my research yet.
If you have a link that "directly" opens (not in a new tab) and you want it to open a new tab, one way of doing it is
This will create a blank page, then paste the link there automagically and thus you will have a new tab with the desired page.
When I try to save a web page using the format "Web Page, Complete," half of the time it only saves the the folder containing the style sheet and images, and the .html file is not saved anywhere on my hard drive. How do I correct this? I have noticed it also happens when I use Safari, so it is not just an isolated issue with Google Chrome.
First save the whole page (webpage,complete) which may only save the folder containing the style sheets and images, again press CTRL+S to save the page but this time select to save only the HTML page by clicking on- (webpage,HTML only).
When directory is saved but not the file, try the following:
In "File name:" include the .html extension (example:
SampleFileName.html), and
Select Webpage, Complete in "Save as Type:"
Seems to fix the bug.