Microsoft Project (MPP) -tiedostojen kääntäminen PDF-tiedostoiksi käyttäen Aspose.Tasks MPP to PDF on yleistä, mutta oletusvienti ei aina ole luettavissa tai tiivistetty. Aspose.Tasks for .NET, MPP PDF -muunnin .NET, voit hienosäädellä sivun kokoa, suuntautumista, aikakautta, sopivaa ja jopa tuottaa yhden sivun yhteenvedon nopeisiin arvioihin. Tässä oppaassa näytetään luotettava asennus Microsoft Project PDF -asteikkoa varten .NET ja täydellinen C#-näyte, jonka voit pudottaa rakennusasi.
Avain
- syö
PdfSaveOptionsPysyvässä työssä PDF-viesti Aspose.Tasks Säästä koko, suuntautuminen, aikakausi,Kyllä Sopeile. - Pidä laskelmat tuoreina
CalculationMode = Automatictaiproject.Recalculate()ennen vientiä PDF vienti mukautetun ulkoasun. - Sukupolvi Yksilöllinen yhteenveto kanssa
RenderToSinglePage = trueJa sitten se on ihan huomaavainen. - Sattuma
StartDate/EndDateKeskitettyä aikaa vähennetään.
Kysy kyselystä
1) Load the MPP File
Luo A Project Ja nyt sitten huokaa .mpp.Voit ottaa käyttöön automaattisen laskentajärjestelmän, jotta päivämäärät ja indikaattorit ovat ajan tasalla.
2) Configure Layout
Valitse sivun koko (esimerkiksi A3), suunta (laajalle Ganttille maisema) ja sisältö sopii, jotta vältetään supistuneet rivit.
3) Set Timescale & Focus Window
Valitse aikakausi (päivät, viikot ja kuukaudet) ja rajoita vientiä mahdollisesti päivämääräalueelle, jossa StartDate/EndDate.
4) Save as PDF
Vientiä tavallinen Gantt PDF, yhden sivun yhteenveto ja vaihtoehtoiset näkymät tarvitset.
Täydellinen, koottava esimerkki (C#)
using System;
using Aspose.Tasks;
using Aspose.Tasks.Saving;
using Aspose.Tasks.Visualization;
namespace MppToPdfLayoutScaling
{
internal static class Program
{
// How to run:
// 1) dotnet new console -n MppToPdfLayoutScaling
// 2) cd MppToPdfLayoutScaling
// 3) dotnet add package Aspose.Tasks
// 4) Replace Program.cs with this file's contents
// 5) dotnet run -- "path-to-input.mpp"
private static void Main(string[] args)
{
if (args.Length == 0)
{
Console.WriteLine("Usage: dotnet run -- <path-to-input.mpp>");
return;
}
string input = args[0];
// Load project and ensure calculations are current
var project = new Project(input)
{
CalculationMode = CalculationMode.Automatic
};
project.Recalculate();
string baseName = System.IO.Path.GetFileNameWithoutExtension(input);
// Standard Gantt export with custom layout
var ganttOptions = new PdfSaveOptions
{
PresentationFormat = PresentationFormat.GanttChart,
PageSize = PageSize.A3, // wider canvas for Gantt
IsPortrait = false, // landscape
Timescale = Timescale.Weeks, // weekly buckets
FitContent = true,
ReduceFooterGap = true,
StartDate = project.Get(Prj.StartDate).Date,
EndDate = project.Get(Prj.FinishDate).Date
};
project.Save($"{baseName}-gantt.pdf", ganttOptions);
Console.WriteLine($"Saved: {baseName}-gantt.pdf");
// Single-page summary (auto scales to fit one page)
var singlePage = new PdfSaveOptions
{
PresentationFormat = PresentationFormat.GanttChart,
RenderToSinglePage = true,
IsPortrait = false
};
project.Save($"{baseName}-gantt-singlepage.pdf", singlePage);
Console.WriteLine($"Saved: {baseName}-gantt-singlepage.pdf");
// Optional: Resource Usage view for time-phased detail
var usage = new PdfSaveOptions
{
PresentationFormat = PresentationFormat.ResourceUsage,
Timescale = Timescale.Days,
FitContent = true
};
project.Save($"{baseName}-resource-usage.pdf", usage);
Console.WriteLine($"Saved: {baseName}-resource-usage.pdf");
}
}
}
## How to run
1. `dotnet new console -n MppToPdfLayoutScaling`
2. `cd MppToPdfLayoutScaling`
3. `dotnet add package Aspose.Tasks`
4. Replace `Program.cs` with the code above
5. `dotnet run -- "path-to-input.mpp"`
### What this code does
* **Loads** an MPP and enables **automatic calculation**.
* **Exports** a configurable **Gantt PDF** with page size/orientation and weekly timescale.
* **Generates** a **single‑page** Gantt summary for quick review.
* **Optionally** exports the **Resource Usage** view with a daily timescale.
## Troubleshooting & Tips
* **PDF spans too many pages:** use a coarser `Timescale` (Weeks/Months) or enable `RenderToSinglePage` for a compact overview.
* **Rows are truncated:** set `FitContent = true` and consider `ReduceFooterGap = true`.
* **Need only part of the schedule:** set `StartDate` and `EndDate` on `PdfSaveOptions` to trim the window.
* **Missing glyphs:** ensure required fonts are installed or configure font folders via `PdfSaveOptions.FontSettings`.
## FAQ
**Q1. Can I export a specific date range only?**
Yes. Set `StartDate` and `EndDate` on `PdfSaveOptions` to render just that window.
**Q2. How do I reduce the PDF page count for very large projects?**
Choose a coarser `Timescale` (Weeks/Months), enable `FitContent`, and consider `RenderToSinglePage` for summaries.
**Q3. Can I export views other than Gantt?**
Yes. Set `PresentationFormat` to `ResourceUsage`, `ResourceSheet`, or other supported views.
**Q4. Do I need Microsoft Project installed?**
No. Aspose.Tasks works independently; add the **Aspose.Tasks** NuGet package to your project.
**Q5. Can I customize columns in the exported PDF?**
Yes. You can define specific columns via view settings; otherwise defaults are used.
## Conclusion
Using `PdfSaveOptions` with appropriate page and timescale settings gives you precise control over MPP → PDF output. Start with an A3 landscape Gantt for readability, add a single‑page summary for stakeholders, and include Resource Usage for time‑phased detail. Test with a few representative projects to settle on defaults that fit your organization’s documents.