Is it possible to fill in PDF forms through Google Script? Or add text on PDF through Google Script on the cloud? - excel

Now basically all our jobs are deployed on Google Suites and triggered through Google Script, so what we want is that we can add this function - filling in the PDF forms - using Google Script as well.
Before what we are trying to do was to design a PDF-like template using Google Sheet and by looping, updating the blank information of the form, and finally saving the result as PDF, we will have the result that we want.
However in this time, the PDF is not that easy to imitate in Google Sheet. It is from the government and thus it is better to keep their format and simply fill in the PDF form.
Actually, we've tried to use the Excel VBA or Python on the hard drive to do and it is pretty simple task to finish. But the problem would be wasting time to switch between platforms and it is not a good solution to deploy everything on the Cloud.
So we are wondering if there is a way to 1) filling PDF forms through Google Script? 2) Or add text on PDF through Google Script on the cloud? 3) Or do it on the cloud in general?

Google Apps Script does not have a native way to programatically fill in an existing PDF.
You'll have to find some 3rd party service/API, or a JavaScript library, that lets you programatically fill in an existing PDF and then you can call it or use it in GAS.

Related

Access worksheet names from Excel file with Google Apps Script (without Drive.Files.insert)

In a Google App Script attached to a Google Sheet, I have the file ID of an excel file. I want to read the worksheet names of that excel file. The tutorials I've seen on conversion load the excel file as a blob then write it to Drive as a Google Sheet, then read it.
Is there a way to do this that does not to create artifacts that I then need to delete? The reasoning is that I am concerned with the following: safety if there's a bug (the wrong thing gets deleted), additional processing time (I need to process a long list of excel files), and leftover artifacts if the script aborts unexpectedly between inserting and deleting.
Thank you!
Answering your questions, the reason the tutorials first convert the Excel file to a Google Sheet is to interact with it (in your case, to gather the worksheet names) it's because the Google APIs or Apps Script cannot interact with the Excel file as row data, and Google needs to convert the file to something readable using Google APIs.
A workaround for this will be to use Excel JavaScript API to read the information original Excel file, you can use externals API in Apps Script since it's based in JavaScript, so you will use Apps Script as an IDE.
However, you can do the same with any other IDE that works with JavaScript.
There are some examples on how to list the worksheets using the Excel JavaScript API in this blog.
If you will like to keep using Google APIs, and using the Google Apps Script built-in services. You will need to convert the file to Google Sheets.
Updating Answer:
You can review more about the Excel Services API services here.

Creating a website with functionalities as given below:

VenEx wants to create an Interactive tool on WIX or any other no code web platform. We would like users to input 6 params on the website, connect the website to an Excel spreadsheet that does the calculation & displays graphs/output back on the website. Pls. Advise
The proper way to do this in Wix would be to use Velo, which requires a bit of coding. But, you won't need to use the spreadsheet because you can write the calculation logic into the site itself.

Is there a way to visualize Chart by its spec obtained from Sheets API using Node.js?

I use Google Sheets API from googleapis to get a spreadsheet and its charts. So I have ChartSpec. How can be this spec used to visualize the chart in a web application, e.g. using Visualization API?
Use case
A simple web app written in HTML and JS which shows all charts from an arbitrary spreadsheet. In the ideal scenario, the charts are rendered just like in spreadsheets, so I can see the charts without the necessity to open a spreadsheet manually.
A user selects a spreadsheet from a list of predefined spreadsheets (menu)
Web app requests up-to-date data for the selected spreadsheet from Node.js backend
Node.js app gets all charts in the spreadsheet using Google Sheets API
Node.js app responds with necessary data
Web app visualizes the charts that should ideally be interactive (eg. using Visualization API)
Problem
I have a trouble with steps 4 and 5. In step 3 I receive ChartSpec which seems to contain all information but data. Instead of data, there are just references to ranges in a form of ChartData object.
Creating a custom implementation which gets all referenced data seems extremely complicated. Even if I created it on my own, I do not know how to create visualizations in step 5.
What I found and why it is not solution for me? There are similar questions and solutions that use Visualization API to query data from a spreadsheet and the visualize it, such as this answer. Why is this not solution for me? Because my spreadsheets are created by non-tech people who do not follow any good practices, so data cannot be easily queried using Query API. The spreadsheets are a mess. The charts are created by the same folks and they want to customize it by themselves. What I need is to show already existing charts without necessity to make any chart-wise code.
The only solution I came up with so far is to use the Chart Editor and allow the user to set up the chart himself. I would be interested in investing in such a solution or working on it together.

Writing to Google Docs Spreadsheets using Apps Script

I'm trying to integrate Apps Script into my website's (not a Google Site) order page so that a user's order can be written to a Google Doc spreadsheet. I don't know how to go about this because the Apps Script documentation says Apps Script can only be developed and embedded in Google Sites Pages. Is there a way I can achieve this even though my site isn't a Google Site?
I'll appreciate any help at all very much, thanks in advance.
You can write a regular HTML form (not in Apps Script) and set method='post' action='the script url'. That will invoke your script with the data from the form passed into the doGet as parameters.
You can create a data capture spreadsheet, and create a Form for it. You can "clone" the form (field names and form action) into your web site.
Your spreadsheet can have an onFormSubmit action (https://developers.google.com/apps-script/understanding_events) which does whatever you need with the submitted data.

Preview Excel, Word, PDF in Web browser

Except for Google docs is there any technology that will allow me to provide a preview for Excel, Word, PDF from within the browser without having to download & installing anything new (of course I excpect they have at least those porgrams running on their computer)
You can save the files as HTML in Word/Excel. I am pretty sure Acrobat lets you do this with PDF too. You could also automate this process using VBA with Office docs.

Resources