Giter Club home page Giter Club logo

Comments (8)

lgregg05 avatar lgregg05 commented on July 25, 2024 6

I had the same problem and got it to work by moving data-pdfmake="{"layout":"noBorders"}" to the table and removed the outer div.

So, instead of

<div data-pdfmake="{&quot;layout&quot;:&quot;noBorders&quot;}">
    <table><tr><td>Hello</td><td>World</td></tr></table>
</div>

try

<table data-pdfmake="{&quot;layout&quot;:&quot;noBorders&quot;}">
    <tr>
        <td>Hello</td>
        <td>World</td>
    </tr>
</table>

from html-to-pdfmake.

Aymkdn avatar Aymkdn commented on July 25, 2024 1

To have no borders on a table, you have to use the layout option noBorders, as described in the PDFMake documentation. It's at the same level than the <table> so you have to apply it to a <div>, using the data-pdfmake properties like the below code:

  <div data-pdfmake="{&quot;layout&quot;:&quot;noBorders&quot;}">
    <table><tr><td>Hello</td><td>World</td></tr></table>
  </div>

Which will be converted to the below:

[
  {
    "table": {
      "body": [
        [
          {
            "text": "Hello",
            "style": [
              "html-td",
              "html-tr"
            ]
          },
          {
            "text": "World",
            "style": [
              "html-td",
              "html-tr"
            ]
          }
        ]
      ]
    },
    "style": [
      "html-table",
      "html-div"
    ],
    "marginBottom": 5,
    "layout": "noBorders"
  }
]

from html-to-pdfmake.

Aymkdn avatar Aymkdn commented on July 25, 2024

Can you provide some code, as well as the result you get and the result you were expected?

I'm currently attending a conference for work and I'm without a computer until Monday so I won't probably be able to provide a solution until then.

from html-to-pdfmake.

pradeepmandalapu avatar pradeepmandalapu commented on July 25, 2024

Thanks for your quick response. I am not able to comment from my office laptop. I am commenting from my phone. I will do from my personal system after some time.
I taken the example.js code and applied border none property to table
And I tried to align the image to right. Both are not worked.

from html-to-pdfmake.

pradeepmandalapu avatar pradeepmandalapu commented on July 25, 2024

Hi ,
I have copied your example.js code and applies some sort of css in multiple ways and also i tried with the approach in the documentation. None of those are worked for me.
My requirement is i need to change the font name and size as well as i don't need table borders. I will have pdf data in key and value pair. Key will be in 1 row. data will be in second row

I also tried https://aymkdn.github.io/html-to-pdfmake/index.html in this link with the table related piece of code from your example.js and applied border:none. It is also not worked
Please find the code below. Also attached a screenshot
2

var pdfMake = require('pdfmake/build/pdfmake');
var pdfFonts = require('pdfmake/build/vfs_fonts');
pdfMake.vfs = pdfFonts.pdfMake.vfs;
var fs = require('fs');
var jsdom = require('jsdom');
var { JSDOM } = jsdom;
var { window } = new JSDOM('');
var htmlToPdfMake = require('html-to-pdfmake');
//var util = require("util");

var html = htmlToPdfMake(`<table border=0>
    <tr>
      <td colspan="3">Table with <b>widths=[100,"*","auto"]</b> and <b>heights=40</b></th>
    </tr>
    <tr>
      <td>column1</td>
      <td>column2</td>
      <td>column3</td>
    </tr>
  </table>
  
  another style
  <table style="border:none">
    <tr>
      <td colspan="3">Table with <b>widths=[100,"*","auto"]</b> and <b>heights=40</b></th>
    </tr>
    <tr>
      <td>column11</td>
      <td>column12</td>
      <td>column13</td>
    </tr>
  </table>
  `,
  { window: window }
);

//console.log(util.inspect(html, {showHidden: false, depth: null}))

var docDefinition = {
  content: [ html ]
};

var pdfDocGenerator = pdfMake.createPdf(docDefinition);
pdfDocGenerator.getBuffer(function(buffer) {
  fs.writeFileSync('examplepdf.pdf', buffer);
  console.log('--> example.pdf');
});

from html-to-pdfmake.

pradeepmandalapu avatar pradeepmandalapu commented on July 25, 2024

This is how I wrote the code, in above comment.
2

from html-to-pdfmake.

Aymkdn avatar Aymkdn commented on July 25, 2024

Thanks for sharing code. I'll check it as soon as I get a computer, probably by Monday.

from html-to-pdfmake.

etoktaev avatar etoktaev commented on July 25, 2024

I can't repeat this example:

<div data-pdfmake="{&quot;layout&quot;:&quot;noBorders&quot;}">
    <table><tr><td>Hello</td><td>World</td></tr></table>
 </div>

In the log I get the following code:

[
  { text: '', style: [] },
  { nodeName: 'DIV', stack: [ [Object] ], layout: 'noBorders' }
]

from html-to-pdfmake.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.