Borders are missing in Aspose EMF/OfficeCompatibleEMF converted from XLSX

Hi,

When converting an Excel worksheet to EMF using Aspose, I noticed the borders are missing in the EMF after inserting the images to DOCX at 100% zoom, which then eventually resulted in missing borders in the PDF after converting the DOCX to PDF.

Code:

var workbook = new Workbook(@".\test.xlsx");
var ws = workbook.Worksheets[0];
ws.PageSetup.PrintArea = @“B6:K6”;
var options = new ImageOrPrintOptions
{
ImageType = ImageType.OfficeCompatibleEmf, // ImageType.Emf for Aspose normal EMF
OnlyArea = false,
TextRenderingHint = TextRenderingHint.AntiAlias, // TextRenderingHint.ClearTypeGridFit for Aspose normal EMF
OnePagePerSheet = true,
Transparent = true
};
ws.PageSetup.LeftMargin =
ws.PageSetup.RightMargin = ws.PageSetup.TopMargin = ws.PageSetup.BottomMargin = ws.PageSetup.HeaderMargin = ws.PageSetup.FooterMargin = 0;
var render = new SheetRender(ws, options);
render.ToImage(0, @".\out.emf");

When copying/pasting it from MS Office manually, the borders are always visible and the borders are also always visible in the converted PDF under any %.

I’ve attached the test files and a screenshot for your reference. Could you please help me take a look?

test.zip (48.3 KB)
image.png (54.7 KB)

Thanks,

@ServerSide527,
Could you please share more details and like how are you inserting the images to docx? Share the step by step procedure for reproducing the issue.

Hi @ahsaniqbalsidiqui

The steps were the same as all my previous similar tickets - For Aspose EMFs I just dragged the EMF output into Word document. For Word EMF I do copy - copy as picture - as shown when printed in Excel then paste into Word.

For the visibility issue in Word, you can just insert the image into any Word document and you can observe the issue. For the visibility issue in the PDF, please use my example DOCX file where it has a specific table settings that can replicate the issue in the PDF.

Thanks,

@ServerSide527,
We have observed the issue and logged it in our database for further investigation. You will be notified here once any update is ready for sharing.

This issue is logged as:
CELLSNET-47820 - Borders are missing in Aspose EMF/OfficeCompatibleEMF converted from XLSX

@ServerSide527

When I open your shared “examples.docx” into Microsoft Word and set zoom to 100%, the border of “Copy as picture – as shown when printed” is also invisible: Word_screenshot.png (58.4 KB)

Actually, the border is on the bound and all the margins to set to zero, so when the border being drawn to an image, part of the border line is beyond the image boundary.
I suggest you adding some margins(e.g. one point) to it to get a good result:

...
ws.PageSetup.LeftMargin =
ws.PageSetup.RightMargin = ws.PageSetup.TopMargin = ws.PageSetup.BottomMargin = ws.PageSetup.HeaderMargin = ws.PageSetup.FooterMargin = 0;

//set one point top margin, convert to centimeters
ws.PageSetup.TopMargin = 1 * 2.54 / 72;
...

Hi @Peyton.Xu

Thanks for your explanation.

When I open your shared “examples.docx” into Microsoft Word and set zoom to 100%, the border of “Copy as picture – as shown when printed” is also invisible: Word_screenshot.png (58.4 KB)

I have checked it again on my side but the line in “example.docx” is always visible on my end. This can also be reflected in my previous screenshot where it was captured under 100%. I’m using Office 365 (16.0.12527.21378).

If yours is earlier than this version, maybe this could mean that the EMF produced by Aspose does not have the same visual compatibility as the latest Office versions.

Even if that is the case, I understand that the issue itself would not cause a problem because I do see Word from time to time cannot reflect the actual visual layout.

However, what is causing the problem is the PDF output converted from DOCX in the end. In Word EMF images, it can always produce the line in the final PDF, which can correctly reflect the original worksheet range in Excel, but in Aspose EMF images, the line appears to be missing in the PDF sometimes. As my clients will use the PDF file as the final publication format, the discrepancy and inconsistency would be considered as a quality issue.

Since Aspose mimics Office behaviour, we expect the Aspose produced EMF files to have the same compatibility than Office produced EMF, so that the final published output will always correctly reflect the original range.

Thank you for your suggestion.

I have tried your proposal and indeed it will get rid of the issue. However, this is more like a workaround with a side-effect that it adds another one point height onto the image.

Our clients are very strict about the layout of the images and sometimes a page can be filled with multiple such pictures. If we add one point onto each image, in the end, each image will have the gap and there could be additional 10+ points height on the page and the last images on the page could be moved to the next page.

Since Word is not requiring this gap/one more point height to show the borders properly (especially in the final PDF)

image.png (4.6 KB)

could Aspose mimics Office behaviours in a more similar way rather than requiring a workaround that would potentially cause layout issues?

Thanks,

@ServerSide527,

Thanks for further details.

Generally, we do mimic MS Office behavior (2003, 2010, 2013/2016, etc.) and it seems those lines might be visible in office365 only. Anyways, let us evaluate your issue further and we will get back to you soon.

@ServerSide527,

We will evaluate if we could adjust the position of borders which are on the boundary. Once we have an update on it, we will let you know here.

@ServerSide527,
This is to inform you that we have fixed your issue now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

@ServerSide527

Please try the latest fix 21.1.2
Aspose.Cells21.1.2 For .Net2_AuthenticodeSigned.Zip (5.5 MB)
Aspose.Cells21.1.2 For .Net4.0.Zip (5.5 MB)
Aspose.Cells21.1.2 For .NetStandard20.Zip (5.5 MB)

@Peyton.Xu thanks for your quick updates!

I have tested with the initial test files and indeed the issue does not seem to happen again.

I will do further tests after the official monthly build. Thanks again for your help!

@ServerSide527,
You are welcome.

The issues you have found earlier (filed as CELLSNET-47820) have been fixed in this update. This message was posted using Bugs notification tool by simon.zhao