Character direction etc

Hello Team,

I have converted test.docx to test_00000001.jpg with ASPOSE.Words.

Please find error point with attached file(test_00000001 - ErrorPoint.jpg).

  1. direction

  2. narrow

This is my code.

public static List ConvertWordToImage(string docName, MemoryStream docStream, Dictionary config)
{
    try
    {
        var pageInfoList = new List();
        // Get config setting
        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))
            Directory.CreateDirectory(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();
        license.SetLicense("Aspose.Total.lic");
        // Convert .doc and .docx file to PDF.
        Document document = new Document(docStream);
        for (int i = 0; (i < document.PageCount) && (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))
                {
                    graphics.Clear(Color.White);
                    document.RenderToScale(i, graphics, 0, 0, readScale);
                    bitmap.Save(imgPath, jpgEncoder, encParams);
                }
            }

            // Add PageInfo List
            pageInfoList.Add(imgPath);
        }

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

protected static ImageCodecInfo GetCodecInfo()
{
    // Get the encoder of JPEG
    ImageCodecInfo jpgEncoder = null;
    foreach (ImageCodecInfo ici in ImageCodecInfo.GetImageEncoders())
    {
        if (ici.FormatID == ImageFormat.Jpeg.Guid)
        {
            jpgEncoder = ici;
            break;
        }
    }

    return jpgEncoder;
}

protected static EncoderParameters GetEncoderParams(int quality)
{
    // Create the parameter for the encoder
    EncoderParameter encParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, quality);
    // Store the parameter in the parameter array
    EncoderParameters encParams = new EncoderParameters(1);
    encParams.Param[0] = encParam;
    return encParams;
}

Thank you,

Atsuo Nakatani

Hi Atsuo,


Thanks for your inquiry. We have tested the scenario with your shared document using Aspose.Words for .NET 17.4.0 and noticed your reported issues. So we have logged these issue in our issue tracking system as following. We will notify you as soon as these issue are resolved.

WORDSNET-15169: Character direction issue.
WORDSNET-15170: Character spacing issue.
WORDSNET-15171: Text Color issue.

We are sorry for the inconvenience.

Best Regards,

The issues you have found earlier (filed as WORDSNET-15171) have been fixed in this Aspose.Words for .NET 17.5 update and this Aspose.Words for Java 17.5 update.


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

The issues you have found earlier (filed as WORDSNET-15169) have been fixed in this Aspose.Words for .NET 21.4 update and this Aspose.Words for Java 21.4 update.