splitbrain / dokuwiki-plugin-dw2pdf

A fork of Luigi Micco's PDF export plugin for DokuWiki
http://www.dokuwiki.org/plugin:dw2pdf
55 stars 68 forks source link

Changing the orientation within one document, the cover.html page template is used again #501

Closed UMA-111 closed 8 months ago

UMA-111 commented 9 months ago

Hi there,

I tried to change the page orientation in one document by using:

~~PDF:LANDSCAPE~~

or

~~PDF:PORTRAIT~~

Whenever I do so, the cover.html from my DW2PDF template is used again.

Did I miss a way to prevent this, or is this a bug?

cheers, UMA-111

Klap-in commented 9 months ago

Do you have an example of cover.html?

The PDF:landscape/portrait is somewhere in the wiki article which you are exporting?

UMA-111 commented 9 months ago

Hi Gerrit, I gave you access to the private repo with this file. In this repo is also an example.pdf, where you can see it at page 38 and 64, where the cover comes again.

The PDF:landscape/portrait is somewhere in the wiki article which you are exporting?

Exactly!

Klap-in commented 9 months ago

After having a look. The cover can be just html like any other page, that is added before the normal pages are added. So far I know <head> and <body> tags are not needed. (I have not yet test with my own setup if it makes a difference). But I think it might be relevant thing to test out if removing them helps. Do not yet see other things that are remarkable for me.

Klap-in commented 9 months ago

Another thing to try out is the working of the @page :first { } syntax.

@page :first {
    header: _blank;
    footer: _blank;
    background-image: url(/lib/plugins/dw2pdf/tpl/yourtpl/cover_files/logo.jpg);
    background-repeat: no-repeat;
    background-image-resize: 1;
    background-position: 0% 25%;
}

It might be :first is used for each first page after rotating a page? Is probably not exactly how it should work, but maybe that is the culprit here? Alternatively, you can try to use your own named page instead of :first and add it to a css style you can refer from the div of the cover page? (see Named @page selectors).

https://mpdf.github.io/paging/using-page.html

UMA-111 commented 8 months ago

Thanks a lot! I could fix the issue. And you are right: The culprit is the @page :first selector, which is always used when the page is rotated, so I added named page selectors.

@page :first {
    header: _blank;
    footer: _blank;
    background-image: url(/lib/plugins/dw2pdf/tpl/avnet/cover_files/manual_logo.jpg);
    background-repeat: no-repeat;
    background-image-resize: 1;
    background-position: 0% 25%;
}

@page landscape {
    size: landscape;
    header: header_odd;
    footer: footer_odd;
    background-image: none; 
}

@page portrait {
    size: portrait;
    header: header_odd;
    footer: footer_odd;
    background-image: none;
}

div.wrap_landscape {
    page: landscape;
    page-break-before: always;
}

div.wrap_portrait {
    page: portrait;
    page-break-before: always;
}

In Dokuwiki I can then use the wrap plugin to change the orientation: <block landscape></block> <block portrait></block>