Free Support Forum - groupdocs.com

Conversion from PDF to HTML through api

Hi Team,

We are trying to convert PDF to HTML through API by first uploading and then converting and downloading. By checking the API logs we are able to see the conversion is showing success. But our code is throwing 500 API error. Basically, the download call is not happening. For small files, less than 2MB the code is working fine. But above that files, we are having the issue. If you can help with our application exact logs , we can analyse more.

@ans12

Are you implementing/evaluating our Cloud API? Could you please share more details on the API variant (e.g. Java, PHP, .NET)?

We are using python .
Our code for instantiating , uploading, and downloading -:

@classmethod  
def GetConfig(cls):
    configuration = groupdocs_conversion_cloud.Configuration(cls.client_id, cls.client_secret)
    configuration.api_base_url = "https://api.groupdocs.cloud"
    return configuration    

@classmethod  
def UploadSampleFiles(cls,foldername,filename):
    # api initialization
    storageApi = groupdocs_conversion_cloud.StorageApi.from_config(cls.GetConfig())
    fileApi = groupdocs_conversion_cloud.FileApi.from_config(cls.GetConfig())
    # upload sample files
    print('upoadin filee    ',filename)
    destFile = filename.replace(foldername+"\\", "", 1)            
    fileExistsResponse = storageApi.object_exists(groupdocs_conversion_cloud.ObjectExistsRequest(destFile))
    if not fileExistsResponse.exists:                                
        fileApi.upload_file(groupdocs_conversion_cloud.UploadFileRequest(destFile, filename))
        print("Uploaded file: "+ destFile)

@classmethod
def DownloadFiles(cls,dir,html_file_name,filepath):
# Create instance of the API
    # api initialization
    storageApi = groupdocs_conversion_cloud.StorageApi.from_config(cls.GetConfig())
    fileApi = groupdocs_conversion_cloud.FileApi.from_config(cls.GetConfig())
    try:
        request = groupdocs_conversion_cloud.DownloadFileRequest(filepath, "demo")
        response = fileApi.download_file(request)
        print("Expected response type is Stream: " , type(response),"    ",type(request),"     ",response,"   ",request)
        # #filename.write_bytes(response.content)
        print(os.path.join(dir,html_file_name))
        copyfile(str(response), os.path.join(dir,html_file_name))
    except groupdocs_conversion_cloud.ApiException as e:
        print("Exception while calling API: {0}".format(e.message))

For conversion-:

class ConvertToHtml:

@classmethod  

def Run(cls,filepath):

    # Create necessary API instances

    apiInstance = groupdocs_conversion_cloud.ConvertApi.from_config(Common.GetConfig())

    

    # Prepare convert settings

    settings = groupdocs_conversion_cloud.ConvertSettings()

    settings.file_path = filepath

    settings.format = "html"

    convertOptions = groupdocs_conversion_cloud.HtmlConvertOptions() 

  

    settings.convert_options = convertOptions       

    settings.output_path = 'demo'

    # Convert

    result = apiInstance.convert_document(groupdocs_conversion_cloud.ConvertDocumentRequest(settings))

    print("Document converted: " + result[0].url)

@ans11

This issue is already logged and under investigation. Please refer to this thread.