我正在使用Google App Script编写合同申请。
它会从模板中创建一个GoogleDoc,其中包含卖家签名和首字母的图像。
由于有五个卖家和十几个不同的模板,有没有办法改变签名和首字母的形象?
我没有线索从哪里开始寻找。
谢谢,祝你有愉快的一天!
答案 0 :(得分:0)
这是一个在Google文档中附加图片的小代码。希望这会给你一个开始的想法。 类似的概念我曾经用resume builder应用程序替换了个人资料图片和签名图片
//Make a UI form to upload Image
function doGet() {
var app = UiApp.createApplication();
//Form
var form = app.createFormPanel().setEncoding('multipart/form-data').setId('form');
//Add this form to the application
app.add(form);
//Panel to hold form elements
var panel = app.createVerticalPanel();
//add this panel inside form
form.add(panel);
//Now create form elemnts
var label1 = app.createLabel('Upload Image');
var uploadControl = app.createFileUpload().setName('file').setId('file');
var submitBtn = app.createSubmitButton('Submit');
//Add all these elemnts to the panel
panel.add(label1).add(uploadControl).add(submitBtn);
//Return the application to the service URL
return app;
}
//This function is callend when the form is submitted
function doPost(e){
var fileBlob = e.parameter.file; //This is the image blob if an image is uploded
//Open the document
var doc = DocumentApp.openById('ID OF GOOGLE DOC')//change Id of the document
//get the body of document
var docBody = doc.getActiveSection();
//Append the iamge in document body
docBody.appendImage(fileBlob);
//Save and close the document
doc.saveAndClose();
}