Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Exit with code 1 due to network error: ContentNotFoundError #5271

Open
6273parastu opened this issue Nov 12, 2022 · 0 comments
Open

Exit with code 1 due to network error: ContentNotFoundError #5271

6273parastu opened this issue Nov 12, 2022 · 0 comments

Comments

@6273parastu
Copy link

when i use other font (e.g. persion font)in html, css occured this error:
Exception has occurred: OSError
wkhtmltopdf reported an error:
Exit with code 1 due to network error: ContentNotFoundError

test.py :

from jinja2 import Template
from pdfkit import pdfkit

sample_data = [{'name': 'برزینی', 'text': "فرمول منو این هیبریدی ما او مردی و زانو بنیان "},
                {'name': 'صادقی', 'text': """فرمول منو این هیبریدی ما او مردی و زانو بنیان"""},
                {'name': 'برزینی', 'text': """فرمول منو این هیبریدی ما او مردی و زانو بنیان  """}]
with open('test.html', 'r') as template_file:
    template_str = template_file.read()
    template = Template(template_str)
    for sa in sample_data:
        sa['text'] = arabic_reshaper.reshape(sa['text']) 
    resume_str = template.render({'contents': sample_data})
    options = {'encoding': "utf-8", 'quiet': ''}
    bytes_array = pdfkit.PDFKit(resume_str, 'string', options=options).to_pdf()
    with open('result.pdf', 'wb') as output:
        output.write(bytes_array)```

test.html :

```<!DOCTYPE html>
<html>
<head lang="fa-IR">
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="static/style.css">
</head>
<style>
    @font-face {
        font-family: "bnazanin";
        src: url("./static/fonts/BNazanin.woff");
    }
    body{
        font-family: "bnazanin";
        text-align: justify;
        direction: rtl;
    }
</style>
<body>
    <p>1401/08/18</p>
        {% for content in contents %}
        <div style="font-size:25px;padding: 15px">
            <p>
                <span style="color:rgb(9, 99, 61);">{{ content.name |safe}} : </span>
                <span style="color: red;">{{content.text |safe}}</span>
                <!-- qweqwe : Lorem ipsum dolor sit amet consectetur adipisicing elit. Fugit omnis magnam harum atque esse nemo maxime, culpa modi suscipit doloribus voluptatem minima laborum provident consequatur vero eligendi molestiae velit! Accusamus? -->
            </p>
        </div>
        {% endfor %}
</body>
</html>```
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant