Skip to content

Commit 7be9d5c

Browse files
Added code examples
1 parent 259cb63 commit 7be9d5c

57 files changed

Lines changed: 2084 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,9 @@ cython_debug/
160160
# and can be added to the global gitignore or merged into this file. For a more nuclear
161161
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
162162
#.idea/
163+
164+
# License files
165+
.lic
166+
167+
# Python package files
168+
.whl
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from groupdocs.pydrawing import Color
2+
from groupdocs.conversion import Converter
3+
from groupdocs.conversion.options.convert import PdfConvertOptions, WatermarkTextOptions
4+
5+
def add_watermark_to_converted_document():
6+
# Instantiate Converter with the input document
7+
with Converter("./professional-services.docx") as converter:
8+
# Set up the watermark options
9+
watermark = WatermarkTextOptions("DRAFT")
10+
watermark.color = Color.from_argb(128, 211, 211, 211) # lite gray
11+
watermark.top = 10
12+
watermark.left = 10
13+
watermark.width = 300
14+
watermark.height = 300
15+
watermark.background = True
16+
17+
# Set up the conversion options
18+
options = PdfConvertOptions()
19+
options.watermark = watermark
20+
21+
# Perform the conversion
22+
converter.convert("./professional-services.pdf", options)
23+
24+
if __name__ == "__main__":
25+
add_watermark_to_converted_document()
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from groupdocs.conversion import Converter
2+
from groupdocs.conversion.options.convert import PdfConvertOptions
3+
4+
def convert_consecutive_document_pages():
5+
# Instantiate Converter with the input document
6+
with Converter("./business-plan.docx") as converter:
7+
# Instantiate convert options to define the output format
8+
pdf_convert_options = PdfConvertOptions()
9+
# Specify the starting page and number of pages to convert
10+
pdf_convert_options.page_number = 1
11+
pdf_convert_options.pages_count = 5
12+
13+
# Convert the specified range of pages in the document to PDF
14+
converter.convert("./pages-1-through-5.pdf", pdf_convert_options)
15+
16+
if __name__ == "__main__":
17+
convert_consecutive_document_pages()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from groupdocs.conversion import Converter
2+
from groupdocs.conversion.options.convert import PdfConvertOptions
3+
4+
def convert_document_to_another_format():
5+
# Instantiate Converter with the input document
6+
with Converter("./business-plan.docx") as converter:
7+
# Instantiate convert options to define the output format
8+
pdf_convert_options = PdfConvertOptions()
9+
10+
# Convert the input document to PDF
11+
converter.convert("./business-plan.pdf", pdf_convert_options)
12+
13+
if __name__ == "__main__":
14+
convert_document_to_another_format()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from groupdocs.conversion import Converter
2+
from groupdocs.conversion.options.convert import PdfConvertOptions
3+
4+
def convert_specific_document_pages():
5+
# Instantiate Converter with the input document
6+
with Converter("./business-plan.docx") as converter:
7+
# Instantiate convert options to define the output format
8+
pdf_convert_options = PdfConvertOptions()
9+
# Specify which document pages to convert
10+
pdf_convert_options.pages = [1, 3, 5]
11+
12+
# Convert the specified pages of the input document to PDF
13+
converter.convert("./pages-1-3-5.pdf", pdf_convert_options)
14+
15+
if __name__ == "__main__":
16+
convert_specific_document_pages()
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from groupdocs.conversion import Converter
2+
from groupdocs.conversion.filetypes import ImageFileType
3+
from groupdocs.conversion.options.convert import ImageConvertOptions
4+
5+
def convert_all_document_pages():
6+
# Instantiate Converter with the input document
7+
with Converter("./basic-presentation.pptx") as converter:
8+
# Instantiate convert options
9+
png_convert_options = ImageConvertOptions()
10+
# Define the output format as PNG
11+
png_convert_options.format = ImageFileType.PNG
12+
13+
# Convert all pages and save to the output folder
14+
converter.convert_by_page("./converted-pages", png_convert_options)
15+
16+
if __name__ == "__main__":
17+
convert_all_document_pages()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from groupdocs.conversion import Converter
2+
from groupdocs.conversion.filetypes import ImageFileType
3+
from groupdocs.conversion.options.convert import ImageConvertOptions
4+
5+
def convert_specific_document_page_to_file():
6+
# Instantiate Converter with the input document
7+
with Converter("./basic-presentation.pptx") as converter:
8+
# Instantiate convert options
9+
png_convert_options = ImageConvertOptions()
10+
# Define the output format as PNG
11+
png_convert_options.format = ImageFileType.PNG
12+
13+
# Set the page number to convert and save it to a file
14+
page_number_to_convert = 3
15+
converter.convert_by_page("./slide-3.png", page_number_to_convert, png_convert_options)
16+
17+
if __name__ == "__main__":
18+
convert_specific_document_page_to_file()

0 commit comments

Comments
 (0)