html2pdf.js icon indicating copy to clipboard operation
html2pdf.js copied to clipboard

PDF format broken with elements having position absolute

Open SufyanRamzan opened this issue 5 years ago • 11 comments

Hi there,

I am working form builder. It provides the facility of adding different HTML components anywhere in the given canvas. These HTML elements can be of any height/width and the user can decide it according to his need. In order to achieve this, I am using a library named "react-grid-layout". It perfectly serves my purpose. However, there is one important thing which this library does is that except the parent HTML element (which is at position relative) all children elements are at position absolute.

I am using "html2pdf" library to print the form made the library explained above. I am also using the "avoid-all" param of "html2pdf" library in order to break sections from the end of one page and move them to the next page. This param works as expected however due to the fact that children elements are at position absolute the sections get overlapped together at the start of the new page.

Any idea how can I fix this issue? PS: I am attaching a screenshot of the issue as well. In the screenshot please note the section "Valuation of Coverage" section was moved to the next page but it gets overlapped with the next section.

Screenshot 2020-01-13 at 7 18 46 PM

SufyanRamzan avatar Jan 13 '20 14:01 SufyanRamzan

I ran into the same problem since a few days. I even tried margin-top and margin-left to offset the div elements but no effect.

Before it worked just fine. Maybe this has to do with a Chrome update or PDF-plugin update?

rdewit86 avatar Jan 21 '20 09:01 rdewit86

For me i am facing issue with position fixed elements. They are not at all getting rendered

kirtipriya avatar Nov 06 '20 13:11 kirtipriya

Some news?

developerskyext avatar May 26 '22 10:05 developerskyext

news about this problem?

leonidaswander avatar Jul 14 '22 03:07 leonidaswander

I am having a similar issue, my elements have their position property set to "absolute" and the saved PDF is blank.

AmirAshvins avatar Nov 30 '22 03:11 AmirAshvins

I am having a similar issue, my elements have their position property set to "absolute" and the saved PDF is blank.

i am having same issue did you find any slotion ?

farzadtara avatar Feb 14 '23 21:02 farzadtara

For me i am facing issue with position fixed elements. They are not at all getting rendered

same here

DRSCrafter avatar Jun 13 '23 10:06 DRSCrafter

same issue

strukturart avatar Jul 29 '23 04:07 strukturart

same here, we can't use this library if it doesn't support absolute positions

mlevi1806 avatar Aug 29 '23 08:08 mlevi1806

Same problem encountered, but fixed with this CSS rules on parent div (because we need a position for parent div to print correctly) :

.parentDiv {
    position: absolute;
}

Gaetanbrl avatar Nov 16 '23 15:11 Gaetanbrl