Trabajando con páginas de proyectos

Aspose.Tasks para C ++ puede recuperar el número total de páginas en un proyecto. El método GetPageCount ofrecido por Aspose.Seks ‘Visualization Space devuelve el recuento total de páginas en un proyecto con opciones de representarlos en función de Timescale.days, Timescale.Months o Timescale.

Obtenga el número de páginas en el proyecto

La clase de proyecto expone el método GetPageCount que se utiliza para obtener el número de páginas totales en un proyecto. El recuento total de páginas en un proyecto se puede recuperar para la escala de tiempo.

Para guardar un proyecto en PDF:

  1. Cargue un archivo de proyecto de Microsoft.
  2. Obtenga el recuento total de páginas del proyecto utilizando el método GetPageCount con configuración de escala de tiempo opcional.

Muestra de programación: Obtenga el número de páginas en el proyecto Las siguientes líneas de código demuestran cómo obtener varias páginas en el proyecto.

 1// The path to the documents directory.
 2System::String dataDir = RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName());
 3    
 4// Read the input Project file
 5System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"GetNumberOfPages.mpp");
 6    
 7// Get number of pages,  Timescale.Months, Timescale.ThirdsOfMonths
 8int32_t iPages = project->GetPageCount();
 9iPages = project->GetPageCount(Aspose::Tasks::Visualization::Timescale::Months);
10iPages = project->GetPageCount(Aspose::Tasks::Visualization::Timescale::ThirdsOfMonths);

Programming Sample: Get the number of pages for different Views Aspose.Tasks for C++ supports rendering a project’s resource usage, resource sheet and task usage to PDF format, and enables users to get the number of pages in the rendered output for these views. This programming sample demonstrates rendering a projects’ usage view and getting the number of pages in the rendered output.

 1// The path to the documents directory.
 2System::String dataDir = RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName());
 3    
 4// Read the source Project
 5System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"GetNumberOfPagesForViews.mpp");
 6    
 7// Get number of pages,  Months and  ThirdsOfMonths
 8System::Console::WriteLine(System::String::Format(u"Number of Pages = '{0}'",project->GetPageCount(Aspose::Tasks::Visualization::PresentationFormat::ResourceUsage, Aspose::Tasks::Visualization::Timescale::Days)));
 9System::Console::WriteLine(System::String::Format(u"Number of Pages = '{0}'",project->GetPageCount(Aspose::Tasks::Visualization::PresentationFormat::ResourceUsage, Aspose::Tasks::Visualization::Timescale::Months)));
10System::Console::WriteLine(System::String::Format(u"Number of Pages = '{0}'",project->GetPageCount(Aspose::Tasks::Visualization::PresentationFormat::ResourceUsage, Aspose::Tasks::Visualization::Timescale::ThirdsOfMonths)));

Programming Sample: Get number of pages based on Start and End Dates

1System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"GetNumberOfPages.mpp");
2    
3auto options = [&]{ auto tmp_0 = System::MakeObject<ImageSaveOptions>(Aspose::Tasks::Saving::SaveFileFormat::PNG); tmp_0->set_SaveToSeparateFiles(true); tmp_0->set_PageSize(Aspose::Tasks::Visualization::PageSize::A3); tmp_0->set_Timescale(Aspose::Tasks::Visualization::Timescale::Months); tmp_0->set_StartDate(project->Get<System::DateTime>(Prj::StartDate()) - System::TimeSpan::FromDays(10)); tmp_0->set_EndDate(project->Get<System::DateTime>(Prj::FinishDate()) + System::TimeSpan::FromDays(30)); return tmp_0; }();
4int32_t pageCount = project->GetPageCount(Aspose::Tasks::Visualization::PageSize::A3, Aspose::Tasks::Visualization::Timescale::Months, project->Get<System::DateTime>(Prj::StartDate()) - System::TimeSpan::FromDays(10), project->Get<System::DateTime>(Prj::FinishDate()) + System::TimeSpan::FromDays(30));
5    
6System::Console::WriteLine(pageCount);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.