![]() " File \"/var/lang/lib/python3.8/subprocess. from django.template import Context, Template import pdfkit templatefolder 'media' context'mediafolder' os.path.abspath(templatefolder) templatefile os.path.join(templatefolder, 'template.html') with open( templatefile, 'r') as f: template Template(f. " File \"/var/lang/lib/python3.8/subprocess.py\", line 854, in _init_\n self._execute_child(args, executable, preexec_fn, close_fds,\n", Though, I am using Django in Docker and the following is working for me just great: Python. " File \"/var/task/pdfkit/configuration.py\", line 17, in _init_\n self.wkhtmltopdf = subprocess.Popen(\n", ![]() " File \"/var/task/pdfkit/pdfkit.py\", line 42, in _init_\n nfiguration = (Configuration() if configuration is None\n", " File \"/var/task/pdfkit/api.py\", line 69, in from_string\n r = PDFKit(input, 'string', options=options, toc=toc, cover=cover, css=css,\n", " File \"/var/task/invoice_api.py\", line 161, in generate_pdf_2\n om_string(html_body, local_file_path)\n", " File \"/var/task/invoice_api.py\", line 49, in lambda_handler\n generate_pdf_2()\n", "errorMessage": " No such file or directory: 'which'", S3_file(local_file_path, bucket_name, writeFileName) om_string(html_body, local_file_path) # <- Getting error here Print('Step 1: ' + local_file_path, html_body) ![]() Local_file_path = '/tmp/local_pdf_file.pdf' I also tried to create a txt file in /tmp to make sure I have access and it was successfully able to create a file and from there upload to S3. The same piece of code works on my local machine with the local path. Also, the gem ‘wkhtmltopdf-binary’ for mac + linux i386 OS. ii) Install it to this directory C:\wkhtmltopdf to avoid permission issue of the app when integrating it to PDF KIT. I have created a deployment package using pdfkit but while converting to pdf, getting error " No such file or directory: 'which'". i) Download wkhtmltopdf-0.9.9-installer.exe. # return True on success and False on errorsĬonvert_html_to_pdf(str(filename_out+'.html'),str(filename_out+'.I am trying to convert the HTML file to pdf and upload it in S3 using Python 3.8 and lambda. Result_file = open(output_filename, "w+b")ĭest=result_file) # file handle to recieve result But 'which' is not available on the container running Lambda. It seems to have inherited the default behaviour of wkhtmltopdf in recent versions, which now blocks local file access unless otherwise specified. The issue is that unless it is preconfigured pdfkit is trying to call the 'which' command to figure out where the wkhtmltopdf binary is. # open output file for writing (truncated binary) Python - pdfkit- Warning: Blocked access to file, Pdfkit is a python wrapper for wkhtmltopdf. This is the code for converting to pdf def convert_html_to_pdf(source_html, output_filename): Output_file(filename_out+'.html', title = 'CMM Scan', mode = 'inline') Layout = column(Div(text = str(filename.replace('_', ' '))),Div(text = 'Absolute Warpage = ' + str(warpage)),l1,l2) When the pdfkit library was installed in the pythonanywhere environment. ![]() which confirms that if I want to invoke the interpreter of python version 3.8 I should execute the command python3.8. Surface3 = Surface3d3(x="x", y="y", z="z", data_source=source, width=600, height=600) Running the python3 command from the pythonanywhere bash console confirms that the version of the python interpreter is 3.7.5. This is the html file generation: source = ColumnDataSource(data=dict(x=xx, y=yy, z=val)) I have looked at all the other solutions online but none of those seem to work. I tried PyQt to generate the pdfs and it worked fine but had issues with being converted to an executable and pdfcrowd worked too but it is a paid library. I am trying to convert the html file into pdf using xhtml2pdf but the images on the html file dont show up on the pdf with xhtml2pdf or pdfkit. I have an interactive html file generated using Bokeh.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |