aspose.words可以将多页的文档直接导出为长图吗?比如我有一个13页的文档,我不希望用分页导出图像的办法输出图像,我想直接导出为一整张长图片,在aspose.words中可以实现吗?还是需要和aspose.imaging配合使用?
@jidesheng, 您可以通过将 Word 文档转换为 SVG 格式来实现此目的:
Document doc = new Document("in.docx");
doc.Save("out.svg");
Aspose.Words 无法对 PNG 或 JPEG 执行相同的操作,但您可以使用 Aspose.Imaging 将 SVG 转换为 PNG:https://docs.aspose.com/imaging/net/convert-svg-to-raster-image/
我尝试过了,但是有的文档转换为svg,在浏览器种打开很清楚,转换为png以后就很模糊了,这是什么原因?我上传一份word文档,麻烦你在本地帮我尝试一下
新建 Microsoft Word 文档.docx (63.7 KB)
这是我的部分转换代码:
TempWordImageSaveOption = new Aspose.Words.Saving.ImageSaveOptions(Aspose.Words.SaveFormat.Svg);
TempWordImageSaveOption.HorizontalResolution = DpiValue;
TempWordImageSaveOption.VerticalResolution = DpiValue;
TempWordDocument.Save(TempSvgFile, TempWordImageSaveOption);
using Aspose.Imaging.Image TempLoadImage = Aspose.Imaging.Image.Load(TempSvgFile);
using SvgRasterizationOptions TempSvgOption = new SvgRasterizationOptions();
TempSvgOption.PageHeight = TempLoadImage.Height;
TempSvgOption.PageWidth = TempLoadImage.Width;
TempSvgOption.ResolutionSettings = new ResolutionSetting(DpiValue,DpiValue);
TempSvgOption.TextRenderingHint = TextRenderingHint.AntiAlias;
//using Aspose.Imaging.ImageOptions.VectorRasterizationOptions TempRasterOption = new VectorRasterizationOptions();
//TempRasterOption.PageWidth = TempLoadImage.Width;
//TempRasterOption.PageHeight = TempLoadImage.Height;
switch (ConvertImageType)
{
case ".jpg":
TempConvertJpegOption.Quality = 100;
TempConvertJpegOption.VectorRasterizationOptions = TempSvgOption;
TempConvertJpegOption.ResolutionSettings = new ResolutionSetting(DpiValue,DpiValue);
TempLoadImage.Save(SavedImageFileName, TempConvertJpegOption);
break;
case ".png":
TempConvertPngOption.VectorRasterizationOptions = TempSvgOption;
TempConvertPngOption.ResolutionSettings = new ResolutionSetting(DpiValue, DpiValue);
TempLoadImage.Save(SavedImageFileName, TempConvertPngOption);
break;
case ".bmp":
TempConvertBmpOption.VectorRasterizationOptions = TempSvgOption;
TempConvertBmpOption.ResolutionSettings = new ResolutionSetting(DpiValue, DpiValue);
TempLoadImage.Save(SavedImageFileName, TempConvertBmpOption);
break;
default:
break;
}
@jidesheng , 由于从 SVG 到 PNG 的转换是由 Aspose.Imaging 执行的,因此您需要针对此问题创建一个单独的论坛主题,并将 SVG 和 PNG 图像附加到该主题。 我来自Aspose.Imaging的同事将帮助您分析这个问题。