简体   繁体   English

jspdf无法在移动设备中生成pdf(Android / iPhone)

[英]jspdf cannot generate pdf in mobile (android/ iPhone)

can we generate pdf using jspdf in mobile phones and tabs? 我们可以在手机和标签页中使用jspdf生成pdf吗? I have simple android application (no Phonegap no Cordova), and an IOS application, jspdf works in web smoothly , but not able to generate pdf in IOS and Android. 我有一个简单的android应用程序(没有Phonegap的Cordova),还有一个IOS应用程序,jspdf在Web上可以正常运行,但无法在IOS和Android中生成pdf。

doc.output('save', 'Pass.pdf');

works fine for web-browsers. 适用于网络浏览器。 I tried 我试过了

doc.save();

and

 var blob = pdf.output();
 window.open(URL.createObjectURL(blob));

and when I tried : 当我尝试时:

 var res = doc.output(); 
 var blob = new Blob([res]);
 window.open(URL.createObjectURL(blob));

I received somthing like this in the android 我在Android中收到了类似的东西

onLoadResource=data:application/pdf;base64,JVBERi0xLjMKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIKL1Jlc291cmNlcyAyIDAgUgovTWVkaWFCb3ggWzAgMCA1OTUuMjggODQxLjg5XQovQ29udGVudHM......

but no pdf 但没有PDF

so Now I want to know , is it even possible to generate pdf in mobiles using jspdf ?or is it all in vain? 所以现在我想知道,甚至有可能使用jspdf在手机中生成pdf吗?还是徒劳?

If yes , how? 如果是,如何?

IOS: Google told me that : To download PDFs to your iPad, iPhone, or iPod Touch, you'll need to download an application. IOS: Google告诉我 :要将PDF下载到您的iPad,iPhone或iPod Touch,您需要下载一个应用程序。

Hence it wasn't possible to do it from jspdf directly so I quit trying onto that. 因此不可能直接从jspdf做到这一点,所以我放弃尝试了。

Android: I din't find any solution regarding that, I moved to another solution. Android:我没有找到任何关于此的解决方案,我转向了另一个解决方案。

Image instead of PDF (for both iPhone and Android) 图片而非PDF (适用于iPhone和Android)

The Information which you want to show in pdf, base64 that information , and send it to Android Api , which could convert it to png and save it to photo gallery. 您想要以pdf,base64形式显示的信息,然后将其发送到Android Api,后者可以将其转换为png并将其保存到照片库。

I hope this may help somebody in future. 我希望这可以在将来对某人有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM