python-pdfkit icon indicating copy to clipboard operation
python-pdfkit copied to clipboard

pdfkit.from_file is not outputting the file content in Arabic!

Open CJSparrow opened this issue 3 years ago • 3 comments

function:

def converter(filename, output_path=(getcwd() + '\\output\\')):
    pdfkit.from_file(f'{output_path}html\\{filename}.html', f'{output_path}pdf\\PDF-{filename}.pdf')

output: image

py: 3.8 pdfkit: last wk: last, 64bit

CJSparrow avatar Jan 19 '22 01:01 CJSparrow

@JazzCore, any help?

CJSparrow avatar Jan 19 '22 21:01 CJSparrow

@CJSparrow I'm pretty sure that this issue is on wkhtmltopdf side, since you're passing a file to it. Check README troubleshooting section and then try running it manually through CLI. You can either form command for it yourself or check what command pdfkit generates and then run it directly from terminal (adapt example for your case):

import pdfkit

r = pdfkit.PDFKit('html', 'string', verbose=True)
print(' '.join(r.command()))
# try running wkhtmltopdf to create PDF
output = r.to_pdf()

JazzCore avatar Jan 19 '22 21:01 JazzCore

HI @CJSparrow

You can try adding these lines in your html, maybe it will help :)

<!DOCTYPE html>
<html lang="fa" style="text-align:right">
  <head>
    <title>PAGE-1</title>
    <meta name="description" content="" />
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

you can change fa (farsi) to ar (arabic)

TorhamDev avatar Nov 18 '22 09:11 TorhamDev