Skip to content

openpdf-html css style does not load #1361

Description

@fosJoddie

Describe the bug

It looks like the changes in https://github.com/LibrePDF/OpenPDF/pull/1348/files caused (some?) css files to stop loading with a silent unexpected EOF

To Reproduce

My css starts with

@page {
    size: a4 portrait;
    margin: 0;
}

@media print {
    footer {
        page-break-after: always;
    }
}

which throws exception after handling of @ media element.

Expected behavior

CSS stylesheet is loaded and generated PDF is pretty

Screenshots

Current PDF (top left)

Image

Correct PDF

Image

System

  • OS: MacOs and Windows
  • Used font: NA
  • OpenPDF version: 2.2.1

Additional context

the break inside this switch only breaks out of the switch and not the loop, around line 422 in org.openpdf.css.parser.CSSParser.java

switch (t.getType()) {
                                case RBRACE:
                                    next();
                                    break;
                                default:
                                    ruleset(mediaRule);
                            }

Suggested fix, tested ok locally

if (t.getType() == Type.RBRACE) {
   next();
   break;
} 
ruleset(mediaRule);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions