プロジェクトページの操作

Aspose.Tasks for .NET はプロジェクトの総ページ数を取得できます。 GetPageCount メソッドは Aspose.Tasks.Visualization namespace はプロジェクトの総ページ数を返し、次の基準でレンダリングするオプションを指定できます: Timescale.Days、Timescale.Months または Timescale.ThirdsOfMonths。

プロジェクト内のページ数を取得する

この Project class は GetPageCount メソッドです。

異なる timescales

プロジェクトをPDFとして保存するには:

  1. Microsoft Project ファイルを読み込みます。
  2. GetPageCount メソッドを使用し、オプションの timescale 設定でプロジェクトの総ページ数を取得します。

プログラミングサンプル:プロジェクトのページ数を取得する

以下のコードは C# を使用してこれを実現する方法を示します。

1Project project = new Project("New Project.mpp");
2
3// Get number of pages,  Timescale.Months, Timescale.ThirdsOfMonths
4int iPages = project.GetPageCount();
5iPages = project.GetPageCount(Timescale.Months);
6iPages = project.GetPageCount(Timescale.ThirdsOfMonths);

ビューごとのページ数の取得

Aspose.Tasks for .NET は次のビューを PDF にレンダリングすることをサポートします: Resource UsageResource Sheet、および Task Usage ビューを PDF にレンダリングします。各ビューごとにページ数を個別に計算することもできます。このプログラミングサンプルはプロジェクトの使用状況ビューをレンダリングし、レンダリング結果のページ数を取得する方法を示します。

例:ビューのページ数を取得する (C#)

1Project project = new Project("New Project.mpp");
2
3// Get number of pages,  Months and  ThirdsOfMonths
4Console.WriteLine(string.Format("Number of Pages = '{0}'", project.GetPageCount(PresentationFormat.ResourceUsage, Timescale.Days)));
5Console.WriteLine(string.Format("Number of Pages = '{0}'", project.GetPageCount(PresentationFormat.ResourceUsage, Timescale.Months)));
6Console.WriteLine(string.Format("Number of Pages = '{0}'", project.GetPageCount(PresentationFormat.ResourceUsage, Timescale.ThirdsOfMonths)));

日付範囲でページ数をフィルタリングする

特定の日付範囲(開始–終了)のページ数を計算する必要がある場合、 Aspose.Tasks は、 GetPageCount メソッドのオーバーロードで、 DateTime パラメータを受け取ります。

プログラミングサンプル:開始日と終了日に基づいてページ数を取得する

 1Project project = new Project("New Project.mpp");
 2
 3ImageSaveOptions options = new ImageSaveOptions(SaveFileFormat.PNG)
 4{
 5    SaveToSeparateFiles = true,
 6    PageSize = PageSize.A3,
 7    Timescale = Timescale.Months,
 8    StartDate = project.Get(Prj.StartDate) - TimeSpan.FromDays(10),
 9    EndDate = project.Get(Prj.FinishDate) + TimeSpan.FromDays(30)
10};
11int pageCount = project.GetPageCount(
12    PageSize.A3,
13    Timescale.Months,
14    project.Get(Prj.StartDate) - TimeSpan.FromDays(10),
15    project.Get(Prj.FinishDate) + TimeSpan.FromDays(30));
16
17Console.WriteLine(pageCount);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.