Comments (3)
Several things here:
<s>
, as shown in the documentation, is not a supported tag; I've just added support to<s>
in the new release;"2nd sentence is on line 2 instead of line 3"
: no, it's not.... if you look at the playground, you'll see it appears on the 3rd line, so my guess is that something is wrong with your code;"Lists aren't displayed at all"
: lists are correctly displayed in the playground, so I think something is wrong with your code.
That says, it wasn't possible to change the default margin left for list item 1.2
because I've just discovered that the default style will be stronger than a style class... In the new release, I've introduced an option parameter to the function in order to overwrite the default styles.
For your specific example, the full code will look like that:
// here there is your HTML code
var html = htmlToPdfMake(`<p>Here I am.</p>
<p><br></p>
<p>I'm another sentence two lines down. <s>Some strike through.</s></p>
<p><br></p>
<ul>
<li>list item 1</li>
<li class="ql-indent-1">list item 1.2</li>
<li>list item 2</li>
</ul>
<p><br></p>
<p><br></p>`, {
defaultStyles:{
li:'' // remove all the default styles for LI (including the margin)
}
});
var docDefinition = {
content: [
html
],
// define some style classes to provide the margins for your LI
styles:{
'html-li':{ // here is the default margin for all LI
marginLeft:5
},
'ql-indent-1':{ // here is the margin to use when we have 'ql-indent-1'
marginLeft: 15
}
}
};
// and finally you can use pdfMake to create the PDF
pdfMake.createPdf(docDefinition);
The above code will return pretty much the below PDFMake code that you can directly copy/paste in the PDFMake Playground:
var dd = {
content: [{
text: 'Here I am.',
style: ['html-p'],
margin: [0, 5, 0, 10]
},
'\n',
{
text: [{
text: 'I\'m another sentence two lines down. ',
style: ['html-p']
},
{
text: 'Some strike through.',
style: ['html-s'],
decoration: 'lineThrough'
}
],
margin: [0, 5, 0, 10],
style: ['html-p']
},
'\n',
{
ul: [{
text: 'list item 1',
style: ['html-li']
},
{
text: 'list item 1.2',
style: ['ql-indent-1', 'html-li']
},
{
text: 'list item 2',
style: ['html-li']
}
],
style: ['html-ul'],
marginBottom: 5
},
'\n',
'\n'
],
styles: {
'html-li':{ // here is the default margin for all LI
marginLeft:5
},
'ql-indent-1':{ // here is the margin to use when we have 'ql-indent-1'
marginLeft: 15
}
}
}
Please, not the new version is 1.1.0
, so a simple npm update
won't update it.
I have updated the documentation too.
from html-to-pdfmake.
Thank you for the thorough response. I'll look into this on my end today
from html-to-pdfmake.
Thank you again. It turns out that it was with our code. We had wrapped our text in another text array, which was fine for text elements but not ul elements. Apparently ul elements can't be part of a text element. I've started work on a solution for that.
from html-to-pdfmake.
Related Issues (20)
- Feature request: support for native Ecma script modules HOT 3
- Cannot load images in the Node.js environment HOT 2
- Support for header / footer HOT 4
- Table cell organization bug HOT 3
- Freeze bug HOT 4
- Adding extra white space in pdf. HOT 8
- Cannot size an image HOT 10
- img breaks line HOT 1
- lineHeight property handling HOT 5
- Feature request: handle and support invalid image HOT 1
- Issue with list items not rendering HOT 3
- Feature Request: HOT 2
- line-height issue HOT 3
- Bug: Table widths parsing issue HOT 2
- Dynamic table widths update HOT 11
- ErrorHandler: TypeError: cellWidth.replace is not a function at index.js:385:105 HOT 5
- Copying and pasting the text "finally" from the PDF and the letter "i" is not included when pasted HOT 1
- Bug: Newlines get inserted after images where they actually shouldn't be HOT 1
- Adding Extra Space in-between HOT 4
- rgba colors parsed incorrectly HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from html-to-pdfmake.