Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    logik
    @logikonabstractions
    image.png
    (then rendered page as pdf)
    Okay thanks a bunch! If you can think of something
    Guillaume Ayoub
    @liZe
    @logikonabstractions I think that we need another stylesheet
    You probably sent pdf.css, but not sb-admin-2.css
    Michael Lewellen
    @cylon56
    image.png
    logik
    @logikonabstractions

    @liZe armphhhhhhhh......... I can be so dumb at times. That css files is basically a baseline from some frontend template I'm using throughout the project. I guess it just made its way there because.... well copy-past I guess. Removing it does solve the issue w/o really affecting the pdf (since I'm already specifying things I want to see there in my own css).

    Well spotted. It probably set some width or something somewhere that weasy didn't like.

    Benjamin Lok
    @BenjaminLok_gitlab
    Hey there, I have a python project on windows using weasyprint. It was working fine about 2 weeks ago. Since then I haven't changed the project. I have done a windows update though, and now when I try to import weasyprint, I get Fontconfig error: Cannot load default config file - anyone else had this and know what to do?
    Lucie Anglade
    @grewn0uille
    Hello @BenjaminLok_gitlab! Did you have a look at these issues Kozea/WeasyPrint#1472, Kozea/WeasyPrint#1474 and Kozea/WeasyPrint#1464 related to fontconfig with windows?
    2 replies
    Benjamin Lok
    @BenjaminLok_gitlab
    will do now, thank you
    elimboto
    @elimboto
    Hello, the Team. This snippet, HTML(string=output).write_pdf("report.pdf", stylesheets=[CSS(string='@page { size: landscape }')]) can convert a Python HTML table into pdf, but only up to some width. I have encountered the situation where the table is wider than this snippet can accommodate, and hence its width will be cut off. I read somewhere that " A modern PDF file can be 15,000,000 inches in each direction....". What can I do to convert HTML doc into pdf no matter its width?
    Lucie Anglade
    @grewn0uille
    Hello!
    There is no perfect solution for this. You can reduce the font-size of the text in the table to make it fit the page. You can also use named page to have different a bigger page for pages with table
    elimboto
    @elimboto
    @grewn0uille Thank you. Reducing font size may in most cases not help, suppose you have 50 columns, each with a width of at least one inch. Do you have an example of named page usage with WeasyPrint?
    For example, you have page: no-chapter in h1
    It means that h1 tags will be put in special pages called no-chapter
    And you can define the format of these pages in a @page no-chapter rule
    Troulet-Lambert Odile
    @piscvau_gitlab
    Hello I am using the report example to write a css for a template in my application. I do not have very much experience with css. I am struggling with the h2 with string-set. I guess that it says that all h2 text should have a break_before and their content should be considered as having an id = "heading". Could you confirm that this understanding is correct; also the string-set is not described in mozilla css reference and here (https://www.cssportal.com/css-properties/string-set.php) it is said that it is deprecated. I suppose it is correctly handled by weasyprint but is there a more recent alternative? I thank you in advance for your help.
    Lucie Anglade
    @grewn0uille
    Hello!
    In the report sample, each time a h2 tag is encounter, its content is put in a string named "heading" and we break before to have a new page https://github.com/CourtBouillon/weasyprint-samples/blob/d95ca0480c8ad1964065b89496541f7c73e5d251/report/report.css#L95-L99
    This string "heading" is used to put the title of the chapter at the top right of the page https://github.com/CourtBouillon/weasyprint-samples/blob/d95ca0480c8ad1964065b89496541f7c73e5d251/report/report.css#L46
    The id "heading" in the HTML is only used to put a image for this section https://github.com/CourtBouillon/weasyprint-samples/blob/d95ca0480c8ad1964065b89496541f7c73e5d251/report/report.css#L207
    Troulet-Lambert Odile
    @piscvau_gitlab
    OK thanks a lot. That is clear.
    Troulet-Lambert Odile
    @piscvau_gitlab
    Hello I am using weasyprint to create a pdf from a django template. The html generated by django template contains a <link rel='stylesheet" href = "/static/.....". The css seems to never be called. I tried to put a specific url_fetcher but it is never called either. So I am confused.
    Guillaume Ayoub
    @liZe
    Hello! You really should use Django-WeasyPrint, it’s really useful to handle the static files correctly in Django.
    Troulet-Lambert Odile
    @piscvau_gitlab
    Hello yes I tried but it does not help. Django url_fetcher is never called. I guess what I misunderstand is what should go in the django template in the link href to the css
    Guillaume Ayoub
    @liZe
    Hmmm…
    Troulet-Lambert Odile
    @piscvau_gitlab
    or said in another way when does weasyprint.render does consider it should look for a url!....
    Guillaume Ayoub
    @liZe
    I think that you have to call a function instead of using /static/, but I don’t know Django very well…
    Troulet-Lambert Odile
    @piscvau_gitlab
    No but let us say it the other way around. what should be in the html so that weasyprint.HTML considers it should look for an URL. May be I should add that for the moment, I am testing with django test and so django is not really serving the static files.....
    Guillaume Ayoub
    @liZe
    Oh, that’s why Django-WeasyPrint doesn’t work then
    Django-WeasyPrint overrides the function used to serve static files, so that it bypasses the network and just gets the content from the filesystem
    But if Django doesn’t serve static files, it won’t work
    If you just want to test with no static files served by the server, you can try to use file:// URLs instead of /static/ URLs that are supposed to be served by the HTTP server
    Troulet-Lambert Odile
    @piscvau_gitlab
    OK yes I tried this. But unfortunately I end up with href= "/file:/home/odile/ and I suppose the extra / prevents weasyprint to find the file. Is this correct?
    Guillaume Ayoub
    @liZe
    Right, the URL is probably rewritten by Django :/
    Troulet-Lambert Odile
    @piscvau_gitlab
    The only solution would then be to create manually a CSS object in the test and pass it to the function HTML in some way. Is this correct?
    Guillaume Ayoub
    @liZe
    To test, you can first include some CSS in a <style> tag and see that it works correctly
    If it works, you can then 1) create the CSS object and give it to the HTML class, or 2) create your own url_fetcher that will translate /static/… URLs into filenames and call the original url_fetcher with this filename
    If it doesn’t work, then the problem is elsewhere
    Troulet-Lambert Odile
    @piscvau_gitlab
    Yes but this is not really good testing practice. But I understand weasyprint is not the cause of my problem!.....
    Guillaume Ayoub
    @liZe
    Oh, OK, I didn’t understand that you were creating unit tests, I thought that you were just trying to get a quick and dirty website!
    :)
    Troulet-Lambert Odile
    @piscvau_gitlab
    well I think that creating a CSS object will do it at least for the moment, because I have only one static that is the CSS. Thanks a lot
    Guillaume Ayoub
    @liZe
    No problem!
    christian lambert
    @skirando_gitlab
    Bonjour,
    j'utilise weasyprint et je voudrais mettre un contenu dans le bottom_right d'une page - @page {
    @bottom-right {
    content: string(heading) " page " counter(page) "categorie : " string(heading2) ;
    position: absolute;
    z-index: -1;
    }
    le heading2 provient d'une classe .catnum{ string-set : heading2 content(),} cet élément figure dans ma page html mais je ne veux pas qu'il apparaisse dans la page mais uniquement dans le bas de page.
    christian lambert
    @skirando_gitlab
    dès que j'utilise hidden = true dans la page html ou display : None dans le css, l'élément n'apparait plus dans le bas de page. Y a-t-il une solution élégante pour résoudre ce problème. Par ailleurs, il est écrit que l'attribut string-set est obsolète. Y a-t-il un autre attribut. Merci pour votre éclairage. Cordialement C. Lambert
    Guillaume Ayoub
    @liZe
    Bonjour @skirando_gitlab
    christian lambert
    @skirando_gitlab
    Bonjour
    Guillaume Ayoub
    @liZe
    Pour le problème de display: None qui fait que l’élément n’apparaît plus, c’est en effet un bug : Kozea/WeasyPrint#473
    Pour string-set qui est obsolète, je crois que j’ai déjà entendu cette histoire… Je ne crois pas que ce soit obsolète, c’est toujours dans le dernier brouillon de la spécification sans mention particulière https://drafts.csswg.org/css-content-3/#string-set