Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pdfkit-table

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pdfkit-table - npm Package Compare versions

Comparing version 0.1.32 to 0.1.33

Untitled Diagram.drawio

64

index.js

@@ -319,2 +319,64 @@ "use strict";

module.exports = PDFDocumentWithTables;
module.exports = PDFDocumentWithTables;
function t2j( element ){
let head = [];
let data = [];
const table = element;
const rows = table.rows.length;
let cells = 0;
let text = '';
for( var r = 0; r < rows; r++ ){
cells || (cells = table.rows[0].cells.length);
let simpleRow = [];
for( var c = 0; c < cells; c++ ){
text = table.rows[r].cells[c].textContent;
if( r === 0 ) {
head.push(text);
}else {
simpleRow.push(text);
}
}
simpleRow.length && data.push(simpleRow);
}
return {
headers: head,
datas: [],
rows: data,
};
// console.log(head, data);
// console.log(table.rows);
// console.log(table.rows.length);
// console.log(table.rows[0].cells);
// console.log(table.rows[0].cells[0].textContent);
// console.log(table.rows[0].cells[0].cellIndex);
// console.log(table.rows[0].innerHTML);
}
function tableToJson( idElement ){
return t2j( document.getElementById(idElement) );
}
function allTablesToJson(){
let all = [];
const table = document.getElementsByTagName('table');
const rows = table.length;
for( var r = 0; r < rows; r++ ){
all.push( t2j(table[r]) );
}
return all;
}
module.exports.tableToJson = tableToJson;
module.exports.allTablesToJson = allTablesToJson;

2

package.json
{
"name": "pdfkit-table",
"version": "0.1.32",
"version": "0.1.33",
"description": "PdfKit Table. Helps to draw informations in simple tables using pdfkit. #server-side. Generate pdf tables with javascript (PDFKIT plugin) ",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -293,4 +293,4 @@ # pdfkit-table

{ name: 'size8:Will' },
// normal
{ name: 'San' },
// normal
{ name: 'San' },
]

@@ -350,2 +350,11 @@ ```

### 0.1.33
+ Function **tableToJson**
- import {tableToJson} from 'pdfkit-table';
- const table = tableToJson('#id_table'); <code>{Object}</code>
+ Function **allTablesToJson**
- import {allTablesToJson} from 'pdfkit-table';
- const tables = allTablesToJson(); <code>{Array}</code>
### 0.1.32

@@ -386,1 +395,2 @@

- influence [voilab](https://github.com/voilab/voilab-pdf-table)
- **Marcos Aurelio P. Araujo**, thanks for give me the challenge.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc