페이지 머리글 및 바닥글 작업

MPP 파일에서 머리글 및 바닥글 정보 읽기

Aspose.Tasks for .NET API는 MPP 파일의 머리글 및 바닥글 정보를 읽는 기능을 제공합니다. 이 API는 다음의 각 탭에 해당하는 전용 클래스를 포함합니다: Microsoft Project Page Setup 대화 상자:

다음 예제는 MPP 파일에서 머리글과 바닥글 정보를 읽는 방법을 보여줍니다:

 1static void Run()
 2{
 3    // Create project and project info instances
 4    Project project = new Project("New Project.mpp");
 5    PageInfo info = project.DefaultView.PageInfo;
 6
 7    Console.WriteLine("Page data cannot be null : {0} ", !info.Equals(null));
 8
 9    if (info != null)
10    {
11        AssertHeaderFooterCorrect(info);
12        AssertPageSettingsCorrect(info);
13        AssertPageViewSettingsCorrect(info);
14        AssertMarginsCorrect(info);
15        AssertLegendCorrect(info);
16    }
17 
18}
19
20static void AssertHeaderFooterCorrect(PageInfo info)
21{
22    Console.WriteLine("Header left text Equals LEFT HEADER : {0} ", info.Header.LeftText.Equals("LEFT HEADER"));
23    Console.WriteLine("Header center text Equals CENTER HEADER : {0} ", info.Header.CenteredText.Equals("CENTER HEADER"));
24    Console.WriteLine("Header right text Equals RIGHT HEADER : {0} ", info.Header.RightText.Equals("RIGHT HEADER"));
25
26    Console.WriteLine("Footer left text Equals LEFT FOOTER : {0} ", info.Footer.LeftText.Equals("LEFT FOOTER"));
27    Console.WriteLine("Footer center text Equals CENTER FOOTER : {0} ", info.Footer.CenteredText.Equals("CENTER FOOTER"));
28    Console.WriteLine("Footer right text Equals RIGHT FOOTER : {0} ", info.Footer.RightText.Equals("RIGHT FOOTER"));
29}
30
31static void AssertPageSettingsCorrect(PageInfo info)
32{
33    Console.WriteLine("Portrait Orientation is Portrait : {0} ", info.PageSettings.IsPortrait.Equals(true));
34    Console.WriteLine("AdjustToPercentOfNormalSize is enabled : {0} ", info.PageSettings.AdjustToPercentOfNormalSize.Equals(true));
35 
36    Console.WriteLine("PercentOfNormalSize Equals 150 : {0} ", info.PageSettings.PercentOfNormalSize.Equals(150));
37    Console.WriteLine("PagesInWidth Equals 3 : {0} ", info.PageSettings.PagesInWidth.Equals(3));
38    Console.WriteLine("PagesInHeight Equals 7 : {0} ", info.PageSettings.PagesInHeight.Equals(7));
39    Console.WriteLine("PaperSize Equals PaperA4 : {0} ", info.PageSettings.PaperSize.Equals(PrinterPaperSize.PaperA4));
40    Console.WriteLine("FirstPageNumber : {0} ", info.PageSettings.FirstPageNumber);
41}
42
43static void AssertPageViewSettingsCorrect(PageInfo info)
44{
45    Console.WriteLine("PrintAllSheetColumns is set to false : {0} ", info.PageViewSettings.PrintAllSheetColumns.Equals(false));
46    Console.WriteLine("PrintFirstColumnsCountOnAllPages is set to true : {0} ", info.PageViewSettings.PrintFirstColumnsCountOnAllPages.Equals(true));
47
48    Console.WriteLine("FirstColumnsCount Equals 3 : {0} ",  info.PageViewSettings.FirstColumnsCount.Equals(3));
49    Console.WriteLine("PrintNotes is set to true : {0} ", info.PageViewSettings.PrintNotes.Equals(true));
50    Console.WriteLine("PrintBlankPages is set to false : {0} ", info.PageViewSettings.PrintBlankPages.Equals(false));
51    Console.WriteLine("FitTimescaleToEndOfPage is set to true : {0} ", info.PageViewSettings.FitTimescaleToEndOfPage.Equals(true));
52}
53
54static void AssertMarginsCorrect(PageInfo info)
55{
56    Console.WriteLine("Margins.Left Equals 1 : {0} ", (info.Margins.Left - 1 <= 1e-5) ? true : false);
57    Console.WriteLine("Margins.Top Equals 1.1 : {0} ", (info.Margins.Top - 1.1 <= 1e-5) ? true : false);
58    Console.WriteLine("Margins.Right Equals 1.2 : {0} ", (info.Margins.Right - 1.2 <= 1e-5) ? true : false);
59    Console.WriteLine("Margins.Bottom Equals 1.2 : {0} ", (info.Margins.Bottom - 1.3 <= 1e-5) ? true : false);
60
61    Console.WriteLine("Margin.Borders Equals Border.AroundEveryPage : {0} ",info.Margins.Borders.Equals(Border.AroundEveryPage));
62}
63
64static void AssertLegendCorrect(PageInfo info)
65{
66    Console.WriteLine("Legend left text Equals LEFT LEGEND : {0} ", info.Legend.LeftText.Equals("LEFT LEGEND"));
67    Console.WriteLine("Legend center text Equals CENTER LEGEND : {0} ", info.Legend.CenteredText.Equals("CENTER LEGEND"));
68    Console.WriteLine("Legend right text Equals RIGHT LEGEND : {0} ", info.Legend.RightText.Equals("RIGHT LEGEND"));
69
70    Console.WriteLine("LegendOn Equals Legend.OnEveryPage : {0} ", info.Legend.LegendOn.Equals(Legend.OnEveryPage));
71    Console.WriteLine("Legend Width Equals 5 : {0} ", (info.Legend.Width - 5 <= 1e-5) ? true : false);
72}

페이지 머리글/바닥글에 이미지 추가

Aspose.Tasks for .NET은 이미지 삽입을 포함하여 페이지 머리글과 바닥글을 조작할 수 있는 기능도 제공합니다. 아래 예제는 페이지 머리글에 이미지를 추가하는 방법을 보여줍니다:

 1Project project = new Project("New Project.mpp");
 2
 3project.RootTask.Children.Add("Task1");
 4PageInfo pageInfo = project.DefaultView.PageInfo;
 5
 6using (Image image = Image.FromFile("Image1.png"))
 7{
 8    pageInfo.Header.CenteredImage = image;
 9    pageInfo.Legend.LeftImage = image;
10    pageInfo.Legend.LeftText = string.Empty;
11    MPPSaveOptions options = new MPPSaveOptions();
12    options.WriteViewData = true;
13    project.Save("AddImageToPageHeaderFooter_out.mpp", options);
14}

Aspose.Tasks for .NET을 사용하면 개발자는 다음에 대해 완전한 제어권을 가집니다: 페이지 설정머리글, 바닥글, 여백, 범례 및 보기 설정을 포함합니다.
이러한 유연성은 다음을 생성할 수 있게 합니다: 전문적인 보고서 및 인쇄 레이아웃 을(를) 프로그래밍 방식으로 생성하여 프로젝트 문서가 Microsoft Project에서 수동으로 조정할 필요 없이 조직의 기준을 충족하도록 보장합니다.

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.