soderlind / read-offline

Read Offline allows you to download or print posts and pages. You can download the post as PDF, ePub and mobi
https://wordpress.org/plugins/read-offline/
31 stars 10 forks source link

Styling font and margins of page text #68

Open webinc opened 8 years ago

webinc commented 8 years ago

Hello...

First of all, forgive me posting in the wrong place, if this isn't a problem....

I like the plugin, and have managed to format a pdf for my client. However, we need to refine in further. In particular, I don't seem able to adjust the font-family or the margins of the body text on the page. See this for a screenshot showing where I am attempting to do format the PDF page.

Please can you guide me on how I change the font and the margins. In the meantime, we have found a workaround for the margins, but only by adding a 20mm white div block to the page content (which pushes the page text beneath header).

Many thanks Tim

webinc commented 8 years ago

Any chance of some help with this please? I have downloaded the MPDF manual, and tried numerous ways to adjust the top and bottom margins of the page, but none of them seem to work when I use the CSS in the read-offline custom CSS box in WP settings within the @page{ } settings.

Can you advise me on what I should do to fix and top and bottom margin so the page content doesn't run over my custom header and footer?

Thanks Tim

matthiaskuhl commented 8 years ago

i have the same question: no effects of any @page-settings, therefore following this thread. my work-around for margin-left/margin-right: adding all the margins to p, h1, h2, …, li, table, … but no solution für top/bottom, if the pdf ist more than one page if you just need one-page-pdfs, you can add a padding-top to header and padding-bottom to footer (inside "custom header"/"custom footer") but hopefully we will find out, how to make @page working? would be great!

soderlind commented 8 years ago

It might be because of this bug: https://github.com/mpdf/mpdf/issues/110

I'll take a look later this weekend

webinc commented 7 years ago

Thanks for that Per... certainly the symptoms are similar to those brought on by the addpage bug. I have tried a wide variety of css calls to set the page margins allowing for the header and footer, but all are ignored.

Any help you can provide would be much appreciated. Many thanks Tim

soderlind commented 7 years ago

Just fyi, I can confirm that the css is ignored.

soderlind commented 7 years ago

I've discovered, that the CCS parser in mpdf is very picky, a simple css like this works:

@page {
  margin: 20%;
}

If the CCS has syntax errors , mdpf will ignore your CSS. The CSS editor in Read Offline will display errors. Eg:

css-error
webinc commented 7 years ago

I'm afraid I'm not getting success even with margin:20%;

This CSS: pagecss1

Produces this PDF: (note - no margin so text overwrites header. and font remains serif instead of sans-serif (less important).... so it appears all CSS is being ignored.

image