When i converting a Word document to markdown, the exported files are with a very low quality (small size).
I want to keep the original size, same as saving the images manually directly from word.
I uploaded one document sample.
I also uploaded the converted files, and the same files saved directly from the word document. You can see the images size differences.
@diemos, I can confirm that Aspose.Words downscales the images, and currently there is no way to prevent this through the public API.
However, it is possible to access the original image data via ImageSavingArgs.CurrentShape property. In the example below, the original images are saved together with downscaled images, and after the conversion to Markdown is finished, the downscaled images are replaced with the original images.
OriginalImageSaving imageSavingCallback = new OriginalImageSaving();
Document doc = new Document("Images-Issue.docx");
MarkdownSaveOptions so = new MarkdownSaveOptions()
{
ImageSavingCallback = imageSavingCallback
};
doc.Save("out.md", so);
foreach (var item in imageSavingCallback.ImageFiles)
{
File.Delete(item.Item1);
File.Move(item.Item2, item.Item1);
}
class OriginalImageSaving : IImageSavingCallback
{
public List<Tuple<string, string>> ImageFiles = new List<Tuple<string, string>>();
void IImageSavingCallback.ImageSaving(ImageSavingArgs args)
{
if (args.CurrentShape.IsImage)
{
string originalImageFile = $"{args.ImageFileName}.original";
Shape shape = (Shape)args.CurrentShape;
shape.ImageData.Save(originalImageFile);
ImageFiles.Add(new Tuple<string, string>(args.ImageFileName,originalImageFile));
}
}
}
Please refer to our documentation for more details: