Convert Project Pages to Separate Image Files
Contents
[
Hide
Show
]To print a Project’s pages to separate output files, use the ImageSaveOptions.SaveToSeparateFiles property. It specifies whether to save pages to separate files or not. Also, the API provides the ImageSaveOptions.Pages property that contains a list of page numbers to save when saving project layouts to separate files. All pages are saved if this list is empty and ImageSaveOptions.SaveToSeparateFiles is set to true.
Printing Project Pages to Separate Files
The following code example demonstrates how to print individual pages in a project to separate files.
1System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"CreateProject2.mpp");
2System::SharedPtr<ImageSaveOptions> saveOptions = System::MakeObject<ImageSaveOptions>(Aspose::Tasks::Saving::SaveFileFormat::PNG);
3saveOptions->set_StartDate(project->Get<System::DateTime>(Prj::StartDate()).AddDays(-3));
4saveOptions->set_EndDate(project->Get<System::DateTime>(Prj::FinishDate()));
5
6saveOptions->set_MarkCriticalTasks(true);
7saveOptions->set_LegendOnEachPage(false);
8
9saveOptions->set_Gridlines(System::MakeObject<System::Collections::Generic::List<System::SharedPtr<Gridline>>>());
10
11System::SharedPtr<Gridline> gridline = System::MakeObject<Gridline>();
12gridline->set_GridlineType(Aspose::Tasks::Visualization::GridlineType::GanttRow);
13gridline->set_Color(System::Drawing::Color::get_CornflowerBlue());
14gridline->set_Pattern(Aspose::Tasks::Visualization::LinePattern::Dashed);
15saveOptions->get_Gridlines()->Add(gridline);
16
17// Save the whole project layout to one file
18project->Save(dataDir + u"PrintProjectPagesToSeparateFiles1_out.png", System::StaticCast<Aspose::Tasks::Saving::SaveOptions>(saveOptions));
19
20// Save project layout to separate files
21saveOptions->set_SaveToSeparateFiles(true);
22project->Save(dataDir + u"PrintProjectPagesToSeparateFiles2_out.png", System::StaticCast<Aspose::Tasks::Saving::SaveOptions>(saveOptions));