Hi, is it possible to save/convert Document to a single Jpeg for more than the first page?
I’ve tried the PageSet.All
option as well and it doesn’t seems working with Jpeg, seems working with Tiff output?
Here is the code I am using:
var jpgOptions = new ImageSaveOptions(SaveFormat.Jpeg);
var tifOptions = new ImageSaveOptions(SaveFormat.Tiff);
var input = new Document(@"Data\2Pages.docx");
//jpgOptions.PageSet = new PageSet(new PageRange(0, 2));
//tifOptions.PageSet = new PageSet(new PageRange(0, 2));
// Jpeg only output one page, Tiff output 2 pages as expected
// but document form :https://reference.aspose.com/words/net/aspose.words.saving/imagesaveoptions/pageset/
// says that PageSet default value is all?
jpgOptions.PageSet = PageSet.All;
tifOptions.PageSet = PageSet.All;
input.Save(@"Data\Output.jpg", jpgOptions);
input.Save(@"Data\Output.tif", tifOptions);
@paull7744 Tiff is multi-frame format, while Jpeg is a single frame format. So you can save only single page as Jpeg. However, if you need to render several pages on a single frame, you can consider using Document.RenderToScale method. The example in the documentation shows how to render the individual pages of a document to graphics to create one image with thumbnails of all pages.
Thank Alexey for the reply and link. Yes, the solutions from you link works as well. But I think I am happy with Tiff, as it seems doing exactly what I am expecting from Jpeg format.
On the other hand, I didn’t see it mentioned anywhere that Jpeg can only be saved single page in Aspose’s document, and now I am trying to implement output to Png instead and it seems only save one page as well?
@paull7744 PNG is just like JPEG and other image formats, except TIFF, allows rendering only a single page. This is described in in the SaveFormat enum. Description states that a page (means single page) of the document is rendered.
Name |
Value |
Description |
Tiff |
100 |
Renders a page or pages of the document and saves them into a single or multipage TIFF file. |
Png |
101 |
Renders a page of the document and saves it as a PNG file. |
Bmp |
102 |
Renders a page of the document and saves it as a BMP file. |
Emf |
103 |
Renders a page of the document and saves it as a vector EMF (Enhanced Meta File) file. |
Jpeg |
104 |
Renders a page of the document and saves it as a JPEG file. |
Gif |
105 |
Renders a page of the document and saves it as a GIF file. |