API to export sheet that contains only a chart as a PDF or image - google-sheets-api

I was wondering if there is any API Call that can perform such operation (export sheet that contains only a chart as a PDF or image).
Firstly i was trying to export a chart from a sheet directly but i found out this is not possible via an API Call.

This is not possible to achieve with Sheets API. These are the interactions with charts that are available in the Sheets API.
With the Drive API, you can export a spreadsheet as a PDF in one line of code making use of the export() method (you can read more about it here). However, this will export the whole spreadsheet and not just the chart (most notably, the grid lines will be visible).
I would say that the best way to export just the chart is using Apps Script. It cannot be "directly" done here, as charts can only be fetched from a spreadsheet as images. Therefore, you then have to transform said image into a pdf. This can be accomplished in two ways: you can either create a blank pdf and append the image, or you can paste the image into a docs (or slides) file and save that docs file as a pdf.
Here I have opted for the second one:
function myFunction(){
var fileId = "YOUR_SPREADSHEET_ID";
var folderId = "YOUR_FOLDER_ID";
var chart = SpreadsheetApp.openById(fileId).getSheetByName("Sheet1").getCharts()[0];
var tempDocs = DocumentApp.create("temp");
tempDocs.getBody().appendImage(chart.getBlob());
tempDocs.saveAndClose();
docblob = DocumentApp.openById(tempDocs.getId()).getAs('application/pdf');
docblob.setName("myName");
DriveApp.getFolderById(folderId).createFile(docblob);
DriveApp.getFileById(tempDocs.getId()).setTrashed(true);
}
Having said that, you can also "brute force" export the entire spreadsheet as a pdf. You can achieve this by using the Drive API - Files - Export function. Note that this method belongs to the Drive API, not the Sheets API.

Related

How to export "extra variant media" from odoo website module

I dont see any way to export those extra images. what is the id of those images, i would prefer to use an api to scrape the images

Web APIs FileReader() hide download option

I've successfully integrated the FileReader() that renders a file from a BLOB so the user can view and interact with it, however the revised criteria states that the user shouldn't be allowed to download the document now.
The requirement is that the download icon is removed from the FileReader() but I can't seem to find a way of doing this, as it's baked into the actual Web API.
I started to write my own PDF viewer using a basic Vue to PDF package and adding custom controls but this is a bit of a monster and I'd like to avoid a complete re-write to remove one action.
Is there any way of removing the download CTA before it renders the PDF?
More context..
The PDF is rendered in the DOM from a BLOB that's passed via an end point I hook into with Axios. I then readAsDataURL(blob) and finally create the FileReader() result as a URL.createObjectURL(blob) to give me the data that I render as the canvas src to enable the PDF viewer. Unfortunately this can't be a PNG as it needs multi pages. Thee issue is that it's sensitive docs that can only be viewed on the portal, so it's to prevent users from easily downloading (aware they could just print screen).

JS API for embedding sheet in Qlik

We can embed visuals of a sheet very easily, with:
const vis = await qlikApp.visualization.get('<visual_id>');
vis.show('<visual_container>'); // Renders visual in the given HTML container
But, I could not find any such API for embedding Qlik sheet.
In the docs, I only found embedding sheet by copy pasting iframe
I don't think its possible to embed the whole sheet using the Visualization API. This API is targeting specifically visualizations (charts, tables etc.)
The only option I'm aware of is the iFrame (aka Single Interation API)
Seems that someone tried to "emulate" Qlik Sense sheet here. But it looks like this will display only the sheet objects (no selections bar for example).

Highcharts - Export Multiple Charts to Multi Page PDF File

We are using Highcharts for our charting application. We are displaying 16 bar charts on a webpage. We need to provide exporting feature (a button) through which all charts on the page get exported to a PDF file.
We have implemented it using the hack suggested on the Highcharts website. http://www.highcharts.com/docs/getting-started/frequently-asked-questions#export-multiplesamples/highcharts/exporting/multiple-charts/.
However,when we export it, all 16 charts are coming on a single page in pdf. We want page breaks so that 4 charts can be shown on each page.
Is there any way we can achieve this ? Please help.
Any help will be appreciated.
Thank you.

Utilities for exporting/printing graphs?

given that the functionality for exporting graphs to SVG or PNG in the Neo4j server page is broken (see SO article), are there any utilities out there that can export a graph from Neo? something that would produce a PDF perhaps?
With not many changes, you could make it work with http://www.cloudformatter.com/CSS2Pdf to format the SVGs in browser to PDF. That set of pages has some d3 samples like this: http://www.cloudformatter.com/CSS2Pdf.SVGCharts.d3Charts
I took one of the sample charts and rendered to PDF through the Javascript and the remote formatter. The page I selected was here and I took one of those charts:
http://graphgist.neo4j.com/#!/gists/1428842b2170702400451777c2bc813f
The code needs some minor change to ensure that Neo4j puts the svg namespace on the element. The samples on that page do not. But the rendering is near perfect. See the web page on the right and PDF result on the left. I only formatted the SVG and not the whole page (where the silver background exists) and that seems to be the only difference.