-
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.
Release GroupDocs.Viewer for Java v24.6 (#86)
Co-authored-by: aleksey.permyakov <aleksey.permyakov@aspose.com>
- Loading branch information
1 parent
516bb84
commit b6938f0
Showing
29 changed files
with
594 additions
and
3 deletions.
There are no files selected for viewing
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
122 changes: 122 additions & 0 deletions
122
java/developer-guide/loading-documents/loading-external-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,122 @@ | ||
--- | ||
id: loading-external-resources | ||
url: viewer/java/loading-external-resources | ||
title: Loading of external resources containing by a document | ||
weight: 5 | ||
keywords: set timeout, Groupdocs.Viewer | ||
description: "This article explains how to manage loading of external resources contained by a document with GroupDocs.Viewer within your Java applications." | ||
productName: GroupDocs.Viewer for Java | ||
hideChildren: False | ||
--- | ||
|
||
If the document contains external resources, such as images, GroupDocs.Viewer loads them when rendering a document. This allows the document to display correctly, but is a potential security risk. | ||
|
||
GroupDocs.Viewer allows you to manage loading of external resources contained by a document. These features are supported for the following formats: | ||
- [Word Processing File Formats](https://docs.fileformat.com/word-processing/) | ||
- [Web File Formats](https://docs.fileformat.com/web/) | ||
- [SpreadSheet File Formats](https://docs.fileformat.com/spreadsheet/) | ||
|
||
Use the [LoadOptions](https://reference.groupdocs.com/viewer/java/com.groupdocs.viewer.options/loadoptions/) object to manage loading of external resources. | ||
|
||
## Skip loading of external resources | ||
|
||
The following code snippet shows how to deny loading of external resources: | ||
|
||
{{< tabs "example3">}} | ||
{{< tab "Java" >}} | ||
```java | ||
LoadOptions loadOptions = new LoadOptions(); | ||
loadOptions.setSkipExternalResources(true); // Skip loading of external resources | ||
|
||
try (Viewer viewer = new Viewer("business-flyer.docx", loadOptions)) { | ||
HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources(); | ||
|
||
viewer.view(viewOptions); | ||
} | ||
``` | ||
{{< /tab >}} | ||
{{< tab "Kotlin">}} | ||
```kotlin | ||
val loadOptions = LoadOptions() | ||
loadOptions.isSkipExternalResources = true // Skip loading of external resources | ||
|
||
Viewer("business-flyer.docx", loadOptions).use { viewer -> | ||
val viewOptions = HtmlViewOptions.forEmbeddedResources() | ||
|
||
viewer.view(viewOptions) | ||
} | ||
``` | ||
{{< /tab >}} | ||
{{< /tabs >}} | ||
|
||
The following images show the output file with and without external resources (see top right corner): | ||
|
||
| loadOptions.setSkipExternalResources(false) | loadOptions.setSkipExternalResources(true) | | ||
|-----------------------------------------------------------|-------------------------------------------------------------| | ||
| ![False](/viewer/java/images/with-external-resources.png) | ![True](/viewer/java/images/without-external-resources.png) | | ||
|
||
## Manage a safelist for loading external resources | ||
|
||
The following code snippet shows how to allow loading of external resources from specific URLs: | ||
|
||
{{< tabs "example2">}} | ||
{{< tab "Java" >}} | ||
```java | ||
LoadOptions loadOptions = new LoadOptions(); | ||
loadOptions.setSkipExternalResources(true); // Skip loading of all external resources | ||
loadOptions.getWhitelistedResources().add("avatars.githubusercontent.com"); // Enable loading of external resources that has `avatars.githubusercontent.com` fragment in resource URL. | ||
|
||
try (Viewer viewer = new Viewer("business-flyer.docx", loadOptions)) { | ||
HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources(); | ||
viewer.view(viewOptions); | ||
} | ||
``` | ||
{{< /tab >}} | ||
{{< tab "Kotlin">}} | ||
```kotlin | ||
val loadOptions = LoadOptions() | ||
loadOptions.isSkipExternalResources = true // Skip loading of all external resources | ||
loadOptions.whitelistedResources.add("avatars.githubusercontent.com") // Enable loading of external resources that has `avatars.githubusercontent.com` fragment in resource URL. | ||
|
||
val viewer = Viewer("business-flyer.docx", loadOptions) | ||
val viewOptions = HtmlViewOptions.forEmbeddedResources() | ||
viewer.use { | ||
it.view(viewOptions) | ||
} | ||
``` | ||
{{< /tab >}} | ||
{{< /tabs >}} | ||
|
||
## Set timeout for loading of external resources | ||
|
||
The default timeout is 10 seconds. GroupDocs.Viewer allows you to change this value. | ||
|
||
The following code snippet shows how to set a timeout to load external resources: | ||
|
||
{{< tabs "example1">}} | ||
{{< tab "Java" >}} | ||
```java | ||
// Specify a timeout. | ||
LoadOptions loadOptions = new LoadOptions(); | ||
loadOptions.setResourceLoadingTimeout(5000); | ||
// Render a file. | ||
try (Viewer viewer = new Viewer("sample.docx", loadOptions)) { | ||
HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources(); | ||
viewer.view(viewOptions); | ||
} | ||
``` | ||
{{< /tab >}} | ||
{{< tab "Kotlin">}} | ||
```kotlin | ||
// Specify a timeout. | ||
val loadOptions = LoadOptions() | ||
loadOptions.setResourceLoadingTimeout(5000) | ||
// Render a file. | ||
Viewer("sample.docx", loadOptions).use { viewer -> | ||
val viewOptions = HtmlViewOptions.forEmbeddedResources() | ||
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/java/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 Java 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 Java | ||
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. | ||
|
||
|
30 changes: 30 additions & 0 deletions
30
...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,30 @@ | ||
--- | ||
id: optimization-pdf-for-web | ||
url: viewer/java/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 Java API for web browser or to reduce size." | ||
keywords: convert to pdf, optimize browser, optimize web | ||
productName: GroupDocs.Viewer for Java | ||
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 "Java" >}} | ||
```java | ||
try (Viewer viewer = new Viewer("sample.docx")) { | ||
PdfViewOptions viewOptions = new PdfViewOptions(); | ||
viewOptions.setPdfOptimizationOptions(new PdfOptimizationOptions()); | ||
viewOptions.getPdfOptimizationOptions().setLinearize(true); | ||
|
||
viewer.view(viewOptions); | ||
} | ||
``` | ||
{{</ tab >}} | ||
{{</ tabs >}} | ||
|
||
|
30 changes: 30 additions & 0 deletions
30
...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,30 @@ | ||
--- | ||
id: optimization-pdf-resources | ||
url: viewer/java/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 Java API to reduce size." | ||
keywords: convert to pdf, optimize size, pdf reduce size | ||
productName: GroupDocs.Viewer for Java | ||
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 "Java" >}} | ||
```java | ||
try (Viewer viewer = new Viewer("sample.docx")) { | ||
PdfViewOptions viewOptions = new PdfViewOptions(); | ||
viewOptions.setPdfOptimizationOptions(new 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/java/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 Java API." | ||
keywords: convert to pdf, optimize browser, optimize web | ||
productName: GroupDocs.Viewer for Java | ||
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 "Java" >}} | ||
```java | ||
try (Viewer viewer = new Viewer("invoice.xlsx")) { | ||
PdfViewOptions viewOptions = new PdfViewOptions(); | ||
PdfOptimizationOptions optimizationOptions = new PdfOptimizationOptions(); | ||
optimizationOptions.setOptimizeSpreadsheets(true); | ||
viewOptions.setPdfOptimizationOptions(optimizationOptions); | ||
viewer.view(viewOptions); | ||
} | ||
``` | ||
{{</ tab >}} | ||
{{</ tabs >}} |
10 changes: 10 additions & 0 deletions
10
...-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,10 @@ | ||
--- | ||
id: optimize-content | ||
url: viewer/java/optimize-content | ||
title: Optimize content | ||
weight: 5 | ||
description: "Optimize content of a PDF file using GroupDocs.Viewer for Java" | ||
productName: GroupDocs.Viewer for Java | ||
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/java/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 Java API." | ||
keywords: convert to pdf, optimize size, pdf reduce size, remove annotations | ||
productName: GroupDocs.Viewer for Java | ||
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 [setRemoveAnnotations](https://reference.groupdocs.com/viewer/java/com.groupdocs.viewer.options/pdfoptimizationoptions/#setRemoveAnnotations-boolean-) to `true`. | ||
|
||
The following code snippet shows how to remove annotations from the file: | ||
|
||
{{< tabs "Example1">}} | ||
{{< tab "Java" >}} | ||
```java | ||
try (Viewer viewer = new Viewer("sample.docx")) { | ||
PdfViewOptions viewOptions = new PdfViewOptions(); | ||
viewOptions.setPdfOptimizationOptions(new PdfOptimizationOptions()); | ||
viewOptions.getPdfOptimizationOptions().setRemoveAnnotations(true); | ||
|
||
viewer.view(viewOptions); | ||
} | ||
``` | ||
{{</ tab >}} | ||
{{</ tabs >}} | ||
|
||
The following image demonstrates the result: | ||
|
||
![Remove annotations](/viewer/java/images/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/java/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 Java API." | ||
keywords: convert to pdf, optimize size, pdf reduce size, remove fields | ||
productName: GroupDocs.Viewer for Java | ||
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 `setRemoveFormFields()` property to `true` in [PdfOptimizationOptions](https://reference.groupdocs.com/viewer/java/com.groupdocs.viewer.options/pdfoptimizationoptions/). | ||
|
||
The following code snippet shows how to flatten form fields in the file: | ||
|
||
{{< tabs "Example1">}} | ||
{{< tab "Java" >}} | ||
```java | ||
try (Viewer viewer = new Viewer("sample.docx")) { | ||
PdfViewOptions viewOptions = new PdfViewOptions(); | ||
viewOptions.setPdfOptimizationOptions(new PdfOptimizationOptions()); | ||
viewOptions.getPdfOptimizationOptions().setRemoveFormFields(true); | ||
|
||
viewer.view(viewOptions); | ||
} | ||
``` | ||
{{</ tab >}} | ||
{{</ tabs >}} | ||
|
||
The following image demonstrates the result: | ||
|
||
![Remove fields](/viewer/java/images/pdf-rendering/optimization/optimization-pdf-remove-fields.png) |
Oops, something went wrong.