Is it possible to replace text within a pdf file using Google Apps Script?
I am trying the following code without success on the replace, it seems like the string is encoded in a way I cannot understand.
var pdfFile = DocsList.getFileById("pdf-doc-id");
var asBlob = pdfFile.getBlob();
var asString = asBlob.getDataAsString();
var s2s = "old string";
var s2r = "new string";
var repString = asString.replace(s2s, s2r);
var repBlob = Utilities.newBlob(repString).setContentType("application/pdf").setName("Testing");
DocsList.createFile(repBlob);
EDIT1: I got an empty pdf back
Any ideas?
Thanks