Impression de fichiers de projet Microsoft
Aspose.Tasks pour .NET fournit la facilité d’imprimer des projets à l’imprimante par défaut ou à toute imprimante personnalisée à l’aide de la fonction Project.print. Il offre également des fonctionnalités d’impression avancées telles que la modification des options d’impression et des paramètres.
Données d’impression du projet
La classe Project expose la fonction Print pour imprimer le projet. La fonction d’impression utilise PrintOptions pour définir différents paramètres pour l’impression comme Timescale, startDate, enddate, fitContent, LegendonEachPage et plus. Une autre classe (à partir de System.Drawing.print Espace de noms), Printersettings est utilisé pour configurer l’imprimante pour imprimer toutes les pages, Page Start (FromPage), Page End (Topage), Papersize et ainsi de suite. Les objets des imprimations et des imprimations sont transmis à project.print () pour l’impression finale.
Pour imprimer un projet:
- Chargez un fichier de projet Microsoft.
- Appelez la fonction d’impression avec les arguments spécifiés.
Imprimez à l’imprimante par défaut
Les lignes de code suivantes montrent comment y parvenir en utilisant C #.
1Project project = new Project("New Project.mpp");
2project.Print();
Print the project to a custom printer
1Project project = new Project("New Project.mpp");
2foreach (string printer in PrinterSettings.InstalledPrinters)
3{
4 if (printer.ToUpperInvariant().Contains( "Microsoft Print to PDF".ToUpperInvariant()))
5 {
6 project.Print(printer);
7 break;
8 }
9}
Print Large Files
1Project project = new Project("New Project.mpp");
2PrintOptions options = new PrintOptions();
3options.Timescale = Timescale.ThirdsOfMonths;
4if (project.GetPageCount(Timescale.ThirdsOfMonths) <= 280)
5 project.Print(options);
Print with PrintOptions and PrinterSettings
1Project project = new Project("New Project.mpp");
2
3PrintOptions options = new PrintOptions();
4options.Timescale = Timescale.Months;
5
6// Print first two pages
7PrinterSettings printerSettings = new PrinterSettings();
8printerSettings.PrintRange = PrintRange.SomePages;
9printerSettings.FromPage = 1;
10printerSettings.ToPage = 2;
11
12System.Drawing.Printing.PageSettings pageSettings = printerSettings.DefaultPageSettings;
13pageSettings.PaperSize = new PaperSize("Custom Size", 1000, 700);
14project.Print(printerSettings, options);