Working with images in RDLC reports and Visual Studio 2010 in NAV 2013 are unfortunately not done without doing some workarounds.
In this blog I will address 2 issues with images in RDLC reports:
- Images with transparent background will not show correctly when opened in PDF.
- Images will show unexpected lines at the edges of the image when printed.
Let us start with Transparent background issue:
Several times I have received company logos which transparent background in PNG format. The logos look great in the RDLC report when printed, and viewed in either Print layout or Print Preview, but when saved to PDF the image looks compressed when opening report in Acrobat Reader, i.e. version 11. Funny enough this is only when viewing the PDF file. When printing to paper from Acrobat Reader the image looks great.
But usually when printing to PDF we don’t plan on doing printing to paper, so we of course want the image to look great in Acrobat Reader as well. Here is a screen dump from Acrobat Reader of an image in PNG format with transparent background and an image in JPG format with no transparent background. Maximize the picture here, then it easy for you to see the difference.
Here is the workaround for getting the image to look nice in Acrobat Reader:
1. Open image with transparent background in Paint
2. Save the image in JPG format.
3. Accept that transparent background will be removed
4. Import image into report again and print to PDF. Issue is then solved. This of course does not work if you are required to have the transparent background in your report.
Note that PDF viewer in Windows 8 does not have this issue, so this seems like a Acrobat Reader issue.
Next issue; Unexpected lines showing at the edges of the image when viewing the report in Print Layout and when printing from either Print Preview or Print layout in Report Viewer.
When viewing the report in Print Preview and when printing to PDF this issue is not seen. But if you print to directly from Report Viewer images will have extra lines at the edges of the image:
Here is a screen dump from Report Viewer in Print Layout mode, and how it will look at paper when printed. It seems like start of the A in Abakion is printed in the end of the picture and the top of the head of the guy in the logo is printed under his right foot. This is clearly a bug in Report Viewer 2010. This bug is not solved in Report Viewer 2012, so I guess it is time to request a hotfix for Report Viewer 2010 and Report Viewer 2012.
Here is the workaround for getting the image to look nice in Report Viewer:
1. We need to increase the canvas size of the image. Unfortunately no standard image tools can do this in Windows. But lucky one of the developers of Paint in Windows left Microsoft long time ago and created Paint.NET a great Image tool for us, and best thing is that it is free. Paint.NET can be downloaded here: http://www.getpaint.net/
2. Open Image in Paint.NET.
3. Select “Image / Canvas Size”
4. Increase Width and Height with 10 pixels
5. Make sure that Anchor is set to Middle. We want to have middle here because we want make a border outside the image of 10 pixels so edges of the real picture is not repeated on other edges of the image.
6. Save image and Import image into report again.
7. View report in Print Layout in Report Viewer and try to print report to real paper. As you can see issue is now solved.
I hope this post was useful for you.