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

when use default_css blank PDF generate. #735

Open
Denny814 opened this issue Nov 10, 2023 · 3 comments
Open

when use default_css blank PDF generate. #735

Denny814 opened this issue Nov 10, 2023 · 3 comments
Labels
bug Something isn't working needs reproduction info Needs more info on how to reproduce this bug

Comments

@Denny814
Copy link

When using default_css in the CreatePDF(), the generative pdf will blank. PDF not taking any html content.
result = pisa_status = pisa.CreatePDF(html, dest=f, default_css=default_css) also font-family not working when using CreatePDF() . I have tried many ways and update version also.
I have used inline, external css also. Please suggest here.

OS version:
Python version: 3.11.4
XHTML2PDF version: 0.2.13

@Denny814 Denny814 added the bug Something isn't working label Nov 10, 2023
@timobrembeck
Copy link
Collaborator

@Denny814 Thanks for the report!
Unfortunately, I'm not able to reproduce this problem. Could you please provide a minimal example of the HTML & CSS code you're trying to render?
And which font family are you using?

@timobrembeck timobrembeck added the needs reproduction info Needs more info on how to reproduce this bug label Nov 10, 2023
@Denny814
Copy link
Author

Hi @timobrembeck , thanks for looking into it.

I am using xhtml2pdf(0.2.13) to generate PDF. When i used 'default_css' to render css in the html file, Blank PDF generate . CSS and the HTML content not rendered in the generated PDF file.

Below is my python code
with open(output_filename, 'wb') as output_file:
result = pisa.CreatePDF(
src=html_content,
dest=output_file,
default_css=default_css
)

Below is my default_css html code

Default CSS definition

default_css = """
    body {
        font-family: Arial, sans-serif;
        font-size: 12pt;
    }
    h1 {
        color: #007bff;
    }
    /* Add more styles as needed */
"""

Below is my html_content html code

Example HTML content

html_content = """

<title>Sample PDF with Default CSS</title>

Hello, World!

This is a sample PDF with default CSS.

""" Please let me know if anything you needed. Thanks.

@Denny814
Copy link
Author

Hi @timobrembeck , Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs reproduction info Needs more info on how to reproduce this bug
Projects
None yet
Development

No branches or pull requests

2 participants