-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS 7 (and newer) can't open PDF in new browser window #165
Comments
Does iOS7 accepts blob:xxx URls? If it does, you can get a blob and use createObjectURL & revokeObjectURL to open such a blob uri instead of the data: one. |
If that doesn't work for whatever reason, you could use a: var newWin = window.open(); Then your new window just generates the PDF. |
I found this on Stack Overflow: "Having an anchor tag with target _blankwill work in iOS 7.0.3" http://stackoverflow.com/questions/18879631/how-to-open-safari-from-a-webapp-in-ios-7 So perhaps you use JS to add an Download to the page. On Fri, Feb 7, 2014 at 10:12 AM, Alexander Troy notifications@github.comwrote:
James Hall Parallax +44 113 322 6477 Registered office: The Old Brewery, High Court, Leeds, LS2 7ES |
Does also not work in Web App only in Safari... the only thing that works is target="xxx" not blank than you can open http websites but not "data:application/pdf..." hrefs. |
Good to know, must be some weird bug in Mobile Safari. |
@diegocr can you reopen it, still an issue. I submittend also a Bugreport to Apple, but as long as it not works we should leave it open, that others see that it needs to be fixed / or have another solution. |
I wonder if we could engineer a workaround that inserts an invisible one of those into the DOM then does a click event on it? Is there any way to detect that we're in a "Home screen" app? |
Yes, window.navigator.standalone returns true if it is "web-app-capable" and pinned to home screen. What do you like to insert? I also tried to insert a link and trigger a click event with the same result - only works in safari not in home screen. |
Got a solution!! <!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script>
document.location.href = document.location.hash.substr(1);
</script>
</body>
</html> Create a link <a class="btn btn-default" id="pdfData" ng-show="isMobile && pdfReady" href="app/views/pdf.html" target="xxx">
Download PDF
</a> After you "rendered" your pdf get the var pdfData = doc.output('datauristring');
var element = document.getElementById('pdfData');
element.href = "app/views/pdf.html#" + pdfData;
element.target = "xxx";
$scope.pdfReady = true; // show download link And now if the user clicks the download link a new window is opened in safari and the pdf get shown |
Neat solution, thanks for sharing it! and sorry for my late reply, i was away. |
@atroy thanks for the working solution. |
@BenRoe you're welcome and thanks edited! |
Great workaround! In addition to the IOs-problem, the accepted solution solved two more issues in my case: IE9: You can now download pdf-results in IE9 without using downloadify @atroy : Thanks alot! |
I know it is not really a jsPDF related issue, but I think many jsPDF users facing the same problem and if someone has a solution for that it would be nice to post it here.
http://stackoverflow.com/questions/20978473/ios-7-and-newer-cant-open-pdf-in-new-browser-window
The text was updated successfully, but these errors were encountered: