How to save plots in Bokeh JS as PNG programmatically?
The documentation gives the following example in Python:
from bokeh.io import export_png
export_png(plot, filename="plot.png")
I could however not find an example on how to programmatically save plots in JavaScript.
The use case is to generate plots in the back-end and use them in automatically generated reports.
Any tips on saving plots in Bokeh JS programmatically are welcome!
Related
I am using Jinja Template and WeasyPrint for PDF generation.
While calling a API, I have prepared the data in the back-end and export that data into PDF file.
I want include chart(Column Chart/Bar Chart) in the pdf file. I don't know how to include chart while exporting PDF. Because the data preparation and export everything should be happened in Back-end with single API.
Thanks in Advance.
I am trying to make a pdf viewer in HTML template using pdf.js in Django framework.
I had used a code that I got from a Youtube channel Traversy Media on how to create a custom PDF Viewer With JavaScript. It is working but I want to know if it's possible to render all pages at once.
Here's the link of the pdf.js full code in GitHub...
Is there an alternative way rather than sticking to this code?
I am currently building a ticketing page using Django. I now have to find the 'best way' to generate a PDF ticket, which ticket buyers can download from our Server.
I looked into different ways and apps including ReportLab in the official documentation. The ticket will include personal information and I am also planning to include a Bar/QR code on the ticket. The question I am struggling with, is which of the available apps is for my purpose the best option. From my first understanding, ReportLab might not be the best solution and I might better generate the ticket from a HTML page.
Before I now dig deeper in documentations I wanted to ask you guys if you have some experience with my objective and can give me some recommendations?
In my case I've used wkhtmltopdf and pdfkit.
Read: https://learnbatta.com/blog/django-html-to-pdf-using-pdfkit-and-wkhtmltopdf-5/
If you want to generate pdf from an HTML page I would suggest you use PhantomJS for this.
Open URL in a subprocess using PhantomJS and direct output to the STDOUT:
import subprocess
proc = subprocess.Popen(
['phantomjs', 'rasterize.js', url, '/dev/stdout'],
stdout=subprocess.PIPE
)
Then create pdf from the STDOUT output:
import io
from PIL import Image
from tempfile import TemporaryFile
with TemporaryFile() as temp_pdf:
img = Image.open(io.BytesIO(proc.stdout.read()))
if img.mode == 'RGBA':
img = img.convert('RGB')
img.save(temp_pdf, "PDF", quality=100)
I need to create in Django sophisticated pdf documents that will be populated with some variable fields.
I am already generating simple pdfs
reportlab.pdfgen import canvas
but customer requires pdfs where pdf is assembled from several text blocks and not simple row based.
Is there easy way to do it?
I have a donut chart (highcharts). By default, I can click on the export button to download the chart as image or other format. What I want to do is not download it. Save it somewhere and include it in the pdf export.
For example, say i have a donut chart which shows the expenses of a farm. I also have a tabular view of the same data. Right now what I can do is export the table as pdf/csv in django. I want to include the highchart as well in the pdf report. Is that possible? And how?
This feature is not build-in in our exporting, but you have two abilities:
setup your own exporting server and develop save file on your webserver
use highcharts cloud
Use a solution like this here which you can combine text, svg chart, tables, barcodes, whatever yku desire to PDF output
http://www.cloudformatter.com/CSS2Pdf
There are samples of all if this including highcharts shown on the pages.