@startinblox/generator
v0.1.0
Published
Pdf generator for startinblox
Downloads
3
Keywords
Readme
SiB Generator
sib-pdf-generator
sib-pdf-generator displays a button. When clicked, it will read the content of the given html element, convert it to pdf and initiate a download of the pdf file in the browser.
Example:
<sib-pdf-generator source="#mytemplate"></sib-pdf-generator>
<template id="mytemplate">Hello!</template>
In this case, the user will be given the option to download a pdf file saying "Hello!"
You can add parameters to sib-pdf-generator
:
| Parameter | Default | Description |
| ------------- |---------------| ------------------------------------------------------|
| source
| | Selector of the template element to generate |
| filename
| 'file'
| Name of the generated file (without the extension) |
| buttonText
| 'Download'
| Text of the download button |
A full example is provided in examples/pdf-generator.html
sib-template-renderer
sib-template-renderer renders a template with a LDP resource which it is given through its data-src attribute and puts the generated content into the html element given by the target attribute.
<div id="mytemplate"></div>
<sib-template-renderer bind-resource target="#mytemplate">
<template>Hello ${resource.name}!</template>
</sib-template-renderer>
In this case, every time the data-src attribute of the sib-template-renderer will be set, the template will say hello to the name of the resource.
The content of the resource in the template is accessible in the resource
object.
That content can then be converted to a pdf file using sib-pdf-generator.
An example is provided in examples/template-renderer.html