convert method
Leave feedback
On this page
Converts the source document and saves the entire converted document.
Learn more:
- More about document conversion basic scenarios: https://docs.groupdocs.com/display/conversionnet/Convert+document
- Conversion use cases, advanced settings and customizations: https://docs.groupdocs.com/display/conversionnet/Converting
def convert(self, target_stream_provider, convert_options):
...
| Parameter | Type | Description |
|---|---|---|
| target_stream_provider | Func[SaveContext, io.RawIOBase] |
Callable that receives a stream and saves the converted document to it. |
| convert_options | ConvertOptions |
Convert options specific to the desired target file type. |
from groupdocs.conversion import Converter
from groupdocs.conversion.options.convert import PdfConvertOptions
def convert_document_to_pdf():
# Instantiate Converter with the input document
with Converter("./business-plan.docx") as converter:
# Define conversion options for PDF output
pdf_options = PdfConvertOptions()
# Convert the document and save as PDF
converter.convert("./business-plan.pdf", pdf_options)
if __name__ == "__main__":
convert_document_to_pdf()
Converts the source document and saves the whole converted document.
Learn more:
- More about document conversion basic scenarios: How to convert document in 3 steps
- Conversion use cases, advanced settings and customizations: Convert document with advanced settings
def convert(self, convert_options, document_completed):
...
| Parameter | Type | Description |
|---|---|---|
| convert_options | ConvertOptions |
The convert options specific to desired target file type. |
| document_completed | Action[ConvertedContext] |
Delegate that receives the converted document stream. Signature: Action<ConvertedContext>. The ConvertedContext parameter contains the converted document stream and metadata. |
from groupdocs.conversion import Converter
from groupdocs.conversion.options.convert import PdfConvertOptions
with open("input.docx", "rb") as stream:
with Converter(stream) as converter:
converter.convert("output.pdf", PdfConvertOptions())
Converts the source document and saves the whole converted document.
Learn more:
- More about document conversion basic scenarios: https://docs.groupdocs.com/display/conversionnet/Convert+document
- Conversion use cases, advanced settings and customizations: https://docs.groupdocs.com/display/conversionnet/Converting
def convert(self, target_stream_provider, convert_options_provider):
...
| Parameter | Type | Description |
|---|---|---|
| target_stream_provider | Func[SaveContext, io.RawIOBase] |
Callable[[SaveContext], io.RawIOBase] that provides the stream to save the converted document. |
| convert_options_provider | Func[ConvertContext, ConvertOptions] |
Callable[[ConvertContext], GroupDocs.Conversion.ConvertOptions] that provides conversion options. |
Returns: None.
from groupdocs.conversion import Converter
from groupdocs.conversion.options.convert import PdfConvertOptions
with open("input.docx", "rb") as stream:
with Converter(stream) as converter:
converter.convert(
lambda ctx: open("output.pdf", "wb"),
lambda ctx: PdfConvertOptions(),
cancellationToken=None
)
Converts the source document and saves the whole converted document.
Learn more
- More about document conversion basic scenarios: https://docs.groupdocs.com/display/conversionnet/Convert+document
- Conversion use cases, advanced settings and customizations: https://docs.groupdocs.com/display/conversionnet/Converting
def convert(self, convert_options_provider, document_completed):
...
| Parameter | Type | Description |
|---|---|---|
| convert_options_provider | Func[ConvertContext, ConvertOptions] |
Callable[[ConvertContext], GroupDocs.Conversion.ConvertOptions] Provides conversion options. The ConvertContext parameter contains information about the conversion operation. |
| document_completed | Action[ConvertedContext] |
Callable[[ConvertedContext], None] Receives the converted document stream. The ConvertedContext parameter contains the converted document stream and metadata. |
Returns: None.
Converts the source document and saves the whole converted document.
Learn more:
- More about document conversion basic scenarios: How to convert document in 3 steps
- Conversion use cases, advanced settings and customizations: Convert document with advanced settings
def convert(self, file_path, convert_options):
...
| Parameter | Type | Description |
|---|---|---|
| file_path | str |
The file path to the source document. |
| convert_options | ConvertOptions |
The convert options specific to the desired target file type. |
from groupdocs.conversion import Converter
from groupdocs.conversion.options.convert import PdfConvertOptions
with open("input.docx", "rb") as stream:
with Converter(stream) as converter:
converter.convert("output.pdf", PdfConvertOptions())
Converts the source document and saves the converted document page by page.
Learn more
- More about document conversion basic scenarios: How to convert document in 3 steps (https://docs.groupdocs.com/display/conversionnet/Convert+document)
- Conversion use cases, advanced settings and customizations: Convert document with advanced settings (https://docs.groupdocs.com/display/conversionnet/Converting)
def convert(self, target_stream_provider, convert_options_provider):
...
| Parameter | Type | Description |
|---|---|---|
| target_stream_provider | Func[SavePageContext, io.RawIOBase] |
Callable[[SavePageContext], io.RawIOBase] that provides a stream for saving each converted page. The SavePageContext parameter contains page number and document information. |
| convert_options_provider | Func[ConvertContext, ConvertOptions] |
Callable[[ConvertContext], ConvertOptions] that provides conversion options. The ConvertContext parameter contains information about the conversion operation. |
Returns: None.
Converts the source document and saves the converted document page by page.
Learn more
- More about document conversion basic scenarios: https://docs.groupdocs.com/display/conversionnet/Convert+document
- Conversion use cases, advanced settings and customizations: https://docs.groupdocs.com/display/conversionnet/Converting
def convert(self, target_stream_provider, convert_options):
...
| Parameter | Type | Description |
|---|---|---|
| target_stream_provider | Func[SavePageContext, io.RawIOBase] |
Callable that provides a stream for saving each converted page. Signature: Func<SavePageContext, Stream>. The SavePageContext parameter contains page number and document information. |
| convert_options | ConvertOptions |
The convert options specific to the desired target file type. |
Returns: None.
from groupdocs.conversion import Converter
from groupdocs.conversion.options.convert import PdfConvertOptions
with open("input.docx", "rb") as stream:
with Converter(stream) as converter:
converter.convert("output.pdf", PdfConvertOptions())
Converts the source document and saves the converted document page by page.
Learn more
- More about document conversion basic scenarios: https://docs.groupdocs.com/display/conversionnet/Convert+document
- Conversion use cases, advanced settings and customizations: https://docs.groupdocs.com/display/conversionnet/Converting
def convert(self, convert_options, document_completed):
...
| Parameter | Type | Description |
|---|---|---|
| convert_options | ConvertOptions |
The convert options specific to desired target file type. |
| document_completed | Action[ConvertedPageContext] |
Callable that receives each converted page. The ConvertedPageContext parameter contains page number, stream, source file name, and target file type. |
from groupdocs.conversion import Converter
from groupdocs.conversion.options.convert import PdfConvertOptions
with Converter("./business-plan.docx") as converter:
converter.convert("./business-plan.pdf", PdfConvertOptions())
Converts the source document and saves the converted document page by page.
Learn more
- More about document conversion basic scenarios: How to convert document in 3 steps
- Conversion use cases, advanced settings and customizations: Convert document with advanced settings
def convert(self, convert_options_provider, document_completed):
...
| Parameter | Type | Description |
|---|---|---|
| convert_options_provider | Func[ConvertContext, ConvertOptions] |
Delegate that provides conversion options. The ConvertContext parameter contains information about the conversion operation. |
| document_completed | Action[ConvertedPageContext] |
Delegate that receives each converted page. The ConvertedPageContext parameter contains page number, stream, source file name, and target file type. |
from groupdocs.conversion import Converter
from groupdocs.conversion.options.convert import PdfConvertOptions
with open("input.docx", "rb") as stream:
with Converter(stream) as converter:
converter.convert("output.pdf", PdfConvertOptions())
- class
Converter
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.