Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    kstefanova96
    @kstefanova961_twitter
    I'm not sure. I have a problem with hyperlink in the generated HTML. I found some issues about cairo, but I don't know how to apply them
    I'm using amazon linux 1
    Lucie Anglade
    @grewn0uille
    Oh, so you managed to run WeasyPrint. What is the problem with the hyperlinks?
    kstefanova96
    @kstefanova961_twitter
    They are not clickable
    They are clickable in the HTML template, but when PDF is generated they are not clickable. The version of cairo package is 1.12.14 - the latest version for Amazon Linux
    Guillaume Ayoub
    @liZe
    WeasyPrint requires at least Cairo 1.15.4 to have clickable links
    kstefanova96
    @kstefanova961_twitter
    Ok, I'll try to install it manually. I'll hope it helps. :D
    Guillaume Ayoub
    @liZe
    Another solution is to install an old version of WeasyPrint
    But having recent versions of Cairo and Pango is much better if you want to have all the features and bug fixes included in recent versions of WeasyPrint :)
    kstefanova96
    @kstefanova961_twitter
    Yeah. Now I read it in the docs. I'll try with a newer cairo version. But still can you tell me which version of WeasyPrint is compatible with cairo 1.12.14. :)
    Guillaume Ayoub
    @liZe
    I think that the last version to support links with Cairo 1.12 is 0.42.3
    kstefanova96
    @kstefanova961_twitter
    Thanks a lot! Really appreciate your help!
    Guillaume Ayoub
    @liZe
    :)
    Felix Schwarz
    @FelixSchwarz
    table_vertical_align.expected.png
    table_vertical_align.png
    I have a problem with WeasyPrint 52.2 in F34 (rawhide). I get several failures when trying to run the test suite. I posted two images for "table_vertical_align" (expected vs actual). Now my question is where I should start looking.
    Fedora rawhide contains the latest versions of most packages so I suspect some cairo problem as the test suite passes in F33.
    Builds in Fedora's continuous build service koschei started to fail when cairo was upgraded from 1.16.0 -> 1.17.4 (also pillow 8.0.1 -> 8.1.0): https://koschei.fedoraproject.org/package/weasyprint?collection=f34
    Felix Schwarz
    @FelixSchwarz
    So I guess the first question is if the test suite works for you with cairo 1.17.x ?
    Lucie Anglade
    @grewn0uille
    Hi!
    The test suite doesn’t work with cairo 1.17 (got 32 failed for me with cairo 1.17.4)
    Lucie Anglade
    @grewn0uille
    That’s one of the reasons we are going to use pydyf
    Felix Schwarz
    @FelixSchwarz
    Yeah, I'm looking forward to pydyf as well. Actually I started packaging it for Fedora (review not yet submitted).
    However as Fedora's build is currently failing with the available versions of WeasyPrint/cairo the package might be removed in F34 worst case until we can get the test suite passing again.
    any idea when we'll see the next stable version of WeasyPrint which can use pydyf? If that's within the next months or so I could probably skip the whole cairo stuff and just package pydyf + the next WeasyPrint version?
    I guess you'll need some more time as pydyfSVG is still to be published?
    Lucie Anglade
    @grewn0uille
    Yes, we need some more time to have pydyfSVG and so we’ll have a WeasyPrint + pydyf
    I think that might be between 2 and 4 months
    Bolat Azamat
    @bolatuly
    question, as I see inline svg is not supported (Kozea/WeasyPrint#75). I wonder if pydyfSVG will support it? Or there are no plans on this feature?
    Guillaume Ayoub
    @liZe
    Hi @bolatuly!
    Guillaume Ayoub
    @liZe
    We may try to support inline SVG with pydyfSVG, probably with no CSS support
    Bolat Azamat
    @bolatuly
    thanks for reply @liZe ! You mean styling through CSS? It would be great at least have support for style attributes on the SVG elements themselves.
    Lucie Anglade
    @grewn0uille
    Yes it would be the styling through CSS which wouldn’t work
    Bolat Azamat
    @bolatuly

    Hello guys, several month ago I opened issue (Kozea/WeasyPrint#1238) in github, with a question about OCG layers. And @liZe answered me that this feature can be implemented using own PDF writer (pydyf as I think). But, because of the urgency, I need it in WeasyPrint v52, running in our production environment.

    So I started looking for a workaround and tried to implement it by myself. Here is what I did:
    Added below code in weasyprint/pdf.py write_pdf_metadata function. it’s not perfect, written quickly for test =).

    resources = pdf_page.get_indirect_dict('Resources', pdf)
    if b'XObject' in resources.byte_string:
        x_objects = resources.get_value('XObject', '<<(.+?)\\>>').split(b' 0 R')
    
        oc_ids = []
        for x_object in x_objects:
            x_object_splitted = x_object.decode('ascii').strip().split()
            if len(x_object_splitted) < 2:
                continue
            x_object_name, x_object_number = x_object_splitted
            x_object_number = int(x_object_number)
            pdf_x_object = PDFXObject(x_object_number, pdf.read_object(x_object_number))
    
            # Add OCG meta
            oc_id = _write_pdf_ocg(x_object_name, pdf)
    
            oc = pdf_format('/OC {0} 0 R', oc_id)
            pdf.extend_x_object(pdf_x_object, oc)
            oc_ids.append(oc_id)
    
        if oc_ids:
            arr = '['
            for oc_id in oc_ids:
                arr = arr + ' {0} 0 R'.format(oc_id)
            arr = arr + ']'
    
            params = pdf_format(
                ' /OCProperties << /D << /Order {0} >> /OCGs {0} >>', arr)
            pdf.extend_dict(pdf.catalog, params)

    I find all XObjects in Resources, extend XObject by adding metadata (/OC)… but I have no idea how to find XObjects which I only need.
    For example making optional only html image with specific id attribute.

    <img src="/test_url" id="ocg_image" />

    Any ideas? I'd appreciate any help you can give.

    Guillaume Ayoub
    @liZe
    Hi @bolatuly. I don’t think that there’s an easy way to get only the XObjects you need from the PDF.
    I don’t think that there’s a specific information that could make them different from each other.
    You’ll probably find an easier solution if you use the current master branch because you can directly change the PDF when the image is inserted. It’s not stable yet (the main missing feature is the lack of SVG support), but you may get the result you want.
    Guillaume Ayoub
    @liZe
    Hmmmm… It’s not easy to find which images have to be modified based on an HTML id…
    Guillaume Ayoub
    @liZe
    The best hack I can think of is:
    • You use a GET parameter in the URL instead of using an HTML id.
    • You override get_image_from_uri to set an ogc boolean attribute to the image (True if the GET parameter is in the URL).
    • You override RasterImage.draw to get the PDF id of the image.
    Guillaume Ayoub
    @liZe
    • You pass a finisher function to write_pdf to add your OCGs.
    That should work, without modifying WeasyPrint’s code.
    Bolat Azamat
    @bolatuly
    • You override RasterImage.draw to get the PDF id of the image.
    Sorry, didn't get this part...
    Bolat Azamat
    @bolatuly
    Should I get PDF id of the image from cairocffi.context.Context? If so, how to do it
    Lucie Anglade
    @grewn0uille
    Hi! The PDF id of the image you need is the image_name in RasterImage.draw
    Bolat Azamat
    @bolatuly
    Hi! Seems like I misunderstood suggested 'hack', it was for current master branch not for release 52 with cairo
    Lucie Anglade
    @grewn0uille
    Yes it is for the current master indeed
    Bolat Azamat
    @bolatuly
    May I ask.. Is there any progress on SVG support in the current master branch?
    Lucie Anglade
    @grewn0uille
    Yes, we started to work on pydyfSVG to support SVG with our PDF generator

    I think that might be between 2 and 4 months

    It was said in the begining of January