[英]Share a PDF in ionic app
我想从我使用 jsPDF 创建的 ionic 应用程序中共享 pdf。 如何将其与 SocialSharing 插件一起使用?
doc.save("resume.pdf")
这会直接下载 pdf 并将我带到无法执行任何操作的屏幕。
//share(message, subject, file, url)
this.socialSharing.share("Test", null, doc.save("resume.pdf"), null);
这也行不通。 我是离子和角度的新手。
更新:我研究并关注了这篇文章, 该文章讨论了在 ionic 应用程序中使用pdfmake
制作 pdf,但我仍然不知道如何共享相同的内容。
import { File } from '@ionic-native/file';
var blob = doc.output('blob', {type: 'application/pdf'});
let pdfUrl = {pdfUrl: URL.createObjectURL(blob)};
if (this.file.checkFile(this.file.cacheDirectory, "myresume.pdf"))
{
this.file.writeExistingFile(this.file.cacheDirectory, "myresume.pdf",blob)
.then(() => console.log('overwrite done'))
.catch(err => console.log(err +' old copies not removed'));
} else{
this.file.writeFile(this.file.cacheDirectory, "myresume.pdf", blob, true)
.then(_ => console.log('write successful'))
.catch(err => console.log(err+ " write failed"));
}
为了分享,
import { File } from '@ionic-native/file';
import { SocialSharing } from '@ionic-native/social-sharing';
export class ResumeView {
pdfUrl : String;
constructor(public navCtrl: NavController,
public navParams: NavParams,
private socialSharing: SocialSharing,
private file: File
)
{
this.pdfUrl = this.navParams.get('pdfUrl');
}
regularShare(){
this.socialSharing.share("test", null, this.file.cacheDirectory + filename, null)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.