Hello,
I am using DocIO with Mail Merge to generate a Word document. Everything seems to work fine except the sizing of the images. I use images in WMF format and would like to size them to the width of the document area. The images appear very small and although I can change the Width/Height or WidthScale/HeightScale properties of the image in the MergeImageField event, I can't make any sense between the settings and the result. I even tried to hardcode the width of the image to the document area width using the PointsConverter class (picture.Width = PointsConverter.FromCm(15.92f);) but that also does not result in anything helpful.
I then tried to use images in png format and these do in fact work correctly and the result is as expected.
Is there anything special I need to consider when using WMF images?
I provided an example based on one of your Mail Merge example projects where you can see the result.
Thanks in advance
Hi Michael,
We have reproduced the reported problem “WMF image in mail merge display
incorrect size in Word document” in our end. We will validate this issue and update you with more details on 2nd
September 2024.
Regards,
Dharanya.
Michael,
upon further analysis, we found that the PNG and WMF image formats handle
height and width settings differently. We need additional time to analyze the
WMF image. We will validate and share the details within two days.
Regards,
Dharanya.
Hello Dharanya,
Thank you for the feedback. Am I correct to assume that it is a problem with vector based graphics format in general? I also tested it using .svg format with the same result.
Michael,
We have confirmed that the reported issue with "WMF image size is not
preserved properly after executing mail merge” is a defect and we have
logged a defect report. We will include the fix for this defect in our weekly
NuGet release, which is estimated to be available on 24th September
2024.
The status of this bug can be tracked through the below link:
WMF
image size is not preserved properly after executing mail merge in WinForms |
Feedback Portal (syncfusion.com)
Disclaimer: Inclusion of this solution in the weekly release may change due to
other factors including but not limited to QA checks and works
reprioritization.
Regarding “Am I correct to assume that it is a problem with vector based
graphics format in general? I also tested it using .svg format with the same
result.”:
The problem is not related with vector-based graphics format. The current issue
is only related to EMF and WMF format image
Regards,
Dharanya.
Hello Dharanya,
Thanks for the feedback and the ETA for the bugfix. Concerning the .svg format I was probably facing another issue but I think I will just wait for the bufix and then continue to use images in WMF format.
Regards,
Michael
Michael,
Regarding SVG image format:
To ensure proper rendering of SVG images in Word documents during mail
merge, it is important to provide fallback bitmap images. In Microsoft Word, a
fallback bitmap image is automatically created when inserting an SVG image. As
similarly in Syncfusion DocIO also requires a fallback image to handle SVGs
correctly during rendering and conversion.
Case 1: Using Bitmap Images
You can directly use the bitmap image (e.g., PNG) in place of an SVG, the image renders correctly in the Word document without any issues. Refer to the code snippet to use bitmap images.
|
FileStream imageStream = new FileStream(Path.GetFullPath(@"../../../Data/Buyers.png"), FileMode.Open, FileAccess.Read); args.ImageStream = imageStream;
|
Case 2: Using SVG with Fallback Bitmap Images
If you want to use an SVG image, you can
provide both the SVG image and a fallback bitmap image. The fallback image is
used for rendering and conversion in Word, while the SVG remains in the file. Refer
to the code snippet to set up SVG and the fallback image in DocIO.
|
FileStream imageStream = new FileStream(Path.GetFullPath(@"../../../Data/Buyers.png"), FileMode.Open, FileAccess.Read); args.ImageStream = imageStream; byte[] svgData = File.ReadAllBytes(Path.GetFullPath(@"../../../Data/" + ProductFileName)); WPicture picture = args.Picture; picture.LoadImage(svgData,imageBytes); |
Regarding "WMF image size is not preserved properly after
executing mail merge”:
We will include the fix for this defect in our weekly NuGet release, which
is estimated to be available on 24th September 2024.
The status of this bug can be tracked through the below link:
WMF
image size is not preserved properly after executing mail merge in WinForms |
Feedback Portal (syncfusion.com)
Regards,
Dharanya.
Hello Dharanya,
Thank you very much for this detailed information regarding svg image format. Since the svg format requires a fallback bitmap image, I don't see any advantage over using a bitmap image like png directly. Especially since I can still decide in which format I need to prepare all Images used during Mail Merge. In this case I will use PNG format until the fix for the WMF image format has been released.
Regards,
Michael
Michael,
As you mentioned in the previous update, you can use all images as PNG format
during mail merge process to preserve properly.
Regarding "WMF image size is not preserved properly after
executing mail merge”:
We will include the fix for this defect in our weekly NuGet release, which
is estimated to be available on 24th September 2024.
The status of this bug can be tracked through the below link:
WMF
image size is not preserved properly after executing mail merge in WinForms |
Feedback Portal (syncfusion.com)
Regards,
Dharanya.
Michael, as we have promised earlier, we have included the fix for the reported issue with “WMF image size is not preserved properly after executing mail merge” in our latest weekly NuGet
release (v27.1.50).
Root cause of the issue:
Image loaded is in WMF
format which we have not handled before properly. So this issue occurs.
Please use the below link to download our latest weekly NuGet:
Syncfusion.DocIO.Net.Core
The status of this bug can be tracked through the feedback link.
Hello Dharanitharan,
Thanks for the update. Today I updated the nuget packages to version 27.1.50 but was not yet able to test the fixed issue because we get build errors in the Syncfusion scss files. I will let you know as soon as I was able to test it.
Kind regards
Michael
Michael, we suspect that the mentioned build error might be due to
NuGet packages version conflicts while updating the Syncfusion.DocIO.Net.Core
NuGet package to the latest version. To resolve this, we suggest you to clear the NuGet cache. You can
refer to the following KB article to learn how to clear the cache:
How
to clear NuGet cache?
Kindly ensure whether you have installed all the required Syncfusion NuGet packages
in the same versions after clearing the cache.
Hello Dharanitharan,
I followed your suggestion and cleared the NuGet cache. Then made sure that the same version of all Syncfusion nugets is installed (27.1.50). Unfortunately we still get the same build error.
Michael, we are currently checking
the reported build error with respective team, we will update the details on
two days.
Michael, upon checking the
error details, we came to know that the issue is occurring from the custom CSS
file which you are using in your application. Please share us your sample application, thereby we will analyze further and
provide you the appropriate solution at the earliest.
Hello Dharanitharan,
Me and my colleague have been testing some more yesterday and have found out a few things. When we downgrade to the latest version of V26 (26.2.14) everything still works fine. As soon as we upgrade to version 27 (27.1.50) we get the build error. We also use a separate project to manage all our syncfusion dependencies so we are able to isolate the problem from our own code. To compile the scss files we use the Web Compiler 2022+. My colleague opened a separate incident concerning the Web Compiler compile error which you can find here 638721. There you can also find the sample project which shows the problem.
Regards,
Michael
Michael, as you have created a separate ticket for this build error, kindly follow
the ticket - 638721
for further details and solutions.