Questions tagged [pdfmake]

Client/server side PDF printing in pure JavaScript

Client/server side PDF printing in pure JavaScript

In-browser

Print PDFs directly in the browser or delegate it to your NodeJS backend. Use the same document definition in both cases.

Fully declarative

Forget about manual x, y calculations. Declare document structure and let pdfmake do the rest.

Powerful layout engine

Use paragraphs, columns, lists, tables, canvas, etc... Declare your own styles, use custom fonts, build a DSL and extend the framework.

Features

  • line-wrapping,
  • text-alignments (left, right, centered, justified),
  • numbered and bulleted lists,
  • tables and columns
    • auto/fixed/star-sized widths,
    • col-spans and row-spans,
    • headers automatically repeated in case of a page-break,
  • images and vector graphics,
  • convenient styling and style inheritance,
  • page headers and footers:
    • static or dynamic content,
    • access to current page number and page count,
  • background-layer
  • page dimensions and orientations,
  • margins,
  • custom page breaks,
  • font embedding,
  • support for complex, multi-level (nested) structures,
  • helper methods for opening/printing/downloading the generated PDF.

References

560 questions
4
votes
1 answer

How to apply web worker to rendering of a PDF using makepdf

I successfully created a PDF using a JavaScript plug-in (pdfmake) and it was great. But when I try to render an ~8,000-row inventory/ledger printout, it freeze for over a minute. This is how I usually declare my docDefinition var docDefinition = {…
melvnberd
  • 3,093
  • 6
  • 32
  • 69
4
votes
1 answer

AngularJS export SVG to PDF

I'm trying to export a element sitting in DOM to a PDF file, generated on client side. I tried with different libraries, and pdfmake is so close to what I want. Any working example with this library or any other library would be helpful. …
user3613863
  • 41
  • 1
  • 4
3
votes
1 answer

Arabic sentence for words are reversed on datatables pdfhtml5 "pdfmake"

I have changed the default font to a font that supports arabic The words supposed to be shown this way: تقارير حركة الرسائل But they are shown as الرسائل حركة تقارير function processDoc(doc) { //…
3
votes
1 answer

CDK Lambda NodejsFunction pdfmake ENOENT Error

I'm trying to upgrade Lambda js code that uses pdfmake 0.1.64 to CDK Lambda NodejsFunction typescript code that uses pdfmake 0.2.5. I'm getting the error: "ENOENT: no such file or directory, open '/var/task/data.trie'" The error is generated when…
Matthew
  • 2,871
  • 5
  • 34
  • 59
3
votes
1 answer

PdfMake list of items to Repeat (checkbox next to text)

I am using the pdfMake and I Ihave a text next to a image I would like to repeat that part in my docdefintion. I would like to repeate this part of my pdfmake { columns: [ { image: "checked", height: 10, …
J.C
  • 632
  • 1
  • 10
  • 41
3
votes
2 answers

Angular 11 and PdfMake. Error TS2345: Argument of type {...} is not assignable to parameter of type TDocumentDefinitions

I'm trying to define pdf document structure accordingly to offical documentation of pdfMake in Angular 11 application. But receiving an error: error TS2345: Argument of type '{ pageSize: string; pageOrientation: string; content: ({ text: string;…
regman
  • 113
  • 10
3
votes
0 answers

Cannot use downloaded library (pdfmake) offline

I am trying to use pdfmake JS library in an offline webpage. I downloaded the CDN file from https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.66/pdfmake.min.js and saved it offline in ..app/js/pdfmake.js I loaded the library using…
Litwos
  • 1,278
  • 4
  • 19
  • 44
3
votes
2 answers

PDFMake: Can't display chinese fonts

In my PDF download, I need to have the possibility to use both english and chinese as languages for the inserted text, but while english works I cannot make chinese to work. I followed the documentation from here, but no matter what fonts I try to…
Artyomska
  • 1,309
  • 5
  • 26
  • 53
3
votes
1 answer

NodeJS Pdfmake how to add an image

I'm using the api pdfmake in nodeJS to generate pdf files http://pdfmake.org/#/ but i do not not know how to add image to the document and always i get below error error invalid image, images dictionary should contain dataURL entries (or local file…
3
votes
1 answer

How to set the background color and padding of text in pdfmake

I have a string which i want to set as the heading of the pdf. I tried it using the following code. But the background is not coming properly. I want to set the background color to the entire row, but it is coming just under text. Any help would be…
YouBee
  • 1,981
  • 1
  • 15
  • 16
3
votes
8 answers

How to import custom fonts for PDFMake in Angular application?

I just started reading into PDFMake's documentation to build a document in my Angular app, I've come across some questions like this one but never got an answer. I was wondering if someone knows or could provide a readable example of how to import…
IvanS95
  • 5,364
  • 4
  • 24
  • 62
3
votes
1 answer

How to test a module using jest which imports an external library which is a constructor

I'm using a library, "pdfmake" and I want to write test cases using jest. I have a module pdf. Inside module pdf I'm exporting 2 functions. In both the exports, I'm using internal functions of "pdfmake" to generate pdfs. Here is the code snippet:…
Zahra Ali
  • 163
  • 2
  • 7
3
votes
1 answer

pdfmake base64 image callback

I have to work with pdfmake to build a pdf preview within my laravel application. I am a javascript noob and going nuts to generate the dataURI for an image in b. Hope you can help me out. How can I get that generated base64 into my docdefinition? …
Sir HC
  • 57
  • 6
3
votes
1 answer

PDFmake table dynamic data

I am using PDFmake to create pdf file, I want to add dynamic data in the table butt the body display empty. this one works when I print [0] but I have lots of dynamic data getData(installation, request) { const phases = { …
Muhammad Ali
  • 369
  • 7
  • 23
3
votes
0 answers

upload generated pdf without temporarily writing any file

I want to upload pdf file created by pdfmake to remote server. For that I am using following code roughly. const doc = printer.createPdfKitDocument(docDefinition); doc.pipe(fs.createWriteStream(filename)) var form = new FormData(); …
rainyday
  • 353
  • 3
  • 17