Comments (8)
I made the following workaround:
export function printJsSuportMobile(printJsConfig: Configuration) {
const isAndroidDevice = navigator.userAgent.match(/Android/i);
if (isAndroidDevice) {
const byteArray = Uint8Array.from(atob(printJsConfig.printable).split('').map(char => char.charCodeAt(0)));
const blob = new Blob([byteArray], { type: 'application/pdf' });
const blobUrl = URL.createObjectURL(blob);
window.open(blobUrl, '_blank');
} else {
printJS(printJsConfig);
}
}
Edit: Obviouly it is only for Android, but in iOS, printJS was working just fine
from print.js.
@eduardocalixtokorp ok thanks but the IOS Chrome browser is not working for mobile
from print.js.
@bhavinangular28 I see. I tested in the latest Safari version not in chrome, but probably you can alter the code above and test it. It'd be something like:
export function printJsSuportMobile(printJsConfig: Configuration) {
const isAndroidDevice = navigator.userAgent.match(/Android/i);
const isAppleDevice = (/iPad|iPhone|iPod/.test(navigator.platform) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) && !window.MSStream
if (isAndroidDevice || isAppleDevice) {
const byteArray = Uint8Array.from(atob(printJsConfig.printable).split('').map(char => char.charCodeAt(0)));
const blob = new Blob([byteArray], { type: 'application/pdf' });
const blobUrl = URL.createObjectURL(blob);
window.open(blobUrl, '_blank');
} else {
printJS(printJsConfig);
}
}
IDK if isAppleDevice works, just got it from a random stackoverflow.
from print.js.
@eduardocalixtokorp I want to change the name, I can do it and how will it be done
from print.js.
@bhavinangular28, probably something like this. I didn't worry about it at the time, but iframe seems to be a reasonable solution
from print.js.
@eduardocalixtokorp does not proper show the title
from print.js.
@eduardocalixtokorp any suggestion please help
from print.js.
@bhavinangular28 Maybe this
from print.js.
Related Issues (20)
- Printing a txt file?
- Printing HTML always overflow to next page HOT 1
- InstallTrigger to detect Firefox is deprecated
- Unable to print blob pdf under Safari (and probably other browser)
- Abandoned - please transfer ownership HOT 1
- Can't print with style HOT 1
- Printing PDF is not working when dev toolbar is opened
- Issue printing PDF using Firefox HOT 11
- Printing HTML and setting documentTitle,documentTitle is not worked.
- How do I monitor the print button
- 2024了现在不知道支持不预览直接下载的吗
- change pageSize of base 64 PDF
- Event listener when printing in silent mode.
- customize css
- 打印时如何设置自定义布局
- Why the printer cannot automatically select paper based on PDF page size
- 分页的tbody把thead覆盖了
- Reference Error
- Set print destination
- add attribute 'sandbox'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from print.js.