2012-12-20 60 views
0

我正在编写Google App脚本中的合同应用程序。我们可以动态更改Google文档中的图片吗?

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

由于有5个卖方,和一打不同的模板,有没有办法改变签名和首字母缩写的形象?

我没有线索从哪里开始寻找。

谢谢,祝你有美好的一天!

  • 埃里克

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

回答

0

这里是一个小的代码,在谷歌文档附加的图像。希望这会给你想法开始。 类似的概念,我用来做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(); 
} 
+0

感谢您的答复。我会看看那是否能让我有所领悟。我可能可以循环浏览各个部分并找到图像所在的位置,然后更改它... – Saumier

相关问题