-
-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"HR" misbehave on re-render... #57
Comments
I'm not at home this weekend so I cannot test, but it's probably something in your code that is causing this issue.... I'll do a test on Monday |
Could be, mind you all other elements work fine it's just the 'hr' and I've not applied any styling to it just to be sure that it's not me, so it's all doing this with default setup. |
I tried to reproduce your issue but I cannot. Can you check the content of |
Can you check the code coming from |
Actually, show |
OK, we have different results between the first and second open. Here's the first: JSON.stringify(html): [{"nodeName":"DIV","stack":[{"text":"My title","nodeName":"H1","fontSize":24,"bold":true,"marginBottom":5,"style":["html-h1","html-div"]},{"text":"This is some example content...","nodeName":"P","margin":[0,5,0,10],"style":["html-p","html-div"]},{"nodeName":"HR","margin":[0,12,0,12],"canvas":[{"type":"line","x1":0,"y1":0,"x2":514,"y2":0,"lineWidth":0.5,"lineColor":"#000000"}]}]}] breadcrumbs.ts:103 here's the 2nd: JSON.stringify(html): [{"nodeName":"DIV","stack":[{"text":"My title","nodeName":"H1","fontSize":24,"bold":true,"marginBottom":5,"style":["html-h1","html-div"],"_margin":[0,0,0,5],"_inlines":[],"_minWidth":41.09765625,"_maxWidth":79.76953125,"positions":[{"pageNumber":1,"pageOrientation":"portrait","pageInnerHeight":761.89,"pageInnerWidth":515.28,"left":40,"top":40,"verticalRatio":0,"horizontalRatio":0}]},{"text":"This is some example content...","nodeName":"P","margin":[0,5,0,10],"style":["html-p","html-div"],"_margin":[0,5,0,10],"_inlines":[],"_minWidth":50.0390625,"_maxWidth":169.1484375,"positions":[{"pageNumber":1,"pageOrientation":"portrait","pageInnerHeight":761.89,"pageInnerWidth":515.28,"left":40,"top":78.125,"verticalRatio":0.0500400320256205,"horizontalRatio":0}]},{"nodeName":"HR","margin":[0,12,0,12],"canvas":[{"type":"line","x1":40,"y1":114.1875,"x2":554,"y2":114.1875,"lineWidth":0.5,"lineColor":"#000000"}],"_margin":[0,12,0,12],"_maxWidth":514,"_minWidth":514,"_maxHeight":0,"_minHeight":0,"positions":[{"pageNumber":1,"pageOrientation":"portrait","pageInnerHeight":761.89,"pageInnerWidth":515.28,"left":40,"top":114.1875,"verticalRatio":0.09737298035149432,"horizontalRatio":0}]}],"_margin":null,"_minWidth":514,"_maxWidth":514,"positions":[{"pageNumber":1,"pageOrientation":"portrait","pageInnerHeight":761.89,"pageInnerWidth":515.28,"left":40,"top":40,"verticalRatio":0,"horizontalRatio":0},{"pageNumber":1,"pageOrientation":"portrait","pageInnerHeight":761.89,"pageInnerWidth":515.28,"left":40,"top":78.125,"verticalRatio":0.0500400320256205,"horizontalRatio":0},{"pageNumber":1,"pageOrientation":"portrait","pageInnerHeight":761.89,"pageInnerWidth":515.28,"left":40,"top":114.1875,"verticalRatio":0.09737298035149432,"horizontalRatio":0}]}] breadcrumbs.ts:103 and the 3rd: JSON.stringify(html): [{"nodeName":"DIV","stack":[{"text":"My title","nodeName":"H1","fontSize":24,"bold":true,"marginBottom":5,"style":["html-h1","html-div"],"_margin":[0,0,0,5],"_inlines":[],"_minWidth":41.09765625,"_maxWidth":79.76953125,"positions":[{"pageNumber":1,"pageOrientation":"portrait","pageInnerHeight":761.89,"pageInnerWidth":515.28,"left":40,"top":40,"verticalRatio":0,"horizontalRatio":0}]},{"text":"This is some example content...","nodeName":"P","margin":[0,5,0,10],"style":["html-p","html-div"],"_margin":[0,5,0,10],"_inlines":[],"_minWidth":50.0390625,"_maxWidth":169.1484375,"positions":[{"pageNumber":1,"pageOrientation":"portrait","pageInnerHeight":761.89,"pageInnerWidth":515.28,"left":40,"top":78.125,"verticalRatio":0.0500400320256205,"horizontalRatio":0}]},{"nodeName":"HR","margin":[0,12,0,12],"canvas":[{"type":"line","x1":80,"y1":228.375,"x2":594,"y2":228.375,"lineWidth":0.5,"lineColor":"#000000"}],"_margin":[0,12,0,12],"_maxWidth":554,"_minWidth":554,"_maxHeight":114.1875,"_minHeight":114.1875,"positions":[{"pageNumber":1,"pageOrientation":"portrait","pageInnerHeight":761.89,"pageInnerWidth":515.28,"left":40,"top":114.1875,"verticalRatio":0.09737298035149432,"horizontalRatio":0}]}],"_margin":null,"_minWidth":554,"_maxWidth":554,"positions":[{"pageNumber":1,"pageOrientation":"portrait","pageInnerHeight":761.89,"pageInnerWidth":515.28,"left":40,"top":40,"verticalRatio":0,"horizontalRatio":0},{"pageNumber":1,"pageOrientation":"portrait","pageInnerHeight":761.89,"pageInnerWidth":515.28,"left":40,"top":78.125,"verticalRatio":0.0500400320256205,"horizontalRatio":0},{"pageNumber":1,"pageOrientation":"portrait","pageInnerHeight":761.89,"pageInnerWidth":515.28,"left":40,"top":114.1875,"verticalRatio":0.09737298035149432,"horizontalRatio":0}]}] breadcrumbs.ts:103 |
It looks like your |
I'm testing the code I sent you above, but I'm running it within a larger react project, it's not isolated with just 1 file, so it's possible that something else interferes which is strange. It is also strange that only the HR is affected out of all the elements. I have found a workaround for now simply adding a separator line with underscores. I don't like doing this but it works. Have you tried adding separator line with another element applying border for example with your script? |
I don't see anything in the code related to Each call of: const html = htmlToPdfmake(`
<div>
<h1>My title</h1>
<p>
This is some example content...
</p>
<hr />
</div>`); Should return the same code, all the time, because you pass a static HTML code to
I only created this lib for a very small project, but now I don't use it anymore: I just maintain it for the community, adding new stuff when people ask for it. |
OK, sounds good, no worries, and thanks for your swift replies. Cheers! |
I'm using your awesome script with React.js.
The issue I encountered is with the
<hr />
element.Background:
I've setup a button that will generate a PDF from some content, the issue is that if you click the button multiple times, basically to generate the same report multiple times the
<hr />
keeps adding all this spacing above and to the right of it and with each newly generated instance the gaps are getting bigger.Here's some code snippet to try to reproduce this:
Here's some screenshots to demonstrate the issue.
First open:
Second open:
Third open:
and so on...
Thanks
The text was updated successfully, but these errors were encountered: