npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@microexcel-csd/nativescript-create-pdf

v1.1.1

Published

A NativeScript plugin to create and write a PDF file to the users device. Android and iOS.

Downloads

23

Readme

Nativescript Create PDF

A plugin to help create and save a PDF file to the users device that includes text and images.

Prerequisites / Requirements

Install the Nativescript-permissions plugin from: https://www.npmjs.com/package/nativescript-permissions

npm i nativescript-permissions

Your PDF will not be written without permission to READ and WRITE to the filesystem.

Installation

tns plugin add @microexcel-csd/nativescript-create-pdf

Usage

Import the plugin into your component

import { CreatePdf } from "@microexcel-csd/nativescript-create-pdf";

Init the plugin

createPdf = new CreatePdf();

Request proper Android permissions:

 ngOnInit(): void {
        permissions.requestPermission([
            "android.permission.READ_EXTERNAL_STORAGE",
            "android.permission.WRITE_EXTERNAL_STORAGE",
        ], "We need these permissions to save pdf")
        .then(function (res) {
        })
        .catch(function () {
        });
    }

Create your PDF file settings:

fileSettings = {
        orientation: 'portrait',
        units: 'mm',
        paperSize: 'Letter',
        fileName: 'pdf-export.pdf', // Name your file with the extension
        folderName: 'App-Exports' // Name the folder being created where your pdf will be saved
    }

Add your text:

text = [
    {
        data: 'Page 1 Sample Text', // this is what appears on the page
        xPos: 10, // x coordinate from top left
        yPos: 20, // y coordinate from top left
        fontSize: 18,
        pageNum: 1 // the page your text will appear on
    },
    {
        data: 'Page 2 Sample Text',
        xPos: 10,
        yPos: 20,
        fontSize: 14,
        pageNum: 2
    }
];

Change font color:

Add fontColor to your text object with your RGB color values in an array. If fontColor is not included the default color is black.

fontColor: [8, 134, 255]

Add your images:

images = [
    {
        path: './app/assets/image.jpg', // where your image is located
        type: 'JPEG', // img type
        xPos: 10, // x coordinate from top left
        yPos: 40, // y coordinate from top left
        width: 30, // width of your image in same unit size as your file settings (mm in this example)
        height: 30, // height of your image in same unit size as your file settings (mm in this example)
        alias: null,
        compression: 'FAST',
        pageNum: 1 // the page your image will appear on
    },
    {
        path: './app/assets/image.jpg',
        type: 'JPEG',
        xPos: 10,
        yPos: 40,
        width: 100,
        height: 125,
        alias: null,
        compression: 'FAST',
        pageNum: 2
    }
];

Pass data and create your pdf:

this.createPdf.create(this.fileSettings, this.text, this.images);
// this will create your pdf and write it to the device

Credits

https://www.npmjs.com/package/jspdf https://rawgit.com/MrRio/jsPDF/master/docs/jsPDF.html

ISC License

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Support Our Packages

paypal