Free Support Forum - aspose.com

Export project file to image(s)

Hello, i’m trying to figure it out… i have a project file with 16 pages - obtained with methd GetPagesCount(): how can i save every single page as a png file OR save entire project in a unique png file?
thank you

Hi,


Thank you for contacting Aspose support team.

Entire project can be printed to a JPEG or PNG file as given in the following sample code:

Project project = new Project(@“D:\Project1.mpp”);

// Save to one page image (Timescale.ThirdsOfMonths)
Aspose.Tasks.Saving.ImageSaveOptions options = new Aspose.Tasks.Saving.ImageSaveOptions(SaveFileFormat.JPEG);
options.Timescale = Timescale.ThirdsOfMonths;
project.Save(“NewProductDevThirdsOfMonths.jpeg”, options);

// Save to one page image (Timescale.Months)
options.Timescale = Timescale.Months;
project.Save(“NewProductDevMonths.jpeg”, options);

// There is IRender property for compliance with Project.Export interface
options.RenderParam = new BaseImageRenderParam(null, Point.Empty, new Size(800, 600), 100, 0, true);
project.Save(“NewProductDevRenderOptions.jpeg”, options);


Similarly, we can print project to TIFF file where each page is printed separately as given below:

Project project = new Project(@“D:\Aspose\test.mpp”);

//Source file to be converted to TIFF
//Save the project to TIFF
project.Save(“RenderMe.tif”, SaveFileFormat.TIFF);

//Save the project with CCITT4 compression
Aspose.Tasks.Saving.ImageSaveOptions options = new Aspose.Tasks.Saving.ImageSaveOptions(SaveFileFormat.TIFF);
options.TiffCompression = Aspose.Tasks.Saving.TiffCompression.Ccitt4;
project.Save(“RenderMe_options.tif”, options);

//Remove the compression
options.TiffCompression = Aspose.Tasks.Saving.TiffCompression.None;
project.Save(“RenderMe_comp_none.tif”, options);

You may also please have a look at the following topics to get more detail on printing:


I am afraid to share that currently no feature is available that can provide printing each page in a separate image. I have logged this new feature request in our issue tracking system under id: TASKS-33649. Development team will look into it and will share their findings with us. You will be automatically notified once any update is available in this regard.

Please feel free to write us back if you have any other query related to Aspose.Tasks.

Hi, i tried this code:



Aspose.Tasks.Saving.ImageSaveOptions OptionsT = new Aspose.Tasks.Saving.ImageSaveOptions(Aspose.Tasks.Saving.SaveFileFormat.PNG);



OptionsT.HorizontalResolution = 200;

OptionsT.VerticalResolution = 200;

OptionsT.Timescale = Aspose.Tasks.Visualization.Timescale.ThirdsOfMonths;

((Aspose.Tasks.Project)m_oDocument).Save(_oOutputStream, OptionsT);





but image result (see attachment) seems to be truncated

i think i have to pass page number and export avery single page as png. is possible to pass in option the page index (as i can do in aspose words or other)?

If i use IRenderParam as you show, there is some discrepance between page index and pageCount: i use document.getPageCount() and return 9 pages but when i use

Aspose.Tasks.Visualization.BaseImageRenderParam(null, System.Drawing.Point.Empty, new System.Drawing.Size(800,600), 100, _iPageIndex, true);



with pageIndex from 0 to 8, have problems because it render between 0 and 7, so i don’t have exact notice about total number of pages!



instead when i use sintax for retrieve a single image

((Aspose.Tasks.Project)m_oDocument).Save(_oOutputStream, Aspose.Tasks.Saving.SaveFileFormat.PNG);

i obtain a single image but splitted in 9 “squares”

Hi,


I am glad to share that feature of exporting a project to multiple image files is implemented and will be available in the next incoming release Aspose.Tasks for .NET 6.8.0. This new release will be available in the first week of next month and request you to wait till then.

Please feel free to write us back if you have any other query related to Aspose.Tasks.


Thank You!
in the meanwhile, can you provide me the right code to implement for getting a PNG stream starting from some page index (say page 5 of 15 pages document)?

Hi,


I am afraid that currently Aspose.Tasks does not provide any feature which can be used to extract particular page from PNG stream.

Please feel free to write us back if you have any query related to Aspose.Tasks.

The issues you have found earlier (filed as TASKS-33649) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

So, i downloaded last version of Aspose DLL… but i’m stuck with project files!
I tried to export a file as single image or multiple images but i obtained vary stranges results.
See files attached: Mpp file has 6 pages, if i try to print it as pdf file obtain 6 pages pdf, OR if i set the relative options to fit it in one page, i’ll get a 1 pages project print.
With Aspose, i.ve tryied this code:

Aspose.Tasks.Saving.ImageSaveOptions OptionsT = new Aspose.Tasks.Saving.ImageSaveOptions(Aspose.Tasks.Saving.SaveFileFormat.PNG);
OptionsT.HorizontalResolution = 200;
OptionsT.VerticalResolution = 200;
OptionsT.Pages = new List{ _iPageIndex}; //pageindex = the single page i need to export
OptionsT.Timescale = Aspose.Tasks.Visualization.Timescale.ThirdsOfMonths;
((Aspose.Tasks.Project)m_oDocument).Save(_oOutputStream, OptionsT );

OR - for a single page for entyre project:
((Aspose.Tasks.Project)m_oDocument).Save(_oOutputStream, Aspose.Tasks.Saving.SaveFileFormat.PNG);

In any case i’m getting 9 pages from method PAgeCount (the document has 6 pages when i open with MS project)
In the first case i obtain 6 pages with bad, cut margins
In the second case i obtain one image with 9 "squares"

So, how can i obtain one image per entire project OR 6 images, one per page as i can see if i print project file directly from MS?

Can you provide me right code to do this?
thank’s a lot.

attached files example…

Hi,


Thank you for contacting us again.

Following is the sample code which generates multiple images for a single MPP file and also a single image containing all the 6 pages. Here the total number of pages is displayed correctly and also we can generate selected pages by filling the list ImageSaveOptions.Pages.

Project project = new Project(@“test.mpp”);
Aspose.Tasks.Saving.ImageSaveOptions saveOptions = new Aspose.Tasks.Saving.ImageSaveOptions(SaveFileFormat.PNG);
saveOptions.StartDate = project.StartDate.AddDays(-3);
saveOptions.EndDate = project.FinishDate;
saveOptions.MarkCriticalTasks = true;
saveOptions.LegendOnEachPage = false;
saveOptions.Gridlines = new List();
Gridline gridline = new Gridline();
gridline.GridlineType = GridlineType.GanttRow;
gridline.Color = Color.CornflowerBlue;
gridline.Pattern = LinePattern.Dashed;
saveOptions.Gridlines.Add(gridline);

//Following commented code will generate page 3 only
//saveOptions.Pages = new List { 3};

// Save the whole project layout to one file
project.Save(@“D:\Aspose\mpp\CustomerFeedback.png”, saveOptions);

// Save project layout to separate files
saveOptions.SaveToSeparateFiles = true;
Console.WriteLine(“Total Pages = {0}”, saveOptions.PageCount);
project.Save(@“D:\Aspose\mpp\CustomerFeedback_.png”, saveOptions);
Could you please give it a try and let us know your feedback?

Hi i found 3 points of interest:


1
//Following commented code will generate page 3 only
//saveOptions.Pages = new List { 3};
// Save project layout to separate files
saveOptions.SaveToSeparateFiles = true;

These two instructions seems to do nothing (used togheter or not): if i use
saveOptions.Pages = new List { 3};
resulting image is the same, unique image for entire project (6 pages),
so saveoptions.pages is always unused

2
using saveOptions.LegendOnEachPage = true; cause the file to grow to 9 pages
that doesn’t happen when you print mpp file directly in project, it remain 6 pages with or without legend

3 exporting mpp file in one image (the only possibility nowadays), creates one image
BUT separated in "squares"
in the PNG file you can see 6 or 9 squares for each page: why not one real image file representing the entire project without "interruptions"

see atached files example (pdf file is one image file printed directly from ms project)

thank you so much

Hi,

Following are the responses to each of your comments:

demo-1:

1
//Following commented code will generate page 3 only
//saveOptions.Pages = new List { 3};
// Save project layout to separate files
saveOptions.SaveToSeparateFiles = true;

These two instructions seems to do nothing (used togheter or not): if i use
saveOptions.Pages = new List { 3};
resulting image is the same, unique image for entire project (6 pages),
so saveoptions.pages is always unused

Response: If we don't set saveOptions.SaveToSeparateFiles = true, the saveOptions.Pages property is ignored and whole project is rendered to single image file.

If we set the saveOptions.SaveToSeparate = true and saveOptions.Pages is empty, entire project will be rendered to separate image files say 6 files will be generated in this case (without legend on each page).

If we set the saveOptions.SaveToSeparate = true and saveOptions.Pages contains some entry like 3 in the above sample code, only one image file will be generated i.e. page 3. If we add more pages like saveOptions.pages = new List{3,4}, it will generate two image files for page 3 and 4 separately.

demo-1:
2
using saveOptions.LegendOnEachPage = true; cause the file to grow to 9 pages
that doesn't happen when you print mpp file directly in project, it remain 6 pages with or without legend

Response: I have created an investigation ticket TASKS-33678 for this issue.

demo-1:
3 exporting mpp file in one image (the only possibility nowadays), creates one image
BUT separated in "squares"
in the PNG file you can see 6 or 9 squares for each page: why not one real image file representing the entire project without "interruptions"

see atached files example (pdf file is one image file printed directly from ms project)

Response: I have created an enhancement ticket TASKS-33679 for this requirement.

hi, you said: "If
we set the saveOptions.SaveToSeparate = true and saveOptions.Pages
contains some entry like 3 in the above sample code, only one image file
will be generated i.e. page 3."


but i’m telling you if i use the same - identical - code i obtain one image of the entyre project!
same as savetoSeparate = false, there’s no diffence!

Why and how you obtain image for page 3 only?

here is the complete code:
Aspose.Tasks.Saving.ImageSaveOptions OptionsT = new Aspose.Tasks.Saving.ImageSaveOptions(Aspose.Tasks.Saving.SaveFileFormat.PNG);
OptionsT.StartDate = ((Aspose.Tasks.Project)m_oDocument).StartDate; //AddDays(-3);
OptionsT.EndDate = ((Aspose.Tasks.Project)m_oDocument).FinishDate;
OptionsT.MarkCriticalTasks = true;
OptionsT.LegendOnEachPage = false;
OptionsT.Gridlines = new List<Aspose.Tasks.Visualization.Gridline>();
Aspose.Tasks.Visualization.Gridline gridline = new Aspose.Tasks.Visualization.Gridline();
gridline.GridlineType = Aspose.Tasks.Visualization.GridlineType.GanttRow;
gridline.Color = System.Drawing.Color.CornflowerBlue;
gridline.Pattern = Aspose.Tasks.Visualization.LinePattern.Dashed;
OptionsT.Gridlines.Add(gridline);
OptionsT.SaveToSeparateFiles = true;
OptionsT.Pages = new List { _iPageIndex }; // =3

((Aspose.Tasks.Project)m_oDocument).Save(_oOutputStream, OptionsT);

Hi,

Here a sample project is attached for your reference containing your sample code along with the output file which is image of page 3 only. Could you please test this project and let us know your feedback? I am using Aspose.Email for .NET 4.3.0, Visual Studio 2013 and Windows 7.

Ok i found the needle in haystack: the problem is stream output!

((Aspose.Tasks.Project)m_oDocument).Save(“test.png”, OptionsT);
saves one page image!

((Aspose.Tasks.Project)m_oDocument).Save(_oOutputStream, OptionsT);
saves entire project image!

try it!

I reported similar problem for aspose.diagram library, solved by recent aspose update…

Keep me informed, thank’s a lot.


Hi ,

Thank you for sharing more detail.

I was able to reproduce this issue at my end using the latest version of Aspose.Tasks for .NET 6.8.0 and have logged it as TASKS-33681 in our issue tracking system for further investigation by our development team. Once there is any information available in this regard, we'll update you here via this thread.

We are sorry for the inconvenience caused to you.

sorry, could be possible to have option “savetoseparatefile” even with PDF options conversion? to choose exporting pdf from task in one unique pdf page or separate pages of pdf…
thank’s

Hi,

Thank you for your inquiry.

An enhancement ticket with id: TASKS-33698 has been logged in our issue tracking system for providing such a feature. Once there is an update available in this regard, we’ll notify you here via this thread.

hi, any news about TASKS-33678, TASKS-33679 and TASKS-33681 ?
thank you

Hi,

I have checked the status of this issue and here are the status of these three issues:

TASKS-33678: This issue is still under investigation and we’ll share the ETA here once it is received from the development team.

TASKS-33679: This issue has been fixed and will be part of the upcoming version of Aspose.Tasks for .NET 7.0.0.

TASKS-33681: This issue has also been fixed and will be part of the upcoming version of Aspose.Tasks for .NET 7.0.0.

I would further like to add that we are in process of releasing Aspose.Tasks for .NET 7.0.0 in the early next week and once the fix version is available for download, we’ll update you here via this thread.