Free Support Forum - aspose.com

Save document as grayscale

Is it possible to take a document created with color text and color images and then use aspose to save it to PDF in grayscale (similar to choosing print in Grayscale while printing).

If not, can I loop through all of the images and text and convert to grayscale before saving it?

Thanks

Brad

Hi Brad,


Thanks for your inquiry. I think, you can achieve this by using the following code snippet:

Document doc = new
Document(@“C:\test\in.doc”);<o:p></o:p>

ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Tiff);

options.ImageColorMode = ImageColorMode.Grayscale;

MemoryStream stream = new MemoryStream();

doc.Save(stream, options);

Document grayedDoc = new Document();

DocumentBuilder builder = new DocumentBuilder(grayedDoc);

using (Image image = Image.FromStream(stream))

{

int framesCount = image.GetFrameCount(FrameDimension.Page);

for (int frameIdx = 0; frameIdx < framesCount; frameIdx++)

{

if (frameIdx != 0)

builder.InsertBreak(BreakType.SectionBreakNewPage);

image.SelectActiveFrame(FrameDimension.Page, frameIdx);

PageSetup ps = builder.PageSetup;

ps.PageWidth = ConvertUtil.PixelToPoint(image.Width, image.HorizontalResolution);

ps.PageHeight = ConvertUtil.PixelToPoint(image.Height, image.VerticalResolution);

builder.InsertImage(

image,

RelativeHorizontalPosition.Page,

0,

RelativeVerticalPosition.Page,

0,

ps.PageWidth,

ps.PageHeight,

WrapType.None);

}

}

grayedDoc.Save(@"C:\test\out.pdf");


Best Regards,

Hi,

We are trying to do the same, but in Java.
We saw that the method ImageColorMode is not present for the ImageSaveOptions class.
Is there any way to save a Word Document in GrayScale and save it afterwards to PDF ?

Many thanks for your reply,

Michael

Hi Michael,


Thanks for your inquiry. I am working over your query and will get back to you soon.

Best Regards,

Hi Michael,


Thanks for your patience. A new feature request has been logged in our issue tracking system as WORDSJAVA-628. We will add a public property to set ImageColorMode in Java in our next version of ‘Aspose.Words for Java’ i.e. 11.9.0. This version will be released at the end of this month. You will be notified as soon as this property is available. We apologise for any inconvenience.

Best Regards,

Thanks !

The issues you have found earlier (filed as WORDSJAVA-628) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.