일반적인 변환 옵션
이 기사에서는 Microsoft Project MPP 파일을 그래픽 형식 (PDF, TIFF, PNG, SVG, HTML)으로 전환하는 데 공통적 인 옵션을 설명합니다. .NET API 용 작업을 사용하여 MS Project MPP, Primavera P6 XML, Primavera XER 또는 기타 지원되는 입력 형식에서 PDF 또는 그래픽 형식으로로드 된 프로젝트를 변환하는 데 사용할 수 있습니다. 이 경우 특정 프로젝트의 견해는 지정된 형식으로 렌더링됩니다.
저장을위한보기 지정
Microsoft Project는 ‘Gantt Chart’, ‘Task Usage’, ‘Resource Usage’등과 같은 다양한보기를 지원합니다. 각보기는 사용자 정의 할 수 있으며 이러한 설정은 MPP 파일에 저장됩니다. Aspose.Tasks for .net을 사용하면 project.views 컬렉션을 사용하여 이러한 설정을 검사하고 변경할 수 있습니다.
프로젝트가 그래픽 형식으로 저장 될 때 내보낼 뷰를 지정하는 3 가지 방법이 있습니다.
- 보기를 명시 적으로 지정하지 마십시오. 이 경우 project.defaultView가 렌더링됩니다. 기본보기가 누락되면 Gantt 차트보기가 렌더링됩니다.
- saveOptions.presentationFormat를 사용하여 PresentationFormat 열거의 값을 지정하십시오. 이 경우 특파원 화면 속성이있는보기는 Project.Views Collection에서 선택됩니다. View가 누락되면 표준 형식의 기본 GanttChart View가 사용됩니다.
- SaveOptions.ViewSettings 속성을 사용하여 렌더링 할 뷰 개체를 명시 적으로 지정하십시오. 보기 객체가 지정되면 SaveOptions.presentationFormat의 값이 무시됩니다.
페이지 크기 지정
Microsoft 프로젝트 파일을 PDF, 이미지 또는 XPS로 렌더링 할 때는 적절한 페이지 크기를 지정하는 것이 중요합니다. 이를 통해 올바른 차트 스케일링을 보장하고 잘린 데이터의 위험을 줄이며 문서를 비즈니스 프로세스에 더 잘 통합 할 수 있습니다. Aspose.Tasks를 사용하면 표준 및 사용자 정의 페이지 크기를 지정할 수 있으며 MPP 파일의 저장된 설정을 사용할 수 있습니다.
페이지 크기는 다음 방법으로 지정할 수 있습니다.
- 페이지 크기를 지정하지 마십시오. 이 경우 pagesize.a4가 사용됩니다.
- SaveOptions.Pagesize 속성을 통해 미리 정의 된 페이지를 지정하십시오.
1 Project project = new Project("Project.mpp");
2 PdfSaveOptions saveOptions = new PdfSaveOptions()
3 {
4 PresentationFormat = PresentationFormat.GanttChart,
5 PageSize = PageSize.A2
6 };
7
8project.Save("OutputFitToA2.pdf", saveOptions);
- Specify custom PageSize via SaveOptions.CustomPageSize property:
1 Project project = new Project("Project.mpp");
2 PdfSaveOptions saveOptions = new PdfSaveOptions()
3 {
4 PresentationFormat = PresentationFormat.GanttChart,
5 CustomPageSize = new SizeF(700, 900),
6 };
7
8 project.Save("OutputFitToCustomPage.pdf", saveOptions);
- Specify PageSize.DefinedInView to use page size saved in MS Project’s Page Setup dialog:
The option is applicable when input file is in MS Project MPP format
1 Project project = new Project("Project.mpp");
2
3 var taskUsageView= project.Views.FirstOrDefault(v => v.Screen == ViewScreen.TaskUsage);
4 taskUsageView.PageInfo.PageSettings.PaperSize = PrinterPaperSize.PaperEnvelope10;
5
6 PdfSaveOptions saveOptions = new PdfSaveOptions()
7 {
8 ViewSettings = taskUsageView,
9 PageSize = PageSize.DefinedInView
10 };
11
12 project.Save("OutputToEnvelope.pdf", saveOptions);
Note: The PageSize.DefinedInView
option is only effective when the source file is an MPP file and contains a view with saved page setup settings. If the view does not contain page setup information or the input file format is not MPP (e.g., XML), this option will have no effect.
Fitting Contents to Cell Size
Commonly, a task (or resource) name is so long that it is truncated when project views are rendered. Aspose.Tasks for .NET provides the FitContent property in the SaveOptions class to avoid truncation of task and resource names. The code example below renders a project to PDF format with the FitContent property set to true.
1Project project = new Project("New Project.mpp");
2SaveOptions options = new PdfSaveOptions();
3
4// Set option fit content to true
5options.FitContent = true;
6options.Timescale = Timescale.Months;
7options.PresentationFormat = PresentationFormat.TaskUsage;
8project.Save("FitContentsToCellSize_out.pdf", options);
Here is an examples of an output file without and with FitContent option:
Printing or Hiding Legends when Rendering
To let you print or hide the legends on each page, the SaveOptions class provides the LegendOnEachPage property. If this flag is set to true, legends are printed on each page in the out
1 SaveOptions options = new PdfSaveOptions();
2
3 // Set the LegendDrawingOptions property to NoLegend to hide legends
4 options.LegendDrawingOptions = LegendDrawingOptions.NoLegend;
Saving to Multiple PDF or graphical files
To save project data to multiple PDF files, set the SaveToSeparateFiles flag to true.
1Project project = new Project("New Project.mpp");
2PdfSaveOptions options = new PdfSaveOptions();
3options.SaveToSeparateFiles = true;
4options.Pages = new List<int>();
5options.Pages.Add(1);
6options.Pages.Add(4);
7project.Save("SaveToMultiplePDFFiles_out.pdf", (SaveOptions)options);