-2

I tried using this code but did not work

This code is from https://stackoverflow.com/a/63664501 written by @Tanaike

function myFunction() {
  const fileId = "###";  // Please set the file ID.

  const url = "https://www.googleapis.com/drive/v3/files/" + fileId;
  const res = UrlFetchApp.fetch(url, {
    method: "patch",
    headers: {authorization: "Bearer " + ScriptApp.getOAuthToken()},
    contentType: "application/json",
    payload: JSON.stringify({ writersCanShare: false, copyRequiresWriterPermission: false}),
  });
  console.log(res.getContentText())
  
  // DriveApp.createFile(blob)  // This comment line is used for automatically detecting the scope of "https://www.googleapis.com/auth/drive"
}

This disables all the features including print as well. If this is not possible can we use the google app script to print the iframe content only from a pdf file?

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57
Bkezh
  • 1
  • 1

2 Answers2

2

The functionality built-in to Docs only allows turning off all copying (including printing) — it's not possible to only turn off copying but allow printing, for example.

Depending on what you're trying to do, you might want to use Apps Script to access and print (or email a copy-protected PDF to) users somehow, rather than letting them access it directly.

Ian Hyzy
  • 481
  • 5
  • 26
-1

When a PDF file is in a browser it is viewer editable, since it is dispositioned from Public Domain to the Users Domain. In effect file ownership is transferred by Hyper Text Transport. It is the same for ALL HTML pages. Legally you may grumble a World Wide Web should be private or protect privacy but it does not. Even if you layer the outside of a PDF with a password once it is fit to view it is fit to modify. A browser is a WorldWideWord Processor.

enter image description here enter image description here

K J
  • 8,045
  • 3
  • 14
  • 36