Creating a PDF?


#1

Hello… I’m trying to create a pdf report summary in my app… I found this: http://pdfkit.org/

but my app then returns error: Failed to find module: "stream",

This is my code snippet from the pdf creation:

var pdf = require("pdfkit");

var pdfpath = filesystem.path.join(documents.path, "output.pdf");
var file = filesystem.File.fromPath(pdfpath);

doc.pipe(file);

doc.fontSize(25)
   .text('test!!!', 100, 100);
doc.end();

I think it has something to do with the file-system? or no? please help… thank you… :slight_smile:


Generate reports in nativescript app
#2

The pdfkit package likely won’t work in the context of NativeScript.

But thanks for the idea, that can totally be made into a plugin, a simple one however.

Looking through search results Google reveals that PDF previewing/writing is a very problematic topic in Android. iText has an Android plugin, but besides being paid, it has not been wrapped as a NativeScript plugin.


#3

Thanks… any idea of maybe a replacement? I need a way to produce a “hardcoded” report for my app… :slight_smile:


#4

This pod for iOS looks promising:

This for Android perhaps:

I’m planning on doing a course on egghead for integrating libs like that directly into NativeScript projects as well as creating public plugins. Maybe I could focus on this one?


#5

you can focus on this one… for me… but for the public? I’m not sure if this is a priority… :grin:


#6

Hey @mansonmamaril,

I am also having same requirement means need to generate pdf report and certificate based on processed user given data in my nativescript with angular app.

How you managed? Did you find any working solution on this?


#7

Hey @Pete.K,

After long months of this post, Shall i get any working solution on this?

Any further idea on this to generate the pdf through nativescript with angular app?


#8

Check this POC with jsPDF :smiley: https://play.nativescript.org/?template=play-ng&id=OGrw9s&v=8