Skip to content

Commit f1f3925

Browse files
ConvertAndDownload page, edited RenderOptions
1 parent 9c00d9b commit f1f3925

3 files changed

Lines changed: 299 additions & 16 deletions

File tree

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
---
2+
id: "convert-and-download"
3+
url: "viewer/convert-and-download"
4+
title: "Convert and download document"
5+
productName: "GroupDocs.Viewer Cloud"
6+
weight: 5
7+
description: ""
8+
keywords: ""
9+
toc: True
10+
---
11+
12+
GroupDocs.Viewer Cloud API enables you to to render documents using single API call, passing input file in the request body, and getting result file stream in the response.
13+
This example demonstrates how to render document without using cloud storage.
14+
15+
Method parameters:
16+
17+
|Name|Type|Description|Comment
18+
|---|---|---|---
19+
|format|string|Requested conversion format: HTML, JPG, PNG or PDF|Required.
20+
|File|binary|Input file to convert|Form data, Required
21+
|pages|string|Pages range to render, like "1,2" or "3-5,10"|Default value : all pages
22+
|password|string|Input document password|Required for password-protected documents.
23+
24+
## Resource URI
25+
26+
```HTTP PUT ~/convertAndDownload```
27+
28+
[Swagger UI](https://reference.groupdocs.cloud/viewer/) lets you call this REST API directly from the browser.
29+
30+
## cURL example
31+
32+
{{< tabs "example1">}}
33+
{{< tab "Request" >}}
34+
```bash
35+
# First get JSON Web Token
36+
# Please get your Client Id and Client Secret from https://dashboard.groupdocs.cloud/applications. Kindly place Client Id in "client_id" and Client Secret in "client_secret" argument.
37+
curl -v "https://api.groupdocs.cloud/connect/token" \
38+
-X POST \
39+
-d "grant_type=client_credentials&client_id=xxxx&client_secret=xxxx" \
40+
-H "Content-Type: application/x-www-form-urlencoded" \
41+
-H "Accept: application/json"
42+
43+
# cURL example to get document information
44+
curl -v "https://api.groupdocs.cloud/v2.0/viewer/convertAndDownload" \
45+
-X PUT \
46+
-H "Content-Type: multipart/form-data" \
47+
-H "Accept: application/json" \
48+
-H "Authorization: Bearer <jwt token>"
49+
--data-binary "@path/to/file"
50+
```
51+
{{< /tab >}} {{< tab "Resonse" >}}
52+
```json
53+
Code 200
54+
<binary file>
55+
```
56+
{{< /tab >}} {{< /tabs >}}
57+
58+
## SDK examples
59+
60+
The API is completely independent of your operating system, database system or development language. We provide and support API SDKs in many development languages in order to make it even easier to integrate. You can see our available SDKs list [here](https://github.com/groupdocs-viewer-cloud).
61+
62+
{{< tabs "example1-sdk">}}
63+
{{< tab "C#" >}}
64+
```cs
65+
// For complete examples and data files, please go to https://github.com/groupdocs-viewer-cloud/groupdocs-viewer-cloud-dotnet-samples
66+
string MyClientSecret = ""; // Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
67+
string MyClientId = ""; // Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
68+
69+
var configuration = new Configuration(MyClientId, MyClientSecret);
70+
var apiInstance = new ViewApi(configuration);
71+
72+
var format = "jpg";
73+
var request = new ConvertAndDownloadRequest(format, File.OpenRead("myfile.txt"));
74+
var result = apiInstance.ConvertAndDownload(request);
75+
```
76+
{{< /tab >}}
77+
{{< tab "PHP">}}
78+
```php
79+
// For complete examples and data files, please go to https://github.com/groupdocs-viewer-cloud/groupdocs-viewer-cloud-php-samples
80+
use GroupDocs\Viewer\Model;
81+
use GroupDocs\Viewer\Model\Requests;
82+
83+
$ClientId = ""; // Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
84+
$ClientSecret = ""; // Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
85+
86+
$configuration = new GroupDocs\Viewer\Configuration();
87+
$configuration->setAppSid($ClientId);
88+
$configuration->setAppKey($ClientSecret);
89+
90+
$apiInstance = new GroupDocs\Viewer\ViewApi($configuration);
91+
92+
$format ="jpg";
93+
$path = __DIR__ . 'myfile.txt';
94+
95+
$request = new Requests\convertAndDownloadRequest($format, $path);
96+
97+
$result = $apiInstance->convertAndDownload($request);
98+
```
99+
{{< /tab >}}
100+
{{< tab "Java">}}
101+
```java
102+
103+
// For complete examples and data files, please go to https://github.com/groupdocs-viewer-cloud/groupdocs-viewer-cloud-java-samples
104+
string MyClientSecret = ""; // Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
105+
string MyClientId = ""; // Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
106+
107+
Configuration configuration = new Configuration(MyClientId, MyClientSecret);
108+
ViewApi apiInstance = new ViewApi(configuration);
109+
110+
String format = "pdf";
111+
File fileObj = new File("myfile.txt");
112+
113+
ConvertAndDownloadRequest request = new ConvertAndDownloadRequest(format, fileObj, null, null);
114+
115+
File file = apiInstance.convertAndDownload(request);
116+
```
117+
{{< /tab >}}
118+
{{< tab "Ruby">}}
119+
```ruby
120+
# For complete examples and data files, please go to https://github.com/groupdocs-viewer-cloud/groupdocs-viewer-cloud-ruby-samples
121+
require 'groupdocs_viewer_cloud'
122+
123+
$client_id = "XXXX-XXXX-XXXX-XXXX" # Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
124+
$client_secret = "XXXXXXXXXXXXXXXX" # Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
125+
126+
apiInstance = GroupDocsViewerCloud::ViewApi.from_keys($client_id, $client_secret)
127+
128+
format = "jpg"
129+
file = File.open("myfile.txt", "r")
130+
131+
request = ConvertAndDownloadRequest.new format, file
132+
133+
response = apiInstance.convert_and_download(request)
134+
```
135+
{{< /tab >}}
136+
{{< tab "Node.js">}}
137+
```js
138+
// For complete examples and data files, please go to https://github.com/groupdocs-viewer-cloud/groupdocs-viewer-cloud-node-samples
139+
global.viewer# require("groupdocs-viewer-cloud");
140+
141+
global.clientId = "XXXX-XXXX-XXXX-XXXX"; // Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
142+
global.clientSecret = "XXXXXXXXXXXXXXXX"; // Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
143+
144+
global.viewApi = viewer_cloud.ViewApi.fromKeys(clientId, clientSecret);
145+
146+
var format = "jpg";
147+
let filebuf = fs.readFileSync("myfile.txt");
148+
149+
var request = new ConvertAndDownloadRequest(format, filebuf);
150+
let response = await viewApi.convertAndDownload(request);
151+
```
152+
{{< /tab >}}
153+
{{< tab "Python">}}
154+
```py
155+
# For complete examples and data files, please go to https://github.com/groupdocs-viewer-cloud/groupdocs-viewer-cloud-python-samples
156+
import groupdocs_viewer_cloud
157+
158+
client_id = "XXXX-XXXX-XXXX-XXXX" # Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
159+
client_secret = "XXXXXXXXXXXXXXXX" # Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
160+
161+
apiInstance = groupdocs_viewer_cloud.ViewApi.from_keys(client_id, client_secret)
162+
163+
format = "jpg"
164+
file = File.open("myfile.txt", "r")
165+
166+
request = ConvertAndDownloadRequest.new format, file
167+
168+
response = apiInstance.convert_and_download(request)
169+
```
170+
{{< /tab >}}
171+
{{< /tabs >}}

content/viewer/developer-guide/data-structures/renderoptions.md

Lines changed: 127 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,44 +17,122 @@ Not all options are supported by all document formats. Each option may correspon
1717
### RenderOptions example
1818

1919
```json
20-
{
20+
{
2121
"StartPageNumber": 0,
2222
"CountPagesToRender": 0,
23+
"PagesToRender": [
24+
0
25+
],
26+
"PageRotations": [
27+
{
28+
"PageNumber": 0,
29+
"RotationAngle": "On90Degree"
30+
}
31+
],
2332
"DefaultFontName": "string",
2433
"DefaultEncoding": "string",
34+
"DetectEncoding": true,
2535
"RenderComments": true,
36+
"RenderNotes": true,
2637
"RenderHiddenPages": true,
2738
"SpreadsheetOptions": {
2839
"PaginateSheets": true,
2940
"CountRowsPerPage": 0,
41+
"CountColumnsPerPage": 0,
3042
"RenderGridLines": true,
3143
"RenderEmptyRows": true,
3244
"RenderEmptyColumns": true,
3345
"RenderHiddenRows": true,
3446
"RenderHiddenColumns": true,
35-
"RenderPrintAreaOnly": true
47+
"RenderHeadings": true,
48+
"RenderPrintAreaOnly": true,
49+
"TextOverflowMode": "Overlay"
3650
},
3751
"CadOptions": {
3852
"ScaleFactor": 0,
3953
"Width": 0,
40-
"Height": 0
54+
"Height": 0,
55+
"Tiles": [
56+
{
57+
"StartPointX": 0,
58+
"StartPointY": 0,
59+
"Width": 0,
60+
"Height": 0
61+
}
62+
],
63+
"RenderLayouts": true,
64+
"LayoutName": "string",
65+
"Layers": [
66+
"string"
67+
]
4168
},
4269
"EmailOptions": {
43-
"PageSize": "string",
70+
"PageSize": "Unspecified",
4471
"FieldLabels": [
4572
{
4673
"Field": "string",
4774
"Label": "string"
4875
}
49-
]
76+
],
77+
"DateTimeFormat": "string",
78+
"TimeZoneOffset": "string"
5079
},
5180
"ProjectManagementOptions": {
52-
"PageSize": "string",
53-
"TimeUnit": "string",
54-
"StartDate": "2019-02-26T10:48:23.911Z",
55-
"EndDate": "2019-02-26T10:48:23.911Z"
81+
"PageSize": "Unspecified",
82+
"TimeUnit": "Unspecified",
83+
"StartDate": "2024-03-25T06:24:32.674Z",
84+
"EndDate": "2024-03-25T06:24:32.674Z"
85+
},
86+
"PdfDocumentOptions": {
87+
"DisableCharsGrouping": true,
88+
"EnableLayeredRendering": true,
89+
"EnableFontHinting": true,
90+
"RenderOriginalPageSize": true,
91+
"ImageQuality": "Low",
92+
"RenderTextAsImage": true,
93+
"FixedLayout": true,
94+
"WrapImagesInSvg": true,
95+
"DisableFontLicenseVerifications": true
96+
},
97+
"WordProcessingOptions": {
98+
"RenderTrackedChanges": true,
99+
"LeftMargin": 0,
100+
"RightMargin": 0,
101+
"TopMargin": 0,
102+
"BottomMargin": 0
103+
},
104+
"OutlookOptions": {
105+
"Folder": "string",
106+
"TextFilter": "string",
107+
"AddressFilter": "string",
108+
"MaxItemsInFolder": 0
109+
},
110+
"ArchiveOptions": {
111+
"Folder": "string",
112+
"FileName": "string",
113+
"ItemsPerPage": 0
114+
},
115+
"TextOptions": {
116+
"MaxCharsPerRow": 0,
117+
"MaxRowsPerPage": 0
118+
},
119+
"MailStorageOptions": {
120+
"TextFilter": "string",
121+
"AddressFilter": "string",
122+
"MaxItems": 0
123+
},
124+
"VisioRenderingOptions": {
125+
"RenderFiguresOnly": true,
126+
"FigureWidth": 0
127+
},
128+
"WebDocumentOptions": {
129+
"PageSize": "Unspecified",
130+
"LeftMargin": 0,
131+
"RightMargin": 0,
132+
"TopMargin": 0,
133+
"BottomMargin": 0
56134
}
57-
}
135+
}
58136

59137
```
60138

@@ -79,10 +157,44 @@ Not all options are supported by all document formats. Each option may correspon
79157
|CadOptions.ScaleFactor|The scale factor affects the size of an output document.
80158
|CadOptions.Width|The width of the render result in pixels.
81159
|CadOptions.Height|The height of the render result in pixels.
82-
|EmailOptions.PageSize|The size of the output page when rendering as PDF or image.Supported values {Unknown|Letter|Ledger|A0|A1|A2|A3}: 1. Unknown - the default, unspecified page size. 2. Letter - the size of the Letter page in points is 792x612.3. Ledger - the size of the Letter page in points is 1224x792. 4. A0 - the size of the A0 page in points is 3371x2384. 5. A1 - the size of the A1 page in points is 2384x1685. 6. A2 - the size of the A2 page in points is 1684x1190. 7. A3 - the size of the A3 page in points is 1190x842. 8. A4 - the size of the A4 page in points is 842x595.
83-
|EmailOptions.FieldLabels|The list of supported email message field labels
84-
|ProjectManagementOptions.PageSize|The size of the page. Supported values {Unknown|Letter|A0|A1|A2|A3}: 1. Unknown - the default, unspecified page size. 2. Letter - the size of the Letter page in points is 792 × 612. 3. Ledger - the size of the Letter page in points is 1224 × 792. 4. A0 - the size of the A0 page in points is 3371 × 2384. 5. A1 - the size of the A1 page in points is 2384 × 1685. 6. A2 - the size of the A2 page in points is 1684 × 1190. 7. A3 - the size of the A3 page in points is 1190 × 842. 8. A4 - the size of the A4 page in points is 842 × 595.
85-
|ProjectManagementOptions.TimeUnit|The time unit to use as minimal point.
86-
Supported values {Unknown|Days|ThirdsOfMonths|Months}: 1. Unknown - unknown, unspecified time scale. 2. Days - one day interval. 3. ThirdsOfMonths - one third of the month. 4. Months - one month interval.
160+
|EmailOptions.PageSize|The size of the output page when rendering as PDF or image.Supported values {Unknown,Letter,Ledger,A0,A1,A2,A3}: 1. Unknown - the default, unspecified page size. 2. Letter - the size of the Letter page in points is 792x612.3. Ledger - the size of the Letter page in points is 1224x792. 4. A0 - the size of the A0 page in points is 3371x2384. 5. A1 - the size of the A1 page in points is 2384x1685. 6. A2 - the size of the A2 page in points is 1684x1190. 7. A3 - the size of the A3 page in points is 1190x842. 8. A4 - the size of the A4 page in points is 842x595.
161+
|EmailOptions.FieldLabels|The list of supported email message field labels.
162+
|EmailOptions.DateTimeFormat|Time Format (can be include TimeZone) for example: 'MM d yyyy HH:mm tt', if not set - current system format is used.
163+
|EmailOptions.TimeZoneOffset|Message time zone offset. Format should be compatible with .net TimeSpan
164+
|ProjectManagementOptions.PageSize|The size of the page. Supported values {Unknown,Letter,A0,A1,A2,A3}: 1. Unknown - the default, unspecified page size. 2. Letter - the size of the Letter page in points is 792 × 612. 3. Ledger - the size of the Letter page in points is 1224 × 792. 4. A0 - the size of the A0 page in points is 3371 × 2384. 5. A1 - the size of the A1 page in points is 2384 × 1685. 6. A2 - the size of the A2 page in points is 1684 × 1190. 7. A3 - the size of the A3 page in points is 1190 × 842. 8. A4 - the size of the A4 page in points is 842 × 595.
165+
|ProjectManagementOptions.TimeUnit|The time unit to use as minimal point. Supported values {Unknown,Days,ThirdsOfMonths,Months}: 1. Unknown - unknown, unspecified time scale. 2. Days - one day interval. 3. ThirdsOfMonths - one third of the month. 4. Months - one month interval.
87166
|ProjectManagementOptions.StartDate|The start date of a Gantt Chart View to render.
88167
|ProjectManagementOptions.EndDate|The end date of a Gantt Chart View to render.
168+
|PdfDocumentOptions.DisableCharsGrouping|Disables chars grouping to keep maximum precision during chars positioning when rendering the page.
169+
|PdfDocumentOptions.EnableLayeredRendering|Enables rendering of text and graphics according to z-order in original PDF document when rendering into HTML.
170+
|PdfDocumentOptions.EnableFontHinting|Enables font hinting. The font hinting adjusts the display of an outline font. Supported only for TTF fonts when these fonts are used in source document.
171+
|PdfDocumentOptions.RenderOriginalPageSize|When this option enabled the output pages will have the same size in pixels as page size in a source PDF document. By default GroupDocs.Viewer calculates output image page size for better rendering quality. This option is supported when rendering into PNG or JPG formats.
172+
|PdfDocumentOptions.ImageQuality|Specifies output image quality for image resources when rendering into HTML. The default value is Low.
173+
|PdfDocumentOptions.RenderTextAsImage|When this option is set to true, the text is rendered as an image in the output HTML. Enable this option to make text unselectable or to fix characters rendering and make HTML look like PDF. The default value is false. This option is supported when rendering into HTML.
174+
|PdfDocumentOptions.FixedLayout|Enables rendering the PDF and EPUB documents to HTML with a fixed layout.
175+
|PdfDocumentOptions.WrapImagesInSvg|Enables wrapping each image in the output HTML document in SVG tag to improve the output quality.
176+
|PdfDocumentOptions.DisableFontLicenseVerifications|Disables any license restrictions for all fonts in the current XPS/OXPS document.
177+
|WordProcessingOptions.RenderTrackedChanges|Enables tracked changes (revisions) rendering.
178+
|WordProcessingOptions.LeftMargin|Left page margin (for HTML rendering only).
179+
|WordProcessingOptions.RightMargin|Right page margin (for HTML rendering only).
180+
|WordProcessingOptions.TopMargin|Top page margin (for HTML rendering only).
181+
|WordProcessingOptions.BottomMargin|Bottom page margin (for HTML rendering only).
182+
|OutlookOptions.Folder|The name of the folder (e.g. Inbox, Sent Item or Deleted Items) to render.
183+
|OutlookOptions.TextFilter|The keywords used to filter messages.
184+
|OutlookOptions.AddressFilter|The email-address used to filter messages by sender or recipient.
185+
|OutlookOptions.MaxItemsInFolder|The maximum number of messages or items, that can be rendered from one folder.
186+
|ArchiveOptions.Folder|The folder inside the archive to be rendered.
187+
|ArchiveOptions.FileName|The filename to display in the header. By default the name of the source file is displayed.
188+
|ArchiveOptions.ItemsPerPage|Number of records per page (for rendering to HTML only).
189+
|TextOptions.MaxCharsPerRow|Max chars per row on page. Default value is 85.
190+
|TextOptions.MaxRowsPerPage|Max rows per page. Default value is 55.
191+
|MailStorageOptions.TextFilter|The keywords used to filter messages.
192+
|MailStorageOptions.AddressFilter|The email-address used to filter messages by sender or recipient.
193+
|MailStorageOptions.MaxItems|The maximum number of messages or items for render. Default value is 0 - all messages will be rendered.
194+
|VisioRenderingOptions.RenderFiguresOnly|Render only Visio figures, not a diagram.
195+
|VisioRenderingOptions.FigureWidth|Figure width, height will be calculated automatically. Default value is 100.
196+
|WebDocumentOptions.PageSize|The size of the output page. The default value is GroupDocs.Viewer.Options.PageSize.Letter 792 x 612 points. When contents does not fit set a larger page size e.g. GroupDocs.Viewer.Options.PageSize.A3.
197+
|WebDocumentOptions.LeftMargin|The distance (in points) between the left edge of the page and the left boundary of the body text. The default value is 5 points.
198+
|WebDocumentOptions.RightMargin|The distance (in points) between the right edge of the page and the left boundary of the body text. The default value is 5 points.
199+
|WebDocumentOptions.TopMargin|The distance (in points) between the top edge of the page and the left boundary of the body text. The default value is 5 points.
200+
|WebDocumentOptions.BottomMargin|The distance (in points) between the bottom edge of the page and the left boundary of the body text. The default value is 5 points.

docs-cloud-common

Submodule docs-cloud-common updated 247 files

0 commit comments

Comments
 (0)