2012-12-20 61 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

相關問題