Free Support Forum -

Lines have disappeared when converting images

Hello team,

I have converted 0_32.docx to Images with Aspose.Words. Please find error point with 0_32_00000001.jpg.

  • The lines have disappeared (Page 1)

This is my code.

public static List ConvertWordToImage(string docName, MemoryStream docStream, Dictionary config)
var pageInfoList = new List();

string docRootDir = config[“DocumentsFilePath”];
int dpi = int.Parse(config[“ImageDPI”]);
int thumbMaxH = int.Parse(config[“ThumbnailMaxHeight”]);
int thumbMaxW = int.Parse(config[“ThumbnailMaxWidth”]);
int maxPageNum = int.Parse(config[“DocumentMaxPageNum”]);
float readScale = float.Parse(config[“ImageReadScale”]);
int readDpi = Convert.ToInt32(dpi * readScale);

// Create images directory
string pageImgDir = docRootDir;
if (!Directory.Exists(pageImgDir))

// Get the encoder of JPEG
ImageCodecInfo jpgEncoder = GetCodecInfo();
//EncoderParameters encParams = GetEncoderParams();

EncoderParameters encParams = GetEncoderParams(int.Parse(config[“ImageJpegQuality”]));

// Instantiate the License class
Aspose.Words.License license = new Aspose.Words.License();

// Convert .doc and .docx file to PDF.
Document document = new Document(docStream);

for (int i = 0; (i < maxPageNum); i++)
var pageInfo = document.GetPageInfo(i);
Size pixelSize = pageInfo.GetSizeInPixels(1.0f, readDpi);

// Export image file
string imgFile = string.Format("{0}_{1:D8}.jpg",
Path.GetFileNameWithoutExtension(docName), i+1);
string imgPath = Path.Combine(pageImgDir, imgFile);
using (Bitmap bitmap = new Bitmap(pixelSize.Width, pixelSize.Height))
bitmap.SetResolution(dpi, dpi);

using (Graphics graphics = Graphics.FromImage(bitmap))
document.RenderToScale(i, graphics, 0, 0, readScale);

bitmap.Save(imgPath, jpgEncoder, encParams);

// TODO Create OCR XML

// Add PageInfo List

// return results with flag of max page limit over
return pageInfoList;

They are parameters.

// Get config setting
Create Appseting key value for async function
Dictionary config = new Dictionary();

config.Add(“DocumentsFilePath”, outDir);
config.Add(“ImageDPI”, “96”);
config.Add(“ImageReadScale”, “1.25”);
config.Add(“ThumbnailMaxHeight”, “252”);
config.Add(“ThumbnailMaxWidth”, “210”);
config.Add(“ImageJpegQuality”, “80”);
config.Add(“DocumentMaxPageNum”, “1000”);

Thank you,

This Topic is created by tahir.manzoor using the Email to Eopic plugin.

Hi there,

Thanks for your patience. It is to inform you that the issue which you are facing is actually not a bug in Aspose.Words. So, we have closed this issue (WORDSNET-15391) as ‘Not a Bug’.

Please use Graphics.SmoothingMode as SmoothingMode.AntiAlias to get the desired output. We have attached the output BMP file with this post for your kind reference. (9.0 KB)

using (Graphics graphics = Graphics.FromImage(bitmap))
    graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
    document.RenderToScale(0, graphics, 0, 0, 1.25f);

    bitmap.Save(MyDir + "17.6.bmp");