enteredData = { "email": email, "country": country, "name": name, "street": street, "city": city } #Create new Datasource object dataSource = Datasource array = [] #Create DataSourceField object and filing it with entered data for key, data in enteredData.iteritems(): value = [data] field = DatasourceField() field.name = key field.type = "text" field.values = value array.append(field) #Set DataSourceField object to the fields parameter of the DataSource object dataSource.fields = array try: #Add DataSource to GroupDocs addDataSource = mergeApi.AddDataSource(clientId, dataSource) #Check status if addDataSource.status == "Ok": try: #Merge DataSource with documnet and convert it to PDF job = mergeApi.MergeDatasource( clientId, guid, addDataSource.result.datasource_id,
enteredData = { "sex": sex, "age": age, "sunrise": sunrise, "name": name } #Create Datasource object dataSource = Datasource #Create empty list fieldsList = [] #Create DatasourceField object and set data to it for fieldName, fieldContent in enteredData.iteritems(): value = [fieldContent] dataFieled = DatasourceField() dataFieled.name = fieldName dataFieled.type = "text" dataFieled.values = value fieldsList.append(dataFieled) #Set Datasource fileds dataSource.fields = fieldsList try: #Add new Datasource to GroupDocs add = merg.AddDataSource(clientId, dataSource) try: #Merge new Datasource to document and convert document to pdf merge = merg.MergeDatasource(clientId, fileGuId, add.result.datasource_id, targetType=resultType)
elif field.type == "Checkbox": type = "boolean" fieldContent = True value = [fieldContent] elif field.type == "Listbox": type = "Integer" value = [str(fieldContent)] elif field.type == "Combobox": type = "Integer" value = [str(fieldContent)] else: type = "text" value = [str(fieldContent)] dataField = DatasourceField() dataField.name = fieldName dataField.type = type dataField.values = value fieldsList.append(dataField) #Set Datasource fields dataSource.fields = fieldsList #Add new Datasource to GroupDocs add = merge.AddDataSource(clientId, dataSource) #Merge new Datasource to document and convert document to pdf merge = merge.MergeDatasource(clientId, fileGuid, add.result.datasource_id, targetType="pdf") jobInfo = None #Check job status for i in range(5): time.sleep(5) #Get job info jobInfo = async.GetJobDocuments(clientId, merge.result.job_id) #If status Completed or Archived break loop
dict(error=str(e), url1='')) try: #Set second user name. Can be obtained in the same manner as first signer name. secondName = firstName + "2" #Create array with merge data enteredData = dict(gender=gender, name=firstName) #Create Datasource object dataSource = Datasource #Create empty list fieldsList = [] #Create DatasourceField object and set data to it for fieldName, fieldContent in enteredData.iteritems(): value = [fieldContent] dataField = DatasourceField() dataField.name = fieldName dataField.type = "text" dataField.values = value fieldsList.append(dataField) #Set Datasource fields dataSource.fields = fieldsList #Add new Datasource to GroupDocs add = merge.AddDataSource(clientId, dataSource) #Merge new Datasource to document and convert document to pdf merge = merge.MergeDatasource(clientId, fileGuId, add.result.datasource_id, targetType="pdf") jobInfo = None #Check job status for i in range(5): time.sleep(5) #Get job info jobInfo = async.GetJobDocuments(clientId, merge.result.job_id) #If status Completed or Archived break loop
#If user choose file from GroupDocs if fileId != "": fileGuId = fileId try: enteredData = {"sex" : sex, "age" : age, "sunrise" : sunrise, "name" : name} #Create Datasource object dataSource = Datasource #Create empty list fieldsList = [] #Create DatasourceField object and set data to it for fieldName, fieldContent in enteredData.iteritems(): value = [fieldContent] dataFieled = DatasourceField() dataFieled.name = fieldName dataFieled.type = "text" dataFieled.values = value fieldsList.append(dataFieled) #Set Datasource fileds dataSource.fields = fieldsList try: #Add new Datasource to GroupDocs add = merg.AddDataSource(clientId, dataSource) try: #Merge new Datasource to document and convert document to pdf merge = merg.MergeDatasource(clientId, fileGuId, add.result.datasource_id, targetType = resultType) i = 0 counter = 5
signature.basePath = basePath docApi.basePath = basePath mergeApi.basePath = basePath asyncApi.basePath = basePath guid = templateGuid #Create list with entered data enteredData = {"email": email, "country": country, "name": name, "street": street, "city": city} #Create new Datasource object dataSource = Datasource array = [] #Create DataSourceField object and filing it with entered data for key, data in enteredData.iteritems(): value = [data] field = DatasourceField() field.name = key field.type = "text" field.values = value array.append(field) #Set DataSourceField object to the fields parameter of the DataSource object dataSource.fields = array try: #Add DataSource to GroupDocs addDataSource = mergeApi.AddDataSource(clientId, dataSource) #Check status if addDataSource.status != "Ok": raise Exception(addDataSource.error_message) #Merge DataSource with document and convert it to PDF job = mergeApi.MergeDatasource(clientId, guid, addDataSource.result.datasource_id, targetType="pdf") if job.status != "Ok": raise Exception(job.error_message)