#content .address p{
- margin-left: 55%;
+ margin-left: 5%;
line-height: 20px;
font-size: 14px;
font-weight: bold;
#content table{
margin-top: 30px;
- width: 100%;
+ width: 96%;
line-height: 20px;
border-spacing : 0;
border-collapse : collapse;
}
#content table tr th{
- padding: 5px;
- font-size: 14px;
+ padding: 4px;
+ font-size: 12px;
border: 1px solid #000;
}
}
#content table tr th:first-child{
- width: 60%;
+ width: 56%;
}
#content table tr td{
- padding: 15px 5px;
+ padding: 12px 4px;
border-left: 1px solid #000;
border-right: 1px solid #000;
line-height: 24px;
- font-size: 14px;
+ font-size: 12px;
font-weight: bold;
}
#content table tr td:first-child{
from jsonrpc import jsonrpc_method
from jsonrpc.proxy import ServiceProxy
from teleforma.models.crfpa import Home
-from xhtml2pdf import pisa
+import weasyprint
from ..decorators import access_required
from ..models.appointment import Appointment, AppointmentPeriod
Write into *dest* file object the given html *content*.
Return True if the operation completed successfully.
"""
- src = BytesIO(content.encode(encoding))
- pdf = pisa.pisaDocument(src, dest, encoding=encoding, **kwargs)
- return not pdf.err
-
+ src = weasyprint.HTML(string = content, encoding = encoding)
+ src.write_pdf(dest)
+ return True
def content_to_response(content, filename=None):
"""
Render a pdf response using given *request*, *template* and *context*.
"""
content = loader.render_to_string(template, context, request = request)
+ #return HttpResponse(content)
buffer = BytesIO()
succeed = content_to_pdf(content, buffer, encoding, **kwargs)
template_name = 'myapp/myview.html'
pdf_filename = 'report.pdf'
- The pdf generation is automatically done by *xhtml2pdf* using
+ The pdf generation is automatically done by *weasyprint* using
the *myapp/myview_pdf.html* template.
Note that the pdf template takes the same context as the normal template.