From 00fcbf31308111ccb3ec36810780f98607391c28 Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Mon, 5 Oct 2020 18:21:53 +0200 Subject: [PATCH 1/3] fix(types): remove addHTML --- examples/js/html2canvas.js | 6 ------ modules.conf.js | 8 -------- types/index.d.ts | 11 ----------- types/jspdf-tests-node.ts | 10 ---------- types/jspdf-tests.ts | 10 ---------- 5 files changed, 45 deletions(-) delete mode 100644 examples/js/html2canvas.js diff --git a/examples/js/html2canvas.js b/examples/js/html2canvas.js deleted file mode 100644 index 27a92a21f..000000000 --- a/examples/js/html2canvas.js +++ /dev/null @@ -1,6 +0,0 @@ -var pdf = new jsPDF("l", "pt", "a4"); - -pdf.addHTML(document.body, function() { - var string = pdf.output("datauristring"); - $(".preview-pane").attr("src", string); -}); diff --git a/modules.conf.js b/modules.conf.js index 61c329fc4..879b025ad 100644 --- a/modules.conf.js +++ b/modules.conf.js @@ -393,14 +393,6 @@ var configuration = { ] }, - 'addhtml': { - name: 'AddHTML Plugin', - folder: 'deprecated', - description: 'Deprecated', - deps: [ - 'jspdf' - ] - }, 'html2pdf': { name: 'html2pdf Plugin', folder: 'deprecated', diff --git a/types/index.d.ts b/types/index.d.ts index 93d62218e..4b51217a8 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -810,7 +810,6 @@ declare module "jspdf" { * jsPDF plugins below: * * - AcroForm - * - AddHTML * - AddImage * - Annotations * - AutoPrint @@ -829,16 +828,6 @@ declare module "jspdf" { * - xmp_metadata */ - // jsPDF plugin: addHTML - addHTML( - element: any, - x: number, - y: number, - options: any, - callback: Function - ): jsPDF; - addHTML(element: any, callback: Function): jsPDF; - // jsPDF plugin: addImage addImage( imageData: string | HTMLImageElement | HTMLCanvasElement | Uint8Array, diff --git a/types/jspdf-tests-node.ts b/types/jspdf-tests-node.ts index 5ddc7aab4..f9410ee86 100644 --- a/types/jspdf-tests-node.ts +++ b/types/jspdf-tests-node.ts @@ -241,16 +241,6 @@ function test_images() { getImageFromUrl("thinking-monkey.jpg", createPDF); } -function test_add_html() { - const pdf = new jsPDF("p", "pt", "a4"); - pdf.addHTML(document.body, function() { - const string = pdf.output("datauristring"); - document - .getElementsByClassName("preview-pane")[0] - .setAttribute("src", string); - }); -} - function test_context2d_smiley() { const doc = new jsPDF("p", "pt", "a4"); const ctx = doc.context2d; diff --git a/types/jspdf-tests.ts b/types/jspdf-tests.ts index aa5a40259..f74bea3eb 100644 --- a/types/jspdf-tests.ts +++ b/types/jspdf-tests.ts @@ -240,16 +240,6 @@ function test_images() { getImageFromUrl("thinking-monkey.jpg", createPDF); } -function test_add_html() { - const pdf = new jsPDF("p", "pt", "a4"); - pdf.addHTML(document.body, function() { - const string = pdf.output("datauristring"); - document - .getElementsByClassName("preview-pane")[0] - .setAttribute("src", string); - }); -} - function test_context2d_smiley() { const doc = new jsPDF("p", "pt", "a4"); const ctx = doc.context2d; From 533b8f09de42899dfe7a3d503a1451019bd7de49 Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Mon, 5 Oct 2020 18:24:19 +0200 Subject: [PATCH 2/3] fix(types): remove fromHTML --- examples/basic.html | 177 --------------------------------------- examples/js/basic.js | 46 ---------- examples/js/from-html.js | 18 ---- modules.conf.js | 9 -- types/index.d.ts | 11 --- 5 files changed, 261 deletions(-) delete mode 100644 examples/js/from-html.js diff --git a/examples/basic.html b/examples/basic.html index 03e19169d..6094da403 100644 --- a/examples/basic.html +++ b/examples/basic.html @@ -229,183 +229,6 @@

Font-metrics-based line sizing and split

Run Code

-

fromHTML plugin

-
-
-

This (BETA level. API is subject to change!) plugin allows one to scrape formatted text from an HTML - fragment into PDF. Font size, styles are copied. The long-running text is split to stated content width. -

-
-
-

Header Two

- Double style span - Monotype span with - carriage return. a humongous font size span. - Followed by long parent-less text node. asdf qwer asdf zxcv qsasfd qwer qwasfd zcxv sdf qwer qwe sdf wer - qwer asdf zxv. -
Serif Inner DIV (bad markup, but testing block detection)
Sans-serif span with extra spaces - Followed by text node without any wrapping element. And some long long text span attached at the end - to test line wrap. qwer asdf qwer lkjh asdf zxvc safd qwer - wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww - qewr asdf zxcv. -

This is a new paragraph.

- This is more wrapping-less text. -

This paragraph will NOT be - on resulting PDF because a special attached element handler will be looking for the ID - 'bypassme' - and - should bypass rendering it.

-

This is another - paragraph.

-

I want to hide this particular word

-

- Integer dignissim urna tortor? Cum rhoncus, a lacus ultricies tincidunt, tristique lundium enim urna, - magna? Sed, enim penatibus? Lacus pellentesque integer et pulvinar tortor? Dapibus in arcu arcu, vut - dolor? Et! Placerat pulvinar cursus, urna ultrices arcu nunc, a ultrices dictumst elementum? Magnis - rhoncus pellentesque, egestas enim purus, augue et nascetur sociis enim rhoncus. Adipiscing augue placerat - tincidunt pulvinar ridiculus. Porta in sociis arcu et placerat augue sit enim nec hac massa, turpis - ridiculus nunc phasellus pulvinar proin sit pulvinar, ultrices aliquet placerat amet? Lorem nunc porttitor - etiam risus tempor placerat amet non hac, nunc sed odio augue? Turpis, magnis. Lorem pid, a porttitor - tincidunt adipiscing sagittis pellentesque, mattis amet, duis proin, penatibus lectus lorem eros, nisi, - tempor phasellus, elit. -

-

Image Support

-

- NOTES: the img src must be on the same domain or the external domain should allow Cross-origin. -

- - -

New page added with html comment: ADD_PAGE

-

-

HTML Table:

-

- NOTES: Must set the COLGROUP tag with "with" on each COL tag as %, inspect the table. BTW the css does not - have a good style to render the table on the html :P, feel free to the add the CSS. -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Heading1 - - Heading2 -
- cell 1,1 - - cell 1,2 -
- cell 2,1 - - cell 2,2 -
- cell 3,1 - - cell 3,2 -
- cell 4,1 - - cell 4,2 -
-

-

-

HTML Lists:

-
-
    -
  • Lorem Ipsum
  • -
  • Dolor Sit amen
  • -
  • Lorem Ipsum
  • -
  • Dolor Sit amen
  • -
-
    -
  1. Lorem Ipsum
  2. -
  3. Dolor Sit amen
  4. -
  5. Lorem Ipsum
  6. -
  7. Dolor Sit amen
  8. -
-
-
-
-

-

var pdf = new jsPDF('p', 'pt', 'letter')
-
-// source can be HTML-formatted string, or a reference
-// to an actual DOM element from which the text will be scraped.
-, source = $('#fromHTMLtestdiv')[0]
-
-// we support special element handlers. Register them with jQuery-style
-// ID selector for either ID or node name. ("#iAmID", "div", "span" etc.)
-// There is no support for any other type of selectors
-// (class, of compound) at this time.
-, specialElementHandlers = {
-    // element with id of "bypass" - jQuery style selector
-    '#bypassme': function(element, renderer){
-        // true = "handled elsewhere, bypass text extraction"
-        return true
-    },
-    '.hide': function(element, renderer){
-        // true = "handled elsewhere, bypass text extraction"
-        return true
-    }
-}
-
-margins = {
-    top: 80,
-    bottom: 60,
-    left: 40,
-    width: 522
-  };
-  // all coords and widths are in jsPDF instance's declared units
-  // 'inches' in this case
-pdf.fromHTML(
-    source // HTML string or DOM elem ref.
-    , margins.left // x coord
-    , margins.top // y coord
-    , {
-        'width': margins.width // max width of content on PDF
-        , 'elementHandlers': specialElementHandlers
-    },
-    function (dispose) {
-      // dispose: object with X, Y of the last line add to the PDF
-      //          this allow the insertion of new lines after html
-        pdf.save('Test.pdf');
-      },
-    margins
-  )
-
-
-

-
-
- -

Text alignment

diff --git a/examples/js/basic.js b/examples/js/basic.js index 7b8d415d4..fac12cfbc 100644 --- a/examples/js/basic.js +++ b/examples/js/basic.js @@ -318,52 +318,6 @@ function demoStringSplitting() { pdf.save("Test.pdf"); } -function demoFromHTML() { - var pdf = new jsPDF("p", "pt", "letter"), - // source can be HTML-formatted string, or a reference - // to an actual DOM element from which the text will be scraped. - source = document.getElementById("fromHTMLtestdiv"), - // we support special element handlers. Register them with jQuery-style - // ID selector for either ID or node name. ("#iAmID", "div", "span" etc.) - // There is no support for any other type of selectors - // (class, of compound) at this time. - specialElementHandlers = { - // element with id of "bypass" - jQuery style selector - "#bypassme": function(element, renderer) { - // true = "handled elsewhere, bypass text extraction" - return true; - }, - ".hide": function(element, renderer) { - // true = "handled elsewhere, bypass text extraction" - return true; - } - }; - - var margins = { - top: 80, - bottom: 60, - left: 40, - width: 522 - }; - // all coords and widths are in jsPDF instance's declared units - // 'inches' in this case - pdf.fromHTML( - source, // HTML string or DOM elem ref. - margins.left, // x coord - margins.top, // y coord - { - width: margins.width, // max width of content on PDF - elementHandlers: specialElementHandlers - }, - function(dispose) { - // dispose: object with X, Y of the last line add to the PDF - // this allow the insertion of new lines after html - pdf.save("Test.pdf"); - }, - margins - ); -} - function demoTextAlign() { var pdf = new jsPDF("p", "pt", "letter"); diff --git a/examples/js/from-html.js b/examples/js/from-html.js deleted file mode 100644 index 156b8a02a..000000000 --- a/examples/js/from-html.js +++ /dev/null @@ -1,18 +0,0 @@ -var doc = new jsPDF(); - -// We'll make our own renderer to skip this editor -var specialElementHandlers = { - "#editor": function(element, renderer) { - return true; - }, - ".controls": function(element, renderer) { - return true; - } -}; - -// All units are in the set measurement for the document -// This can be changed to "pt" (points), "mm" (Default), "cm", "in" -doc.fromHTML($("body").get(0), 15, 15, { - width: 170, - elementHandlers: specialElementHandlers -}); diff --git a/modules.conf.js b/modules.conf.js index 879b025ad..326a45312 100644 --- a/modules.conf.js +++ b/modules.conf.js @@ -383,15 +383,6 @@ var configuration = { description: '', deps: [] }, - 'from_html': { - name: 'FromHTML Plugin', - folder: 'deprecated', - description: 'Deprecated', - deps: [ - 'jspdf', - 'cell' - ] - }, 'html2pdf': { name: 'html2pdf Plugin', diff --git a/types/index.d.ts b/types/index.d.ts index 4b51217a8..eff4a6d99 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -817,7 +817,6 @@ declare module "jspdf" { * - Cell * - Context2D * - fileloading - * - FromHTML * - html * - JavaScript * - split_text_to_size @@ -947,16 +946,6 @@ declare module "jspdf" { // jsPDF plugin: html html(src: string | HTMLElement, options?: HTMLOptions): Promise; - // jsPDF plugin: fromHTML - fromHTML( - HTML: string | HTMLElement, - x: number, - y: number, - settings?: any, - callback?: Function, - margins?: any - ): jsPDF; - // jsPDF plugin: JavaScript addJS(javascript: string): jsPDF; From 1abf1b08aa38b0aa40a379d09e877c732c8ada25 Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Mon, 5 Oct 2020 18:27:30 +0200 Subject: [PATCH 3/3] fix(types): remove html2pdf --- modules.conf.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/modules.conf.js b/modules.conf.js index 326a45312..57ea8031c 100644 --- a/modules.conf.js +++ b/modules.conf.js @@ -382,15 +382,6 @@ var configuration = { folder: 'libs', description: '', deps: [] - }, - - 'html2pdf': { - name: 'html2pdf Plugin', - folder: 'deprecated', - description: 'Deprecated', - deps: [ - 'jspdf' - ] } }