-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PdfOptimizationOptions and XML document rendering articles were imple…
…mented.
- Loading branch information
1 parent
9cf94ca
commit 18df9df
Showing
20 changed files
with
821 additions
and
2 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
...eloper-guide/rendering-documents/rendering-to-pdf/adjust-jpeg-images-quality.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
id: adjust-jpeg-images-quality | ||
url: viewer/python-net/adjust-jpeg-images-quality | ||
title: Specify the JPEG image quality | ||
weight: 3 | ||
description: "Adjust JPEG images quality when rendering documents to PDF with GroupDocs.Viewer for Python via .NET" | ||
productName: GroupDocs.Viewer for Python via .NET | ||
hideChildren: False | ||
--- | ||
Decreasing the JPG images quality reduces the size of the output file. | ||
|
||
To adjust images quality, set the [image_quality](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pdfoptimizationoptions/#properties) property of the [PdfViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pdfoptimizationoptions/) class. The value must be between 1 (minimum quality) and 100. The default value is 90. | ||
|
||
To set the image quality, follow these steps: | ||
|
||
1. Instantiate the [Viewer](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer) class. Specify the source document path as a constructor parameter. | ||
1. Instantiate the [PdfViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pdfviewoptions) object. | ||
2. Set the [PdfViewOptions.pdf_optimization_options](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pdfviewoptions/#properties) value as instantiated [PdfOptimizationOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pdfoptimizationoptions/) object. | ||
3. Set the [PdfViewOptions.pdf_optimization_options.image_quality](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pdfoptimizationoptions/#properties) value. | ||
4. Call the [view](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer/#methods) method of the [Viewer](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer) object. Specify the [PdfViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pdfviewoptions) object as the parameter. | ||
|
||
The following code snippet shows how to adjust JPG image quality in the output PDF document: | ||
|
||
{{< tabs "example1">}} | ||
{{< tab "Python" >}} | ||
```python | ||
with gv.Viewer("sample.docx") as viewer: | ||
# Create view options. | ||
viewOptions = gvo.PdfViewOptions() | ||
|
||
# Specify the JPG image quality. | ||
pdf_optimization_options = gvo.PdfOptimizationOptions() | ||
pdf_optimization_options.image_quality = 50 | ||
# Specify pdf_optimization_options object | ||
viewOptions.pdf_optimization_options = pdf_optimization_options | ||
|
||
viewer.view(viewOptions) | ||
``` | ||
{{< /tab >}} | ||
{{< /tabs >}} |
21 changes: 21 additions & 0 deletions
21
...r-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/_index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
id: optimization-pdf-options | ||
url: viewer/python-net/optimization-pdf-options | ||
title: Optimize the output PDF file | ||
linkTitle: Optimize the output PDF file | ||
weight: 6 | ||
description: "This topic describes how to optimize PDF file in the GroupDocs.Viewer Python API for web browser or to reduce size." | ||
keywords: convert to pdf, optimize size, optimize browser, optimize web, pdf reduce size | ||
productName: GroupDocs.Viewer for Python via .NET | ||
hideChildren: False | ||
toc: True | ||
--- | ||
GroupDocs.Viewer allows you to optimize the output PDF file for a web browser or to reduce the file size by optimizing resources. | ||
|
||
Optimization for a web allows a browser to display the first pages of a PDF file when you open the document, instead of waiting for the entire file to download. | ||
|
||
Resource optimization allows you to reduce the size of the output PDF file. While optimizing, GroupDocs.Viewer may reduce the image size or quality, remove notes or form fields, remove objects, fonts, or personal information from a document, and so on. | ||
|
||
You can also optimize an existing PDF file. To do this, open it, specify the optimization parameters, and save the output file. | ||
|
||
|
28 changes: 28 additions & 0 deletions
28
...documents/rendering-to-pdf/optimization-pdf-options/optimization-pdf-for-web.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
id: optimization-pdf-for-web | ||
url: viewer/python-net/optimization-pdf-for-web | ||
title: Optimize a PDF file for a browser | ||
linkTitle: Optimize a PDF file for a browser | ||
weight: 1 | ||
description: "This topic describes how to optimize PDF file using the GroupDocs.Viewer Python API for web browser or to reduce size." | ||
keywords: convert to pdf, optimize browser, optimize web | ||
productName: GroupDocs.Viewer for Python via .NET | ||
hideChildren: False | ||
toc: True | ||
--- | ||
This optimization allows a browser to display the first pages of a PDF file when you open the document, instead of waiting for the entire file to download. | ||
|
||
The following code snippet shows how to optimize a PDF file for browser: | ||
{{< tabs "Example1">}} | ||
{{< tab "Python" >}} | ||
```python | ||
with gv.Viewer("sample.docx") as viewer: | ||
|
||
viewOptions = gvo.PdfViewOptions() | ||
viewOptions.pdf_optimization_options = gvo.PdfOptimizationOptions() | ||
viewOptions.pdf_optimization_options.lineriaze = True | ||
|
||
viewer.view(viewOptions) | ||
``` | ||
{{< /tab >}} | ||
{{< /tabs >}} |
28 changes: 28 additions & 0 deletions
28
...cuments/rendering-to-pdf/optimization-pdf-options/optimization-pdf-resources.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
id: optimization-pdf-resources | ||
url: viewer/python-net/optimization-pdf-resources | ||
title: Optimize the PDF file resources | ||
linkTitle: Optimize the PDF file resources | ||
weight: 2 | ||
description: "This topic describes how to optimize PDF file using the GroupDocs.Viewer Python API to reduce size." | ||
keywords: convert to pdf, optimize size, pdf reduce size | ||
productName: GroupDocs.Viewer for Python via .NET | ||
hideChildren: False | ||
toc: True | ||
--- | ||
Resource optimization allows you to reduce the size of the output PDF file. While optimizing, GroupDocs.Viewer may reduce the image size or quality, remove notes or form fields, remove objects, fonts, or personal information from a document, and so on. | ||
|
||
The following code snippet shows how to optimize the PDF file by default: | ||
|
||
{{< tabs "Example1">}} | ||
{{< tab "Python" >}} | ||
```python | ||
with gv.Viewer("sample.docx") as viewer: | ||
|
||
viewOptions = gvo.PdfViewOptions() | ||
viewOptions.pdf_optimization_options = gvo.PdfOptimizationOptions() | ||
|
||
viewer.view(viewOptions) | ||
``` | ||
{{< /tab >}} | ||
{{< /tabs >}} |
32 changes: 32 additions & 0 deletions
32
...ents/rendering-to-pdf/optimization-pdf-options/optimization-pdf-spreadsheets.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
id: optimization-pdf-spreadsheets | ||
url: viewer/python-net/optimization-pdf-spreadsheets | ||
title: Optimize spreadsheets in a PDF file | ||
linkTitle: Optimize spreadsheets in a PDF file | ||
weight: 3 | ||
description: "This topic describes how to optimize spreadsheets in a PDF file using the GroupDocs.Viewer Python API." | ||
keywords: convert to pdf, optimize browser, optimize web | ||
productName: GroupDocs.Viewer for Python via .NET | ||
hideChildren: False | ||
toc: True | ||
--- | ||
This optimization allows to reduce the output file size by setting up border lines. Besides that, it removes the Arial and Times New Roman characters of 32-127 codes. | ||
|
||
The default value is `False`. | ||
|
||
|
||
The following code snippet shows how to optimize spreadsheets in a PDF file: | ||
|
||
{{< tabs "Example1">}} | ||
{{< tab "Python" >}} | ||
```python | ||
with gv.Viewer("invoice.xlsx") as viewer: | ||
|
||
viewOptions = gvo.PdfViewOptions() | ||
viewOptions.pdf_optimization_options = gvo.PdfOptimizationOptions() | ||
viewOptions.pdf_optimization_options.optimize_spreadsheets = True | ||
|
||
viewer.view(viewOptions) | ||
``` | ||
{{< /tab >}} | ||
{{< /tabs >}} |
11 changes: 11 additions & 0 deletions
11
...-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/_index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
id: optimize-content | ||
url: viewer/python-net/optimize-content | ||
title: Optimize content | ||
weight: 5 | ||
description: "Optimize content of a PDF file using GroupDocs.Viewer for Python via .NET " | ||
productName: GroupDocs.Viewer for Python via .NET | ||
hideChildren: False | ||
isMenuItemWithNoContent: True | ||
--- | ||
|
35 changes: 35 additions & 0 deletions
35
...ptimization-pdf-options/optimize-content/optimization-pdf-remove-annotations.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
id: optimization-pdf-remove-annotations | ||
url: viewer/python-net/optimization-pdf-remove-annotations | ||
title: Remove annotations | ||
linkTitle: Remove annotations | ||
weight: 1 | ||
description: "This topic describes how to remove annotations from PDF file using the GroupDocs.Viewer Python API." | ||
keywords: convert to pdf, optimize size, pdf reduce size, remove annotations | ||
productName: GroupDocs.Viewer for Python via .NET | ||
hideChildren: False | ||
toc: True | ||
--- | ||
If the output PDF file contains annotations, you can remove them to reduce the file size. | ||
|
||
To remove annotations, set the [remove_annotations](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pdfoptimizationoptions/#properties) property to `True`. | ||
|
||
The following code snippet shows how to remove annotations from the file: | ||
|
||
{{< tabs "Example1">}} | ||
{{< tab "Python" >}} | ||
```python | ||
with gv.Viewer("sample.docx") as viewer: | ||
|
||
viewOptions = gvo.PdfViewOptions() | ||
viewOptions.pdf_optimization_options = gvo.PdfOptimizationOptions() | ||
viewOptions.pdf_optimization_options.remove_annotations = True | ||
|
||
viewer.view(viewOptions) | ||
``` | ||
{{< /tab >}} | ||
{{< /tabs >}} | ||
|
||
The following image demonstrates the result: | ||
|
||
![Remove annotations](/viewer/net/images/developer-guide/pdf-rendering/optimization/optimization-pdf-remove-annotations.png) |
35 changes: 35 additions & 0 deletions
35
...pdf/optimization-pdf-options/optimize-content/optimization-pdf-remove-fields.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
id: optimization-pdf-remove-fields | ||
url: viewer/python-net/optimization-pdf-remove-fields | ||
title: Remove form fields | ||
linkTitle: Remove form fields | ||
weight: 2 | ||
description: "This topic describes how to remove form fields from PDF file using the GroupDocs.Viewer Python API." | ||
keywords: convert to pdf, optimize size, pdf reduce size, remove fields | ||
productName: GroupDocs.Viewer for Python via .NET | ||
hideChildren: False | ||
toc: True | ||
--- | ||
If the output PDF file contains form fields, you can flatten them to reduce the file size. | ||
|
||
To remove form fields, set the [remove_form_fields](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pdfoptimizationoptions/#properties) property to `True`. | ||
|
||
The following code snippet shows how to flatten form fields in the file: | ||
|
||
{{< tabs "Example1">}} | ||
{{< tab "Python" >}} | ||
```python | ||
with gv.Viewer("sample.docx") as viewer: | ||
|
||
viewOptions = gvo.PdfViewOptions() | ||
viewOptions.pdf_optimization_options = gvo.PdfOptimizationOptions() | ||
viewOptions.pdf_optimization_options.remove_form_fields = True | ||
|
||
viewer.view(viewOptions) | ||
``` | ||
{{< /tab >}} | ||
{{< /tabs >}} | ||
|
||
The following image demonstrates the result: | ||
|
||
![Remove fields](/viewer/net/images/developer-guide/pdf-rendering/optimization/optimization-pdf-remove-fields.png) |
11 changes: 11 additions & 0 deletions
11
...ng-documents/rendering-to-pdf/optimization-pdf-options/optimize-fonts/_index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
id: optimize-fonts | ||
url: viewer/python-net/optimize-fonts | ||
title: Optimize fonts | ||
weight: 6 | ||
description: "Optimize fonts in a PDF file using GroupDocs.Viewer for Python via .NET" | ||
productName: GroupDocs.Viewer for Python via .NET | ||
hideChildren: False | ||
isMenuItemWithNoContent: True | ||
--- | ||
|
39 changes: 39 additions & 0 deletions
39
...to-pdf/optimization-pdf-options/optimize-fonts/optimization-pdf-subset-fonts.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
id: optimization-pdf-subset-fonts | ||
url: viewer/python-net/optimization-pdf-subset-fonts | ||
title: Subset fonts | ||
linkTitle: Subset fonts | ||
weight: 2 | ||
description: "This topic describes how to subset fonts in PDF file using the GroupDocs.Viewer Python API." | ||
keywords: convert to pdf, optimize size, pdf reduce size, subset fonts | ||
productName: GroupDocs.Viewer for Python via .NET | ||
hideChildren: False | ||
toc: True | ||
--- | ||
Not optimized files may contain embedded fonts. GroupDocs.Viewer can remove unused instructions in embedded fonts to reduce the file size. | ||
|
||
To subset fonts in a PDF file, set the [subset_fonts](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pdfoptimizationoptions/#properties) property to `True`. | ||
|
||
The following code snippet shows how to subset fonts in a PDF file: | ||
|
||
{{< tabs "Example1">}} | ||
{{< tab "Python" >}} | ||
```python | ||
with gv.Viewer("sample.docx") as viewer: | ||
|
||
viewOptions = gvo.PdfViewOptions() | ||
viewOptions.pdf_optimization_options = gvo.PdfOptimizationOptions() | ||
viewOptions.pdf_optimization_options.subset_fonts = True | ||
|
||
viewer.view(viewOptions) | ||
``` | ||
{{< /tab >}} | ||
{{< /tabs >}} | ||
|
||
The following image demonstrates the result. There is no difference in appearance: | ||
|
||
![No difference in appearance](/viewer/net/images/developer-guide/pdf-rendering/optimization/optimization-pdf-subset-fonts-appearance.png) | ||
|
||
But there is the significant difference in size: | ||
|
||
![Significant difference in size](/viewer/net/images/developer-guide/pdf-rendering/optimization/optimization-pdf-subset-fonts-size.png) |
11 changes: 11 additions & 0 deletions
11
...g-documents/rendering-to-pdf/optimization-pdf-options/optimize-images/_index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
id: optimize-images | ||
url: viewer/python-net/optimize-images | ||
title: Optimize images | ||
weight: 4 | ||
description: "Optimize images in a PDF file using GroupDocs.Viewer for Python via .NET" | ||
productName: GroupDocs.Viewer for Python via .NET | ||
hideChildren: False | ||
isMenuItemWithNoContent: True | ||
--- | ||
|
35 changes: 35 additions & 0 deletions
35
.../optimization-pdf-options/optimize-images/optimization-pdf-convert-grayscale.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
id: optimization-pdf-convert-grayscale | ||
url: viewer/python-net/optimization-pdf-convert-grayscale | ||
title: Convert to grayscale | ||
linkTitle: Convert to grayscale | ||
weight: 3 | ||
description: "This topic describes how to convert PDF file to grayscale using the GroupDocs.Viewer Python API." | ||
keywords: convert to pdf, optimize size, pdf reduce size, convert to grayscale | ||
productName: GroupDocs.Viewer for Python via .NET | ||
hideChildren: False | ||
toc: True | ||
--- | ||
To speed up the printing of a PDF file and reduce its size, you can convert it from RGB color space to grayscale. | ||
|
||
To convert a PDF file to grayscale, set the [convert_to_gray_scale](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pdfoptimizationoptions/#properties) property to `True`. | ||
|
||
The following code snippet shows how to convert a PDF file to grayscale: | ||
|
||
{{< tabs "Example1">}} | ||
{{< tab "Python" >}} | ||
```python | ||
with gv.Viewer("sample.docx") as viewer: | ||
|
||
viewOptions = gvo.PdfViewOptions() | ||
viewOptions.pdf_optimization_options = gvo.PdfOptimizationOptions() | ||
viewOptions.pdf_optimization_options.convert_to_gray_scale = True | ||
|
||
viewer.view(viewOptions) | ||
``` | ||
{{< /tab >}} | ||
{{< /tabs >}} | ||
|
||
The following image demonstrates the result: | ||
|
||
![Convert to grayscale](/viewer/net/images/developer-guide/pdf-rendering/optimization/optimization-pdf-convert-grayscale.png) |
39 changes: 39 additions & 0 deletions
39
...timization-pdf-options/optimize-images/optimization-pdf-reduce-image-quality.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
id: optimization-pdf-reduce-image-quality | ||
url: viewer/python-net/optimization-pdf-reduce-image-quality | ||
title: Reduce image quality | ||
linkTitle: Reduce image quality | ||
weight: 1 | ||
description: "This topic describes how to compress images in PDF file using the GroupDocs.Viewer Python API." | ||
keywords: convert to pdf, optimize size, pdf reduce size, compress images | ||
productName: GroupDocs.Viewer for Python via .NET | ||
hideChildren: False | ||
toc: True | ||
--- | ||
|
||
If the output PDF file contains images, you can reduce its size using image compression. | ||
|
||
To enable image compression, set the [compress_images](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pdfoptimizationoptions/#properties) property to `True`. The GroupDocs.Viewer compresses all images in the file. | ||
|
||
The [image_quality](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pdfoptimizationoptions/#properties) property determines the compression ratio. It is a quality value in percent. 100% means original quality. | ||
|
||
The following code snippet shows how to compress images in the file: | ||
|
||
{{< tabs "Example1">}} | ||
{{< tab "Python" >}} | ||
```python | ||
with gv.Viewer("sample.docx") as viewer: | ||
|
||
viewOptions = gvo.PdfViewOptions() | ||
viewOptions.pdf_optimization_options = gvo.PdfOptimizationOptions() | ||
viewOptions.pdf_optimization_options.compress_images = True | ||
viewOptions.pdf_optimization_options.image_quality = 50 | ||
|
||
viewer.view(viewOptions) | ||
``` | ||
{{< /tab >}} | ||
{{< /tabs >}} | ||
|
||
The following image demonstrates the result: | ||
|
||
![Reduce image quality](/viewer/net/images/developer-guide/pdf-rendering/optimization/optimization-pdf-reduce-image-quality.png) |
Oops, something went wrong.