Forum How do I...?

Problems getting string-set and page regions updated when an absolute-positioned element is introduced

theadventmaster
FYI this is a DocRaptor customer using Prince 12. They sent us a wonderful test rig to demonstrate the issue. Are you able to reproduce the following?

Every <h1> except the second is intended to update the custom top-right page region content. You can see that only a handful accomplish this task. The introduction of an absolute positioned cover page seems to be causing problems.

I'm not confident enough to file this as a bug. I'm wondering if you can help us find the solution?
<style>
  @page {
    size: a4 landscape;
    margin: 10mm;
  }
  .page {
    page-break-before: always;
  }

  @page {
    @top-right {
      margin-top: 3mm;
      border-bottom: thin solid #333333;
      content: string(top_right, first);
    }
    @bottom-right {
      margin-bottom: 3mm;
      border-top: thin solid #333333;
      content: "Page " counter(page) " of " counter(pages);
    }
  }

  h1 {
    string-set: top_right content();
  }

  .page-cover {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: lightblue;
  }

  .force-title-update {
    opacity: 0;
  }

</style>

<div class="page">
  <h1>Title 1</h1>
  <p>This sets the top-right region</p>
  <h1>Title 2</h1>
  <p>This is correctly ignored as we're using first: <code>string(top_right, first)</code></p>
</div>

<div class="page">
  <h1>Title 3</h1>
  <p>This works too</p>
</div>

<div class="page page-cover">
  <h1>Title 4</h1>
  <p>This doesn't update title</p>
  <p>I use the <code>page-cover</code> class to create pages with positioned elements (cover pages etc.)</p>
</div>

<div class="page">
  <div class="page-cover">
    <h1>Title 5</h1>
    <p>This doesn't update title either</p>
  </div>
</div>

<div class="page">
  <h1 class="force-title-update">Title 6</h1>
  <div class="page-cover">
    <h1>Title 6</h1>
    <p>This page has a workaround, but requires duplicated content</p>
  </div>
</div>


Best regards,

Alex
DocRaptor support
  1. title-not-updating.pdf57.4 kB
markbrown
Hi Alex,

FYI this is a DocRaptor customer using Prince 12. They sent us a wonderful test rig to demonstrate the issue. Are you able to reproduce the following?


Yes, I can reproduce it. Thanks for the neat test!

I'm not confident enough to file this as a bug. I'm wondering if you can help us find the solution?


I think it probably should be considered a bug. The title will update if the absolutely positioned element is wrapped in a relatively positioned one, although the result is still not quite what you are after. I'll keep experimenting.

Mark
oodavid
Thanks Mark - I'd rather have nesting than duplication :)

> ...although the result is still not quite what you are after

How so?
markbrown
> How so?

The background wouldn't appear with just the relative positioning. However, I've found adding height:190mm to the wrapper element fixes this, although it means effectively duplicating the page size (which perhaps isn't as bad as needing to duplicate content). Does this work for you?

Mark