0

我正在用 Google App Script 编写合同应用程序。

它从包含卖家签名和姓名缩写图像的模板创建 GoogleDoc。

由于有五个卖家,以及十几个不同的模板,有没有办法改变签名和首字母的形象?

我不知道从哪里开始寻找。

感谢,并有一个愉快的一天!

  • 埃里克

编辑:我在 DocumentApp 中发现了一些关于 InlineImage 的内容......仍在寻找

4

1 回答 1

0

这是一个在 Google 文档中附加图像的小代码。希望这会给您带来前进的想法。类似的概念我曾经制作一个简历生成器应用程序,它替换了个人资料图片和签名图片

//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();
}
于 2012-12-20T15:32:44.107 回答