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

@journeyapps-solutions/cc-pdf-sass

v2.0.4

Published

Sass Framework for PDF styling

Downloads

3,938

Readme

cc-pdf-sass

This is the styling framework for PDF's and DocX. This enables RocketPDF to style a pdf/docx and Cloud Code to compile the style.

The sass files are included in the lib and enable use in CC.

Documentation

View the docs @ https://journeyapps-solutions.github.io/cc-pdf-sass/

Installation

Per machine

yarn add @journeyapps-solutions/cc-pdf-sass --save

Note, if you are having issues related to the package not being found after install. Double check that the yarn bin or npm bin is added to your path environmental variables

  • run yarn global bin to get the yarn path to use.
  • run npm bin to get the npm bin path.

Deploying

When a version is deployed, the documentation style is also updated.

yarn version

API

Both PDF and DocX use the same API to generate the required styles.

/**
 * Compiles the SASS to a string for use in CC handlebars
 * @param  {string|array} input Path to the directory/directories containing the variable.scss and custom.scss
 * @return {string} Compile CSS
 */
compileSass: async function (path) {...}

/**
 * Copy over the variable.scss and custom.scss files to the process path.
 * @param  {string} destination Destination folder path
 */
initSassFiles: async function (destination) {...}

Usage

index.js:

PDF Example:

// make sure config.js has the relevant credentials
const config = require('./config');
const PDFSass  = require('@journeyapps-solutions/cc-pdf-sass');

export async function run() {

  //The directory where variable.scss and custom.scss exists
  let _css = await PDFSass.PdfSassCompiler.compileSass(__dirname); 

  let data = {}
  data.generated_at = new Date();
  data.css =  _css;

  // Generate HTML using handlebars
  const pdfHtml = _pdfTemplate(data);

  //Do something with the pdfHtml

}

DocX Example

// make sure config.js has the relevant credentials
const config = require('./config');
const PDFSass  = require('@journeyapps-solutions/cc-pdf-sass');

export async function run() {

  //The directory where variable.scss and custom.scss exists
  let _css = await PDFSass.DocxSassCompiler.compileSass(__dirname); 

  let data = {}
  data.generated_at = new Date();
  data.css =  _css;

  // Generate HTML using handlebars
  const pdfHtml = _pdfTemplate(data);

  //Do something with the pdfHtml

}
// make sure config.js has the relevant credentials
const config = require('./config');
const PDFSass  = require('@journeyapps-solutions/cc-pdf-sass');

export async function run() {

  //The directories where variable.scss and custom.scss exists
  let _css = await PDFSass.PdfSassCompiler.compileSass([__dirname, `${process.cwd()}/../shared`]); 

  let data = {}
  data.generated_at = new Date();
  data.css =  _css;

  // Generate HTML using handlebars
  const pdfHtml = _pdfTemplate(data);

  //Do something with the pdfHtml

}

Printing Layout in OfflinePDF

Since we are using the native print function of the browser when printing offline, we need to add some css to correctly configure for this: Docs: https://developer.mozilla.org/en-US/docs/Web/CSS/@page

Portrait:

@page {
    size: 210mm 297mm;
    /* Chrome sets own margins, we change these printer settings */
    margin: 1mm 0mm 0mm 0mm;
    size: A4 portrait;
}

Landscape:

@page {
    size: 210mm 297mm;
    /* Chrome sets own margins, we change these printer settings */
    margin: 1mm 0mm 0mm 0mm;
    size: A4 landscape;
}

Development

Commands:

  • yarn docs - Compile the documentation Sass
  • yarn serve - Serve the documentation via browser_sync
  • yarn test - Run the Testing Suite

Changelog

2020/02/02

  • Added support for docx document generation
  • Version break due to new syntax use, not backwards compatible

2018/09/03

  • container now sets paddings based on the page tag
  • Added formating variables for <p> (paragraph) tag
  • Added Colors variables to the headings