第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何在xhtml2pdf中將阿拉伯字符導(dǎo)出為pdf?

如何在xhtml2pdf中將阿拉伯字符導(dǎo)出為pdf?

PHP
MMTTMM 2023-11-09 17:00:35
我想使用 xhtml2pdf 將阿拉伯字符導(dǎo)出為 pdf,因?yàn)槲以?django 應(yīng)用程序中使用它。我知道他們做了更新,說他們修復(fù)了它,但它對(duì)我不起作用,我使用了自定義字體但仍然不起作用。因此,請(qǐng)任何人知道正確的加密方式或與之相關(guān)的任何方式,幫助我。發(fā)票.html:{% load static %}<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>        <meta http-equiv="content-type" content="text/html; charset=utf-8"><head>    <title>{{title}}</title><style type="text/css">        @font-face {        font-family: Amiri, "Amiri Font";        src: url("{% static 'font/Amiri-Italic.ttf'%}");        }        body {            font-weight: 200;            font-size: 14px;        }    </style></head><body><pdf:language name="arabic"/>    <div class='wrapper'>        <div class='header'>            <p class='title'>Invoice # {{ invoice_ID }} </p>        </div>        <div>            <div class='details'>                <pdf:language name="arabic"/>                     <p> ?????</p>                           customername : {{customer_name}} <br><hr>                <hr class='hrItem' />            </div>        </div></body></html>utils.py :from io import BytesIOfrom django.http import HttpResponsefrom django.template.loader import get_templatefrom xhtml2pdf import pisadef render_to_pdf(template_src, context_dict={}):    template = get_template(template_src)    html  = template.render(context_dict)    result = BytesIO()    pdf = pisa.pisaDocument(BytesIO(html.encode("UTF-8")), result)    if not pdf.err:        return HttpResponse(result.getvalue(), content_type='application/pdf')    return Noneviews.py :from django.shortcuts import render, redirect, HttpResponseimport pandas as pdfrom .models import SaleInvoice, TransferWays, User, InstallingCitiesfrom siteManagment.models import MarketersManagment, WareHousesfrom .utils import render_to_pdffrom django.core.validators import ValidationError
查看完整描述

1 回答

?
慕標(biāo)琳琳

TA貢獻(xiàn)1830條經(jīng)驗(yàn) 獲得超9個(gè)贊

我解決了它,文檔實(shí)際上沒有任何問題,問題出在靜態(tài)中..因?yàn)楫?dāng)您使用 {% static 'whatever' %} 時(shí),它將搜索靜態(tài)文件,但由于某種原因它不起作用,我認(rèn)為問題來自 django 本身,也許你無法從 pdf 文件中調(diào)用靜態(tài)。這是我的新發(fā)票.html(我已將字體的整個(gè)路徑放在其中):


{% load static %}

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

    

    <meta http-equiv="content-type" content="text/html; charset=utf-8">

    <head>

    

    <title>{{title}}</title>

    <style type="text/css">

        


        .header {

            font-size: 20px;

            font-weight: 100;

            text-align: center;

            color: #007cae;

        }


        .title {

            font-size: 22px;

            font-weight: 100;

            /* text-align: right;*/

            padding: 10px 20px 0px 20px;

        }


        .title span {

            color: #007cae;

        }


        .details {

            padding: 10px 20px 0px 20px;

            text-align: right !important;

            /*margin-left: 40%;*/

        }


        .hrItem {

            border: none;

            height: 1px;

            /* Set the hr color */

            color: #333;

            /* old IE */

            background-color: #fff;

            /* Modern Browsers */

        }

        @font-face {font-family: RTLFont; src: url('C:\\Users\\BigBoy\\Desktop\\MyProjects\\ToysSite\\static\\font\\Amiri-Italic.ttf')} // Here

        

        body {

            font-weight: 200;

            font-size: 14px;

            font-family: RTLFont;

        }

        /* @page {

        background-image: url('C:\Users\BigBoy\Desktop\MyProjects\ToysSite\static\background.png');

        } */

    </style>

</head>


<body>

    <div class='wrapper'>

        <div class='header'>

            

        </div>

        <div>

            <div class='details'>

                <pdf:language name="arabic"/>

                

                ??? ?????? : {{customer_name}} <br><hr>

                <hr class='hrItem' />

            </div>

        </div>

    </div>

</body>


</html>


查看完整回答
反對(duì) 回復(fù) 2023-11-09
  • 1 回答
  • 0 關(guān)注
  • 152 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)