Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting PDF error 135 when opening with Adobe #1292

Closed
RyanLeeBot opened this issue Jan 23, 2021 · 9 comments
Closed

Getting PDF error 135 when opening with Adobe #1292

RyanLeeBot opened this issue Jan 23, 2021 · 9 comments

Comments

@RyanLeeBot
Copy link

Have the simplest python script possible using the WeasyPrint tutorial. I'm using the latest versions of all libraries involved as I just set up everything for the first time.

Python code is:

from weasyprint import HTML, CSS HTML('http://weasyprint.org/').write_pdf('weasyprint-website.pdf')

When opening the pdf with adobe it tells me it wasn't all readable and detected a problem, error 135. I can view the pdf in any web browser. So if I print to pdf from the web browser and reopen then it works, just can't open direct after WeasyPrint creates the pdf from python. Any suggestions on how to troubleshoot this?

I'm integrating all this into an automation app that emails out reports to executives so the manual print to pdf work around for testing won't work for me in production.

@liZe
Copy link
Member

liZe commented Jan 23, 2021

Hello!

Do you use the latest stable version of WeasyPrint (v52.2) or the current master branch?

@RyanLeeBot
Copy link
Author

Hi there, thanks for asking. It was 52.2 and I tried forcing older versions as well to see if it made any difference with no luck.

Depending on how hard it is to figure out I'm looking at just sending the data to Power BI as I have an environment there already for reports.

@liZe
Copy link
Member

liZe commented Jan 25, 2021

Hi there, thanks for asking. It was 52.2 and I tried forcing older versions as well to see if it made any difference with no luck.

Depending on how hard it is to figure out I'm looking at just sending the data to Power BI as I have an environment there already for reports.

Oh, that’s strange. We’ve seen such errors with the master branch, but not with stable releases. If you can send us the related data (generated PDF, HTML and CSS sources) or make them available on Power BI, that would be very useful to understand the cause of the problem.

@jamwil
Copy link

jamwil commented Feb 4, 2021

I'm experiencing a similar issue and have narrowed it down to a / character in my html. Strangest thing. Will update if I can get to the bottom of it.

Edit: When I uncompress with qpdf I get the following warnings. No such issue when I remove the /.

WARNING: file.pdf (object 7 0, offset 10778): invalid character (+) in hexstring
WARNING: file.pdf (object 7 0, offset 10780): unknown token while reading object; treating as string
WARNING: file.pdf (object 7 0, offset 10724): expected dictionary key but found non-name object; inserting key /QPDFFake1

@liZe
Copy link
Member

liZe commented Feb 4, 2021

I'm experiencing a similar issue and have narrowed it down to a / character in my html. Strangest thing. Will update if I can get to the bottom of it.

Thanks a lot for this comment. Could you please share the PDF file, so that I can try to find the reason of the problem too 😄?

@jamwil
Copy link

jamwil commented Feb 4, 2021

Thanks @liZe! I will email the input html as well as the output pdf to you right away.

@liZe
Copy link
Member

liZe commented Feb 4, 2021

This bug is caused by a bug in Cairo 1.17.4: https://gitlab.freedesktop.org/cairo/cairo/-/issues/449

Cairo 1.17.4 is not a stable versions and suffers from many bugs. Using the latest version of Cairo instead (1.16.0) fixes this problem.

Also note that the current master branch doesn’t use Cairo anymore.

@liZe liZe closed this as completed Feb 4, 2021
@jamwil
Copy link

jamwil commented Feb 4, 2021

Confirmed, downgrading to Cairo 1.17.2 solved this issue. Thanks @liZe!

@ghost
Copy link

ghost commented Feb 8, 2021

Having the same issue, the full error is "There was an error processing a page. There was a problem reading this document (135).". Additional information reads "Dictionary keys must be direct name objects.". A more minimal HTML producing this issue follows:

<!DOCTYPE html>
<html>
<head>
</head>
<body>
    <table>
        <tr>
            <td>Hi</td>
        </tr>
    </table>
</body>
</html>

I haven't tried downgrading Cairo yet, but I thought I would provide more information about the error along with a minimal test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants