Exporting report to PDF
This article describes how to export a report using the FastReport Corporate Server report processor.
Getting started
You will need the following tools and features:
Knowledge on how to use API key in FastReport Corporate Server.
This article does not include the information about authentication and authorization.
The curl tool.
Any other REST client will work, however, the examples are provided for curl.
A report.
You can learn how to build a report from the article Prepeare a report.
Active subscription for FastReport Corporate Server.
Internet access.
Remark
Please note that you can export the report directly from the template, without saving it in the process. To do this, run the same commands for the report template, replacing Report in the request line with Template; also use the template identifier, not that of the report.
Instructions
To export a report to PDF, you will need a report identifier. Make a
GET
request tohttps://fastreport.cloud/api/rp/v1/Report/Root
to get the root directory.A sample request.
curl -X GET "https://fastreport.cloud/api/rp/v1/Reports/Root" -H "accept: text/plain"
A sample response.
{ "name": "RootFolder", "parentId": null, "tags": null, "icon": null, "type": "Folder", "size": 16384, "subscriptionId": "5fa919fa292a8300019349bc", "status": "None", "id": "5fa919f9292a8300019349ba", "createdTime": "2020-11-09T10:29:13.993Z", "creatorUserId": "5af5a8dc-8cb0-40f9-ac99-ca2533fa4491", "editedTime": "0001-01-01T00:00:00Z", "editorUserId": null }
The directory identifier from the example above is
5fa919f9292a8300019349ba
.Get a list of files in the directory; to do this, execute a
GET
request tohttps://fastreport.cloud/api/rp/v1/Reports/Folder/{id}/ListFiles?skip=0&take=10
, substituting{id}
with the directory identifier.A sample request.
curl -X GET "https://fastreport.cloud/api/rp/v1/Reports/Folder/5fa919f9292a8300019349ba/ListFiles?skip=0&take=10" -H "accept: text/plain"
A sample response.
[ { "templateId": "5fc9ece6b792c90001d94b13", "reportInfo": null, "name": "awesome_report.fpx", "parentId": "5fa919f9292a8300019349ba", "tags": null, "icon": null, "type": "File", "size": 16927, "subscriptionId": "5fa919fa292a8300019349bc", "status": "Success", "id": "5fe4614bcd7c55000148e4c6", "createdTime": "2020-12-24T09:37:15.716Z", "creatorUserId": "5af5a8dc-8cb0-40f9-ac99-ca2533fa4491", "editedTime": "2020-12-24T09:37:15.716Z", "editorUserId": "5af5a8dc-8cb0-40f9-ac99-ca2533fa4491" } ]
The report identifier from the example above is
5fe4614bcd7c55000148e4c6
.To export a report, you need a directory where you should place the export file.
To get the root directory for exports, make a
GET
request tohttps://fastreport.cloud/api/rp/v1/Exports/Root
.A sample request.
curl -X GET "https://fastreport.cloud/api/rp/v1/Exports/Root" -H "accept: text/plain"
A sample response.
{ "name": "RootFolder", "parentId": null, "tags": null, "icon": null, "type": "Folder", "size": 16384, "subscriptionId": "5fa919fa292a8300019349bc", "status": "None", "id": "5fa919fa292a8300019349bb", "createdTime": "2020-11-09T10:29:14.002Z", "creatorUserId": "5af5a8dc-8cb0-40f9-ac99-ca2533fa4491", "editedTime": "0001-01-01T00:00:00Z", "editorUserId": null }
The directory identifier from the example above is
5fa919fa292a8300019349bb
.To export the report, make a
POST
request tohttps://fastreport.cloud/api/rp/v1/Reports/File/{id}/Export
, substituting{id}
with the report identifier.Send JSON in the body of the request according to the scheme below.
{ "fileName": "string", "folderId": "string", "format": "Pdf", "exportParameters": { "additionalProp1": {}, "additionalProp2": {}, "additionalProp3": {} } }
folderId
— the identifier of the directory where the export will be placed.fileName
— the name of the resulting file, add the extension.pdf
manually.format
— the export format.exportParameters
— a set of export options. They are set in the same way as the parameters of export from the FastReport .NET library.
A sample request.
curl -X POST "https://fastreport.cloud/api/rp/v1/Reports/File/5fe4614bcd7c55000148e4c6/Export" -H "accept: text/plain" -H "Content-Type: application/json-patch+json" -d "{ \"fileName\": \"awesome_result.pdf\", \"folderId\": \"5fa919fa292a8300019349bb\", \"format\": \"Pdf\",}"
A sample response.
{ "format": "Pdf", "reportId": "5fe4614bcd7c55000148e4c6", "name": "awesome_result.pdf", "parentId": "5fa919fa292a8300019349bb", "tags": null, "icon": null, "type": "File", "size": 16384, "subscriptionId": "5fa919fa292a8300019349bc", "status": "InQueue", "id": "5fe46a33cd7c55000148e4c7", "createdTime": "2020-12-24T10:15:15.8039648+00:00", "creatorUserId": "5af5a8dc-8cb0-40f9-ac99-ca2533fa4491", "editedTime": "2020-12-24T10:15:15.8039697+00:00", "editorUserId": "5af5a8dc-8cb0-40f9-ac99-ca2533fa4491" }
Take note that the file has the
InQueue
status, which means an export task was created and got into the builder's queue; at this stage, the file received its identifier5fe46a33cd7c55000148e4c7
for the process.Wait for a while, until the file is exported.
To get information about the file, make a
GET
request tohttps://fastreport.cloud/api/rp/v1/Exports/File/{id}
, having replaced{id}
with the export identifier.A sample request.
curl -X GET "https://fastreport.cloud/api/rp/v1/Exports/File/5fe46a33cd7c55000148e4c7" -H "accept: text/plain"
A sample response.
{ "format": "Pdf", "reportId": "5fe4614bcd7c55000148e4c6", "name": "awesome_result.pdf", "parentId": "5fa919fa292a8300019349bb", "tags": null, "icon": null, "type": "File", "size": 41142, "subscriptionId": "5fa919fa292a8300019349bc", "status": "Success", "id": "5fe46a33cd7c55000148e4c7", "createdTime": "2020-12-24T10:15:15.803Z", "creatorUserId": "5af5a8dc-8cb0-40f9-ac99-ca2533fa4491", "editedTime": "2020-12-24T10:15:15.803Z", "editorUserId": "5af5a8dc-8cb0-40f9-ac99-ca2533fa4491" }
Take note of the file`s
Success
status. The report has been successfully exported.To download the report, make a
GET
request tohttps://fastreport.cloud/download/e/{id}
, having replaced{id}
with the report identifier.A sample request.
curl -X GET "https://fastreport.cloud/download/e/5fe46a33cd7c55000148e4c7" -H "accept: text/plain"
The file will be received in response.