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

Python Blabel generate broken PDF file #10

Open
dsztandarski opened this issue Mar 15, 2021 · 5 comments
Open

Python Blabel generate broken PDF file #10

dsztandarski opened this issue Mar 15, 2021 · 5 comments
Assignees

Comments

@dsztandarski
Copy link

dsztandarski commented Mar 15, 2021

I am writing a program to handle label printing on a thermal transfer printer. I have a problem with corrupted PDF files after generating them with blabel. For example, if I generate a label with the serial number VWAB123456, everything is fine, but in the case of the serial number VWAC123456 a corrupt PDF file is generated.

Damaged PDF after printing with Sumatra PDF looks fine, but bold font disappears and the font type changes. It looks like CSS is not being used at all at the moment. Adobe Reader error below:
Broken PDF
Damagen PDF Image

Label without bold (broken PDF file)
Label without bold

Label with bold (fine PDF)
Label with bold

Python code:
Python code

HTML code:
HTML code

CSS sheet:
CSS sheet

Can anyone help me with this problem?

@veghp veghp self-assigned this Mar 16, 2021
@veghp
Copy link
Member

veghp commented Mar 16, 2021

Thanks for posting a detailed example. Your code works fine here on Ubuntu, without running the lines with sumatra. A couple of comments on what may cause this issue: from what you wrote, blabel correctly made at least one PDF, so the package seems to work fine. You are sourcing the logo over the net, and that can be a problem (repeated access / delay / etc). Try using a local image.
If the label is wider or longer than the page, as is in your example, then part of it will not be printed on the page. Perhaps that can be a problem and interpreted as corrupted file?
If you are running your code as posted, sumatra may try to access the pdf at the same time as the python code (or the next iteration if you are running as a loop). Try using a different filename for each pdf.
Finally, this package was developed on Ubuntu (GNU/Linux) and not Windows (but as mentioned above, it would cause an error in all files).

@dsztandarski
Copy link
Author

I checked your suggestions and unfortunately the program that runs on Windows continues to generate corrupted PDF files. I installed Ubuntu in Virtualbox and ran the program on Ubuntu 20.04 LTS and in this case the program works fine and generates correct PDF files.

Is there any way to fix this problem for a program that runs on Windows 10?

@Zulko
Copy link
Member

Zulko commented Mar 16, 2021

This library uses weasyprint to generate the PDFs, it might be worth checking with them if they are aware of Windows issues.

Another possibility is that the font used (on Windows) is causing the problem.

@dsztandarski
Copy link
Author

dsztandarski commented Mar 17, 2021

I found a solution. The problem was caused by the cairo library version 1.17.4, I installed the older version of GTK3-Runtime (including cairo version 1.16.2) from 2019-11-07 from the link below and the files are generated correctly :)

https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer/releases/tag/2019-11-07

@veghp
Copy link
Member

veghp commented Mar 18, 2021

That's great to hear, thanks for sharing

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