def Run(cls):
        # Create necessary API instances
        apiInstance = groupdocs_conversion_cloud.ConvertApi.from_config(
            Common.GetConfig())

        # Prepare convert settings
        settings = groupdocs_conversion_cloud.ConvertSettings()
        settings.file_path = "WordProcessing/four-pages.docx"
        settings.format = "pdf"
        settings.convert_options = groupdocs_conversion_cloud.PdfConvertOptions(
        )

        watermark = groupdocs_conversion_cloud.WatermarkOptions()
        watermark.text = "Sample watermark"
        watermark.color = "Red"
        watermark.width = 100
        watermark.height = 100
        watermark.background = True

        settings.watermark_options = watermark
        settings.output_path = "converted"

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

        print("Document converted: " + result[0].url)
    def Run(self):
        # Create instance of the API
        api = Common_Utilities.Get_ConvertApi_Instance()

        try:
            settings = groupdocs_conversion_cloud.ConvertSettings()
            settings.storage_name = Common_Utilities.myStorage
            settings.file_path = "conversions\\password-protected.docx"
            settings.format = "jpeg"

            loadOptions = groupdocs_conversion_cloud.DocxLoadOptions()
            loadOptions.password = "******"

            settings.load_options = loadOptions

            convertOptions = groupdocs_conversion_cloud.PdfConvertOptions()
            convertOptions.bookmarks_outline_level = 1
            convertOptions.center_window = True
            convertOptions.compress_images = False
            convertOptions.display_doc_title = True
            convertOptions.dpi = 1024
            convertOptions.expanded_outline_levels = 1
            convertOptions.fit_window = False
            convertOptions.from_page = 1
            convertOptions.pages_count = 1
            convertOptions.grayscale = True
            convertOptions.headings_outline_levels = 1
            convertOptions.image_quality = 100
            convertOptions.linearize = False
            convertOptions.margin_top = 5
            convertOptions.margin_left = 5
            convertOptions.password = "******"
            convertOptions.unembed_fonts = True
            convertOptions.remove_unused_streams = True
            convertOptions.remove_unused_objects = True
            convertOptions.remove_pdfa_compliance = False
            convertOptions.height = 1024

            settings.convert_options = convertOptions
            settings.output_path = "converted\\topdf"

            request = groupdocs_conversion_cloud.ConvertDocumentRequest(
                settings)
            response = api.convert_document(request)

            print("Document converted successfully: " + str(response))
        except groupdocs_conversion_cloud.ApiException as e:
            print("Exception while calling API: {0}".format(e.message))
コード例 #3
0
def doc2pdf(file, filename, output_file, output_name):
    request_upload = groupdocs_conversion_cloud.UploadFileRequest(
        file, filename)
    response_upload = file_api.upload_file(request_upload)
    # Create necessary API instances
    apiInstance = groupdocs_conversion_cloud.ConvertApi.from_keys(
        app_sid, app_key)

    # Prepare convert settings
    settings = groupdocs_conversion_cloud.ConvertSettings()
    settings.file_path = file
    settings.format = "pdf"

    load_options = groupdocs_conversion_cloud.DocxLoadOptions()
    load_options.password = "******"
    convert_options = groupdocs_conversion_cloud.PdfConvertOptions()
    convert_options.center_window = True
    convert_options.compress_images = False
    convert_options.display_doc_title = True
    convert_options.dpi = 1024.0
    convert_options.fit_window = False
    convert_options.from_page = 1
    convert_options.grayscale = False
    convert_options.image_quality = 100
    convert_options.linearize = False
    convert_options.margin_top = 5
    convert_options.margin_left = 5
    convert_options.unembed_fonts = True
    convert_options.remove_unused_streams = True
    convert_options.remove_unused_objects = True
    convert_options.remove_pdfa_compliance = False

    settings.load_options = load_options
    settings.convert_options = convert_options
    settings.output_path = "converted"
    result = apiInstance.convert_document(
        groupdocs_conversion_cloud.ConvertDocumentRequest(settings))
    request_download = groupdocs_conversion_cloud.DownloadFileRequest(
        f"converted/{output_name}")
    response_download = file_api.download_file(request_download)
    copyfile(response_download, f"{output_file}")
    # Convert
    return render_template("index.html", script=f'<script>x=null</script>')
    def Run(cls):
        # Create necessary API instances
        apiInstance = groupdocs_conversion_cloud.ConvertApi.from_config(Common.GetConfig())
        
        # Prepare convert settings
        settings = groupdocs_conversion_cloud.ConvertSettings()
        settings.file_path = "WordProcessing/four-pages.docx"
        settings.format = "pdf"
        convertOptions = groupdocs_conversion_cloud.PdfConvertOptions()
        convertOptions.from_page = 2
        convertOptions.pages_count = 2
        settings.convert_options = convertOptions
        settings.output_path = "converted/two-pages.pdf"

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

        print("Document converted: " + result[0].url)
        
コード例 #5
0
    def Run(cls):
        # Create necessary API instances
        apiInstance = groupdocs_conversion_cloud.ConvertApi.from_config(
            Common.GetConfig())

        # Prepare convert settings
        settings = groupdocs_conversion_cloud.ConvertSettings()
        settings.file_path = "WordProcessing/password-protected.docx"
        settings.format = "pdf"

        loadOptions = groupdocs_conversion_cloud.DocxLoadOptions()
        loadOptions.password = "******"
        convertOptions = groupdocs_conversion_cloud.PdfConvertOptions()
        convertOptions.center_window = True
        convertOptions.compress_images = False
        convertOptions.display_doc_title = True
        convertOptions.dpi = 1024.0
        convertOptions.fit_window = False
        convertOptions.from_page = 1
        convertOptions.grayscale = False
        convertOptions.image_quality = 100
        convertOptions.linearize = False
        convertOptions.margin_top = 5
        convertOptions.margin_left = 5
        convertOptions.password = "******"
        convertOptions.unembed_fonts = True
        convertOptions.remove_unused_streams = True
        convertOptions.remove_unused_objects = True
        convertOptions.remove_pdfa_compliance = False

        settings.load_options = loadOptions
        settings.convert_options = convertOptions
        settings.output_path = None  # set OutputPath as None will result the output as document file

        # Convert
        result = apiInstance.convert_document_download(
            groupdocs_conversion_cloud.ConvertDocumentRequest(settings))

        print("Document converted: " + result)