InfoPath 2010 provides the ability to use a background image behind each view to (hopefully) enhance the appearance of the form.
When choosing this option, however, it is not possible to select from an image resource that you may have created, like when using a PictureButton. Instead, for each view in the form, one must browse the file system for the desired image. If the same image is used repeatedly, InfoPath will stupidly embed duplicate copies of the same file, with a number appended to the name.
So if you have four views, and have added the same image as a background to all four views, your .xsn file will now contain four copies of the same image, something like “image.png”, “image1.png”, “image2.png” “image3.png”. If the files are small, this may not be a big deal, but if your background image is large enough (say 50 KB), your .xsn file will be 150 KB larger than it needs to be.
Fortunately, this problem can be easily addressed as follows:
1. Configure your form views with background images, save the form, create a backup of the file somewhere in case you accidentally “break” the exported copy that will be modified in the following steps.
2. On the File tab, choose Publish>Export Source FIles, and export the form component to some location on your system.
3. Browse to this location, note the similarly named image files among the exported files.
4. Identify the image file you wish to re-use, i.e “image.png”, others such as “image1.png”, image2.png”, etc. are the duplicates that will be deleted.
5. Delete the duplicate images, saving only the “image.png”.
6. Open manifest.xsf in Notepad, search for and delete file tags containing the duplicate references, e.g.
“<xsf:file name=”image2.png”></xsf:file>”,
leaving only the single reference to the desired image.
7. Each view in the form will have an .XSLT (XML stylesheet transform) file. Open each of these in Notepad, and search for the image name, it should be located in the body tag as an attribute, e.g.
“<body style=”BACKGROUND-REPEAT: repeat” background=”image.png”>”.
Edit the attribute value to point to the chosen image name.
8. Save all files.
9. Open manifest.xsf using InfoPath Designer, verify that the form can be opened and it behaves correctly.
10. Save it as the original .xsn file, or create a new file name.
11. Continue development using this newly update .xsn file.
Filed under: Form Design, InfoPath Tagged: Background, Bloated, Duplicate, Images, InfoPath
