PDF Generating Tool Support Forum

HOME   Login   Register    Search

  Subject: Using 'display: absolute' with 'page-break-inside: avoid'
   PostPosted: 16 May 2017, 13:54 

I'm having problems using a div with 'position: absolute' inside an other div with 'position: relative' in combination with 'page-break-inside: avoid'. The relative divs are positioned as is expected. But the absolute positioned divs are rendered like they would be with out the page break.

Example code:
  for ( int i = 0; i < 10; i++ ) {
      <tr style="page-break-inside: avoid">
          <div style="position: relative; width: 400px; height: 400px; border: solid 2px red;">
            Outer div: <%=i%>
            <div style="position: absolute; left: 100px; top: 100px; width: 200px; height: 200px; border: solid 2px green;">
              Inner div: <%=i%>

See screenshot of generated output. The green divs should always be in the exact center of the red divs, but this is not the case.

Does anybody have an idea how to fix this problem?

2017-05-16 13_50_40-ManageMent Systeem.png
2017-05-16 13_50_40-ManageMent Systeem.png [ 25.89 KiB | Viewed 77 times ]
  Subject: Re: Using 'display: absolute' with 'page-break-inside: avoid'
   PostPosted: 18 May 2017, 17:43 
A page breaking logic for absolute positioned elements was too browser-specific the time we added it to PD4ML. So we implemented two (reasonable from our perspective) modes. There were also strange approaches: i.e. the absolute positioned elements are rendered only on the first page. We did not support that.

So try the alternative mode:

Map m = new HashMap();
m.put(PD4Constants.PD4ML_ABSOLUTE_ADDRESS_SPACE, "document");

Or switch the mode on by the JVM param:

[Reply]     [ 2 posts ] 

Copyright ©2004-10 zefer|org. All rights reserved. Bookmark and Share