Skip to content

Commit 50d2e19

Browse files
Added PdfOptimizationOptions, changed PdfOptions
1 parent 40b01ff commit 50d2e19

3 files changed

Lines changed: 124 additions & 14 deletions

File tree

content/viewer/developer-guide/basic-usage/pdf-viewer/pdf-viewer-adjust-quality-for-jpg-images.md renamed to content/viewer/developer-guide/basic-usage/pdf-viewer/pdf-viewer-optimization-options.md

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
---
2-
id: "pdf-viewer-adjust-quality-for-jpg-images"
3-
url: "viewer/pdf-viewer-adjust-quality-for-jpg-images"
4-
title: "PDF Viewer - Adjust quality for JPG images"
2+
id: "pdf-viewer-optimization-options"
3+
url: "viewer/pdf-viewer-optimization-options"
4+
title: "PDF Viewer - Optimization options"
55
productName: "GroupDocs.Viewer Cloud"
66
description: ""
77
keywords: ""
88
---
99

1010
# Introduction #
1111

12-
When rendering documents to PDF format that contains JPG images it may be reasonable to reduce size of the output file by adjusting quality of the JPG images. GroupDocs.Viewer Cloud enables you to adjust quality of images in the output PDF document with JpgQuality setting of PdfOptions class. The supported values range of JpgQuality is from 1 to 100. Default value is 90.
12+
GroupDocs.Viewer Cloud 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.
13+
See [PdfOptimizationOptions]({{< ref "viewer/developer-guide/data-structures/pdfoptimizationoptions.md" >}}) for more information.
1314

14-
The following code sample shows how to adjust JPG image quality in the output PDF document.
15+
The following code sample shows how to adjust image quality in the output PDF document.
1516

1617
## API Usage ##
1718

@@ -51,7 +52,10 @@ curl -v "https://api.groupdocs.cloud/v2.0/viewer/view" \
5152
},
5253
'ViewFormat': 'PDF',
5354
'RenderOptions': {
54-
'JpgQuality': 50
55+
'PdfOptimizationOptions': {
56+
'CompressImages': true,
57+
'ImageQuality': 80
58+
}
5559
}
5660
}"
5761

@@ -100,7 +104,10 @@ var viewOptions = new ViewOptions
100104
ViewFormat = ViewOptions.ViewFormatEnum.PDF,
101105
RenderOptions = new PdfOptions
102106
{
103-
JpgQuality = 50
107+
PdfOptimizationOptions = new PdfOptimizationOptions {
108+
CompressImages = true,
109+
ImageQuality = 80
110+
}
104111
}
105112
};
106113

@@ -125,7 +132,10 @@ ViewOptions viewOptions = new ViewOptions();
125132
viewOptions.setFileInfo(fileInfo);
126133
viewOptions.setViewFormat(ViewFormatEnum.PDF);
127134
PdfOptions renderOptions = new PdfOptions();
128-
renderOptions.setJpgQuality(50);
135+
PdfOptimizationOptions pdfOptimizationOptions = new PdfOptimizationOptions();
136+
pdfOptimizationOptions.setCompressImages(true);
137+
pdfOptimizationOptions.setImageQuality(80);
138+
renderOptions.setPdfOptimizationOptions(pdfOptimizationOptions);
129139
viewOptions.setRenderOptions(renderOptions);
130140

131141
ViewResult response = apiInstance.createView(new CreateViewRequest(viewOptions));
@@ -149,7 +159,10 @@ ViewOptions viewOptions = new ViewOptions();
149159
viewOptions.setFileInfo(fileInfo);
150160
viewOptions.setViewFormat(ViewFormatEnum.PDF);
151161
PdfOptions renderOptions = new PdfOptions();
152-
renderOptions.setJpgQuality(50);
162+
PdfOptimizationOptions pdfOptimizationOptions = new PdfOptimizationOptions();
163+
pdfOptimizationOptions.setCompressImages(true);
164+
pdfOptimizationOptions.setImageQuality(80);
165+
renderOptions.setPdfOptimizationOptions(pdfOptimizationOptions);
153166
viewOptions.setRenderOptions(renderOptions);
154167

155168
ViewResult response = apiInstance.createView(new CreateViewRequest(viewOptions));
@@ -179,7 +192,12 @@ $fileInfo->setFilePath("SampleFiles/with_jpg_image.pptx");
179192
$viewOptions->setFileInfo($fileInfo);
180193
$viewOptions->setViewFormat(Model\ViewOptions::VIEW_FORMAT_PDF);
181194
$renderOptions = new Model\PdfOptions();
182-
$renderOptions->setJpgQuality(50);
195+
196+
$pdfOptimizationOptions = new Model\PdfOptimizationOptions();
197+
$pdfOptimizationOptions->setCompressImages(true);
198+
$pdfOptimizationOptions->setImageQuality(80);
199+
$renderOptions->setPdfOptimizationOptions($pdfOptimizationOptions);
200+
183201
$viewOptions->setRenderOptions($renderOptions);
184202

185203
$request = new Requests\CreateViewRequest($viewOptions);
@@ -205,7 +223,9 @@ let viewOptions = new viewer_cloud.ViewOptions();
205223
viewOptions.fileInfo = fileInfo;
206224
viewOptions.viewFormat = viewer_cloud.ViewOptions.ViewFormatEnum.PDF;
207225
viewOptions.renderOptions = new viewer_cloud.PdfOptions();
208-
viewOptions.renderOptions.jpgQuality = 50;
226+
viewOptions.renderOptions.pdfOptimizationOptions = new viewer_cloud.PdfOptimizationOptions();
227+
viewOptions.renderOptions.pdfOptimizationOptions.compressImages = true;
228+
viewOptions.renderOptions.pdfOptimizationOptions.imageQuality = 80;
209229

210230
let request = new viewer_cloud.CreateViewRequest(viewOptions);
211231
let response = await viewApi.createView(request);
@@ -229,7 +249,9 @@ view_options.file_info = groupdocs_viewer_cloud.FileInfo()
229249
view_options.file_info.file_path = "SampleFiles/with_jpg_image.pptx"
230250
view_options.view_format = "PDF"
231251
view_options.render_options = groupdocs_viewer_cloud.PdfOptions()
232-
view_options.render_options.jpg_quality = 50
252+
viewOptions.render_options.pdf_optimization_options = new groupdocs_viewer_cloud.PdfOptimizationOptions()
253+
viewOptions.render_options.pdf_optimization_options.compress_images = True
254+
viewOptions.render_options.pdf_optimization_options.image_quality = 80
233255

234256
request = groupdocs_viewer_cloud.CreateViewRequest(view_options)
235257
response = apiInstance.create_view(request)
@@ -253,12 +275,13 @@ viewOptions.file_info = GroupDocsViewerCloud::FileInfo.new
253275
viewOptions.file_info.file_path = "SampleFiles/with_jpg_image.pptx"
254276
viewOptions.view_format = "PDF"
255277
viewOptions.render_options = GroupDocsViewerCloud::PdfOptions.new
256-
viewOptions.render_options.jpg_quality = 50
278+
viewOptions.render_options.pdf_optimization_options = GroupDocsViewerCloud::PdfOptimizationOptions.new
279+
viewOptions.render_options.pdf_optimization_options.compress_images = true
280+
viewOptions.render_options.pdf_optimization_options.image_quality = 80
257281

258282
request = GroupDocsViewerCloud::CreateViewRequest.new(viewOptions)
259283
response = apiInstance.create_view(request)
260284

261285
```
262286

263287
{{< /tab >}} {{< /tabs >}}
264-
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
id: "pdfoptimizationoptions"
3+
url: "viewer/pdfoptimizationoptions"
4+
title: "PdfOptimizationOptions"
5+
productName: "GroupDocs.Viewer Cloud"
6+
weight: 1
7+
description: ""
8+
keywords: ""
9+
---
10+
11+
PdfOptimizationOptions data structure contains the PDF optimization options to apply to the output PDF file.
12+
13+
##### ImageOptions example #####
14+
15+
```html
16+
17+
{
18+
"Lineriaze": false,
19+
"RemoveAnnotations": false,
20+
"RemoveFormFields": false,
21+
"ConvertToGrayScale": false,
22+
"SubsetFonts": false,
23+
"CompressImages": false,
24+
"ImageQuality": 100,
25+
"ResizeImages": false,
26+
"MaxResolution": 300,
27+
"OptimizeSpreadsheets": false
28+
}
29+
30+
```
31+
32+
##### ImageOptions fields #####
33+
34+
|Name|Description
35+
|---|---
36+
|Lineriaze|Enables optimization the output PDF file for viewing online with a web browser. 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.
37+
|RemoveAnnotations|Enables removing annotation from the output PDF file.
38+
|RemoveFormFields|Enables removing form fields from a PDF file.
39+
|ConvertToGrayScale|Enables converting the output PDF file to a grayscale.
40+
|SubsetFonts|Subsets fonts in the output PDF file. If the file uses embedded fonts, it contains all font data. GroupDocs.Viewer Cloud can subset embedded fonts to reduce the file size.
41+
|CompressImages|Enables compressing images in the output PDF file. Use this option to allow other compressing options: PdfOptimizationOptions.ImageQuality and PdfOptimizationOptions.MaxResolution.
42+
|ImageQuality|Sets the image quality in the output PDF file (in percent). To change the image quality, first set the PdfOptimizationOptions.CompressImages property to true.
43+
|ResizeImages|Enables setting the maximum resolution in the output PDF file. To allow this option, set the GroupDocs.Viewer.Options.PdfOptimizationOptions.CompressImages property to true. This option allows setting the GroupDocs.Viewer.Options.PdfOptimizationOptions.MaxResolution property.
44+
|MaxResolution|Sets the maximum resolution in the output PDF file. To allow this option, set the GroupDocs.Viewer.Options.PdfOptimizationOptions.CompressImages and GroupDocs.Viewer.Options.PdfOptimizationOptions.MaxResolution properties to true. The default value is 300.
45+
|OptimizeSpreadsheets|Enables optimization of spreadsheets in the PDF files. 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.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
id: "pdfoptions"
3+
url: "viewer/pdfoptions"
4+
title: "PdfOptions"
5+
productName: "GroupDocs.Viewer Cloud"
6+
weight: 1
7+
description: ""
8+
keywords: ""
9+
---
10+
11+
PdfOptions data structure inherits [RenderOptions]({{< ref "viewer/developer-guide/data-structures/renderoptions.md" >}}) and used as part of [ViewOptions]({{< ref "viewer/developer-guide/data-structures/viewoptions.md" >}}) data structure.
12+
13+
##### ImageOptions example #####
14+
15+
```html
16+
17+
{
18+
"DocumentOpenPassword": "string",
19+
"PermissionsPassword": "string",
20+
"Permissions": ["AllowAll", "DenyModification"],
21+
"PdfOptimizationOptions": {},
22+
"ImageMaxWidth": 0,
23+
"ImageMaxHeight": 0,
24+
"ImageWidth": 0,
25+
"ImageHeight": 0
26+
}
27+
28+
```
29+
30+
##### ImageOptions fields #####
31+
32+
|Name|Description
33+
|---|---
34+
|RenderOptions fields|PdfOptions inherits all properties of [RenderOptions]({{< ref "viewer/developer-guide/data-structures/renderoptions.md" >}})
35+
|DocumentOpenPassword|The password required to open the PDF document
36+
|PermissionsPassword|The password required to change permission settings; Using a permissions password you can restrict printing, modification and data extraction
37+
|Permissions|The array of PDF document permissions. Allowed values are: AllowAll, DenyPrinting, DenyModification, DenyDataExtraction, DenyAll. Default value is AllowAll, if now permissions are set.
38+
|PdfOptimizationOptions|Contains options for rendering documents into PDF format. See [PdfOptimizationOptions]({{< ref "viewer/developer-guide/data-structures/pdfoptimizationoptions.md" >}})
39+
|ImageMaxWidth|Max width of an output image in pixels. (When converting single image to PDF only)
40+
|ImageMaxHeight|Max height of an output image in pixels. (When converting single image to PDF only)
41+
|ImageWidth|The width of the output image in pixels. (When converting single image to PDF only)
42+
|ImageHeight|The height of an output image in pixels. (When converting single image to PDF only)

0 commit comments

Comments
 (0)