"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, targetType="pdf")
"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)
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 #Check job status
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 if jobInfo.result.job_status == "Completed" or jobInfo.result.job_status == "Archived":
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) #Time delay necessary for server side processing