Printing Project Pages to Separate Image Files
Saving Project Pages to Separate Files To print the pages in a Project to separate output files, use the ImageSaveOptions.SaveToSeparateFiles property. This specifies whether to save project pages to separate files or not. Also, the API provides ImageSaveOptions.Pages property which contains a list of page numbers to save when saving project layout to separate files. All pages are saved if this list is empty and ImageSaveOptions.SaveToSeparateFiles is set to true.
The code sample below shows how to print pages to separate files.
1// For complete examples and data files, please go to https://github.com/aspose-tasks/Aspose.Tasks-for-Java
2// The path to the documents directory.
3String dataDir = Utils.getDataDir(PrintPagesToSeparateImage.class);
4
5Project project = new Project(dataDir + "CustomerFeedback.mpp");
6ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFileFormat.PNG);
7
8java.util.Calendar cal = java.util.Calendar.getInstance();
9cal.setTime(project.get(Prj.START_DATE));
10cal.add(java.util.Calendar.DATE, -3);
11
12saveOptions.setStartDate(cal.getTime());
13saveOptions.setEndDate(project.get(Prj.FINISH_DATE));
14
15saveOptions.setMarkCriticalTasks(true);
16saveOptions.setLegendOnEachPage(false);
17
18saveOptions.setGridlines(new ArrayList<Gridline>());
19
20Gridline gridline = new Gridline();
21gridline.setGridlineType(GridlineType.GanttRow);
22gridline.setColor(Color.BLUE);
23gridline.setPattern(LinePattern.Dashed);
24saveOptions.getGridlines().add(gridline);
25
26// Save the whole project layout to one file
27project.save(dataDir + "CustomerFeedback.png", saveOptions);
28
29// Save project layout to separate files
30saveOptions.setSaveToSeparateFiles(true);
31project.save(dataDir + "CustomerFeedback_.png", saveOptions);