Out of position when converting to image

Hello team,

PQ3784.zip (12.1 KB)
1.jpg (36.1 KB)

I have converted PQ3784.docx to Images with Aspose.Words however I got 1 error.

  1. Out of position

I have also attached PQ3784SaveAsPdfByWord.pdf which is a pdf MS Word outputs correctly as a reference.
PQ3784SaveAsPdfByWord.pdf (147.7 KB)

This is my code.

public static List ConvertWordToImage(string docName, MemoryStream docStream, Dictionary<string, string> config)
{
try
{
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))
                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);
                    }
                }

                // TODO Create OCR XML

                // Add  PageInfo List
                pageInfoList.Add(imgPath);
            }
            
            // return results with flag of max page limit over
            return pageInfoList;
        }
        finally
        {
        }
    }

They are parameters.

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

               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,
PFU DSOL2

@PFU.DSOL2,

Thanks for your inquiry. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-15865. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@PFU.DSOL2,

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