Change Line Height of Google Doc through Google Drive API - api

I cannot figure out how to change the document formatting options through the Google Drive API. Is this not supported? As of now I am uploading a file but Google is making the line height 1.15, but I want it to be Single (or 1).

Google Drive doesn't provide fine-grained controls to alter Google Docs, Sheets, etc. You can import files in other formats and convert them to Google formats, but you can't manipulate individual properties of the resulting files, including line height.

Related

Fetch a certain page of a pdf as an image from google drive

I have some 10,000 pages of hand-written scanned documents in google drive in somewhere around 70 pdf documents.
I am making a spreadsheet index of these, with one row for each page where I make notes of what is on each page, by actually viewing those pages, reading it, and every fully typing it if required.
I need a link, which I can put in the spreadsheet, which when clicked opens up a certain page of the pdf as an image only, and not the entire pdf, the pdf is in google drive. Is there something like this possible in Google Drive? Or should I manually download all pdf, split it into images, and then re-upload and use that?
(example - java -jar pdfbox-app.jar PDFToImage -format jpg -quality 0.75 pdffile.pdf ; and then upload all this)
I have a feeling it must be possible because when we open the pdf in browser, it loads pdf pages one by one, it takes time but it opens it in some custom image+text format, so it must be exported. Also I know there is one image version for each google slide and link is stable, so there might be something for pdf also I was thinking.
There isn’t a parameter or feature to link a pdf page in Google Drive file viewer.
Indeed as mentioned, you can link to a specific slide in Google Slides, however Google file types do have additional features.
That’s not the case for PDFs for example. A workaround I can think of would be to create a comment for each page and each comment will have its own id.
After creating the comment, you can click on the three vertical dots icon and click on Link to this comment.
Alternatively, you can send feedback to Google (On file viewer page, click on three vertical dots icon and then Send feedback to Google) making sure to describe the proposed feature.

Update an existing PDF

I have an existing PDF template, and I want to add some text over the top of it in a specific location on a specific page. For example, an invoice template or a scanned document.
How would I go about this? I'm using Sheets if that narrows my options.
There is a lot of documentation on how to create PDFs from documents, but nothing that will take a particular PDF and put text over it.
A bit of blue sky thinking from my side. What if you were to do the following?
Manually:
Export the PDF as an image
Resize a Google slide to be the same shape as the image
Add the image to the google slide as a background image
In Code:
Make a copy of the google slide as needed
Add your Google sheets data to the slide positioned as needed on the slide
Export the Google slide as a pdf
I mention google slides, because Google docs to not have allow background images.
Another possibility with using Google docs is to build a document that looks like your invoice, then add to it tags. In your code search for the tags and replace them with data from your sheet. Even you could use a mail merge addon to do this if you didn't fancy writing any code.
In your Google Drive right-click on your PDF;
Open With > Connect More Apps > Search docusign > Left-click blue connect button and this should take you to Docusign.
Your PDF will then open with Docusign where you can manually add a signature or text to specific places.
Alternatively... You can use App Script.
Example,
Constructing a document using HTML and replacing the specific value with a variable which is collect from a Sheet or particular location. Writing the function to do this will allow you to interpret the HTML and replace the variable with the text or possibly an image. Then it would create this as a PDF.
There are many alternative ways to do this.
Here is one example on github;
Convert Google Doc to PDF using App Script

Export Google Sheet to PDF Programmatically with Custom Parameters

How do you export an entire Google Sheet to PDF in Landscape with fit to width, grid lines, page numbers, and spreadsheet name but not sheet name?
How about exporting the same as above but only 1 specific sheet in the spreadsheet or specific range within a sheet?
I can do all this through the GUI when exporting from a Google Sheet but no documented way via API.
I have found various sources showing how to do this via URL but have been unable to find any documentation by Google. The parameters used are not consist between sources and have been unable to figure out all the parameters available through the GUI.
How were the parameters determined? Is this documented by Google? Is this possible via API?
URL exporting sources:
https://issuetracker.google.com/issues/36761058#c25
Google Apps Script - Add landscape parameter to PDF email attachment

How to force Google CSE to search just uploaded PDF file

I am using free Google custom search engine in my website to search mostly PDF and HTML files. It works pretty much well, however it doesn't search PDF file just uploaded. Is it due to that Google bot needs sometime to crawl? Is there anyway we can allow to search instantly?
The website is : http://benchmarkinc.com.au/
Do you need it to automatically index newly uploaded PDFs or are you able to manually add those PDFs to the CSE after they've been uploaded?
You can add specific files to your index from the CSE control panel -> Admin - Indexing tab and then add the URLs for the PDFs you want Google to index.
Apparently, it takes up to 24 hours for Google to index the PDF.

Google Script for PDF image/screenshot import into Google Doc

I'm trying to write a script that takes images from a PDF file and puts them into a Google Doc Template. The PDF has a bunch of images in it, one image per page. What I want to do is grab the images one at a time (or take a screenshot of the entire page) and paste it into a new document. How can I access a single image at a time to import it into the google doc?
Thanks.
There is probably no way to play directly with a pdf file but you should consider to first convert these pdf to google docs and, in a second time, use the document class that can retrieve images inside the doc quite easily...