Create Report in PDF Format Introduction
This example allows you to returns created report in PDF format using Aspose.Tasks Cloud API in your applications. You can use our REST API with any language: .NET, Java, PHP, Ruby, Rails, Python, Objective C, jQuery and many more.
API
Type
Description
Resource Link
/tasks/{name}/report
GET
Returns created report in PDF format
GetReportPdf
cURL Example
SDKs
The Aspose.Tasks Cloud SDKs can be downloaded from the following page: Available SDKs
SDK Examples
C#
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
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var remoteName = await UploadFileToStorageAsync("Home move plan.mpp");
var response = await TasksApi.GetReportPdfAsync(new GetReportPdfRequest()
{
Type = ReportType.Milestones,
Name = remoteName,
Folder = this.DataFolder
});
Assert.IsTrue(response.Length > 0);
var buffer = new byte[4];
response.Read(buffer, 0, 4);
Assert.AreEqual("%PDF", Encoding.ASCII.GetString(buffer));
PHP
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
<?
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-php/
$remoteName = "testGetReportPdf.mpp";
$folder = $this->uploadFile("Home move plan.mpp", $remoteName, '');
$response = $this->tasks->getReportPdf(new GetReportPdfRequest($remoteName, Model\ReportType::MILESTONES, self::$storageName, $folder));
Assert::assertNotNull($response);
Assert::assertEquals("%PDF", $response->fread(4));
Python
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
# For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-python
filename = 'Home_move_plan.mpp'
self.upload_file(filename)
get_request = GetReportPdfRequest(filename, ReportType.MILESTONES)
get_result = self.tasks_api.get_report_pdf(get_request)
self.assertIsNotNone(get_result)
with open(get_result, encoding='utf-8', errors='ignore') as f:
self.assertTrue(f.readable())
self.assertIn('%PDF-1.5', f.readline())
Node.js
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
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-node
const fileName = "Home_move_plan.mpp";
const localPath = "./Data/" + fileName;
const remotePath = "Temp/Data";
const remoteFullPath = remotePath + "/" + fileName;
await tasksApi.uploadFileToStorage(remoteFullPath, localPath);
const request = new GetReportPdfRequest();
request.name = fileName;
request.folder = remotePath;
request.type = ReportType.Milestones;
const result = await tasksApi.getReportPdf(request);
expect(result.response.statusCode).to.equal(200);
expect(result.body.buffer).is.not.undefined.and.not.null;
const strings = BaseTest.convertArrayBufferToStrings(result.body.buffer);
expect(strings[0]).to.equal("%PDF-1.5");
Go
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
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
opts := &requests.GetReportPdfOpts{
Type_: string(models.MILESTONES_ReportType),
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
file, response, err := client.TasksApi.GetReportPdf(ctx, opts)
if err != nil {
t.Error(err)
}
assert.Equal(t, 200, response.StatusCode)
assert.Less(t, 1, len(file))
fileAsStrings := ConvertBytesToStrings(file)
assert.Equal(t, "%PDF-1.5", fileAsStrings[0])
Java
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
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-java/
String localFileName = "Home_move_plan.mpp";
String remoteFileName = TestInitializer.UploadFile(localFileName);
GetReportPdfRequest request = new GetReportPdfRequest(remoteFileName, ReportType.MILESTONES.getValue(), null, null);
File result = TestInitializer.tasksApi.getReportPdf(request);
assertNotNull(result);
assertTrue(result.exists());
String[] fileAsStrings = ReadFileAsStrings(result);
assertEquals("%PDF-1.5", fileAsStrings[0]);