Posts

Showing posts with the label unix

Convert Html to PDF Python/Django on Unix Platform

Convert Html to PDF Python/Django on Unix Platform I’m working on a functionality where I need to convert a huge html file (size more than 1 mb) into pdf. I’ve tried below two open-source python libraries. 1. Xhtml2pdf (Pisa) 2. Weasyprint But none of them solves my problem as they take around 4-5 mins in generating 1 MB PDF file (around 500 pages) causing my app server’s worker process (Gunicorn and Nginx) to get down and throwing ‘GATEWAY TIMEOUT ERROR’ on browser. CPU utilization also goes up to 100% while PDF conversion is in process. If anybody is having any idea which API/library will be a best suit for large html files. Possible duplicate of Render HTML to PDF in Django site – Ajay Singh Jun 29 at 10:49 I've already used pisa but it takes around 5 minutes in conversion – Sachin Ch...

Sed with Regexp not working?

Sed with Regexp not working? I'm trying to search in all files a text and replace it with the word EXAMPLE. I do the following: for f in /home/testu/zz*; do sed -i "s/&VAR1s*=s*'?[1]{4}'?/EXAMPLE/g" "$f" done It gives no error, the files seems to be "updated" in the filesystem, but they wont get changed. If I test that regexp with grep command it works fine, so it must be something about the regexp with the sed command but dunno what. Any help? Are you aware that [1]{4} matches 1111 ? Is that your intention? – Wiktor Stribiżew Jun 29 at 8:14 [1]{4} 1111 Ah, use sed -i "s/&VAR1s*=s*'?1{4}'?/EXAMPLE/g" or sed -i "s/&VAR1[[:blank:]]*=[[:blank:]]*'?1{4}'?/EXAMPLE/g" – Wiktor...