[reportlab-users] Different styles for screen and print

Yan Seiner yan at seiner.com
Fri Nov 29 12:02:17 EST 2013

On 11/29/2013 07:57 AM, Yan Seiner wrote:

> I have a mediawiki template for a photo "gallery" - basically 2 images

> sized to span the width of the page. I am using mwlib / rl reports to

> generate pdfs from the wiki.


> I need to have one format / size of the images for screen display and

> one for the pdf to make it appear correctly.


> I have tried using various combinations of <div media="print"

> display="none"> and so on and it either displays in both screen and

> reports or neither.


> Is anyone using mwlib / reportlab to create pdfs with different screen

> and report formatting? How do I tell reportlab to ignore certain

> sections?

I've made some progress but I'm still struggling with reportlab.

For mediawiki, the following gives the results I want, but reportlab
prints both paragraphs:

Test page:

== Print ==

<div style="media:print" class="ys_print">
Lorem ipsum....

== Screen ==
<div style="media:screen" class="ys_screen">
Lorem ipsum....


@media screen {
div.ys_print {
display: none;


@media print {
div.ys_screen {
display: none;

How do I get reportlab to respect the media and display css?

More information about the reportlab-users mailing list