Since these viewer pages (like quite many other system pages) don't use the master page settings of the sites, I couldn't apply any styles to them via the normal route, adding rules to the branding css file referenced on the master pages. Instead I created a new css stylesheet with only the style rules needed for these viewer pages and set it as alternate stylesheet and that worked.
But I wanted to include this file in my solution and make it as easy for the customer as possible to deploy the solution, I needed to do a couple things.
First, I added a new module in my solution, naming it StyleLibrary. In the solution explorer I created a folder for my custom stylesheet and added the stylesheet in the solution, inside the foder. Checking that the elements.xml file had the correct url's and paths:
Module Name="StyleLibrary" Url="style library"
File Path="StyleLibrary\Customer.AdditionalStyles\customer_additionalstyles.css" Url="Customer.AdditionalStyles/customer_additionalstyles.css" /
I set the solution up to deploy the stylesheet to the style library for use.
Then I fixed the feature receiver to set up the alternate stylesheet when the feature is activated so it doesn't have to be set manually. The code for feature activation with the alternate stylesheet setup only looks like this:
public override void FeatureActivated(SPFeatureReceiverProperties properties)
SPSite siteCollection = properties.Feature.Parent as SPSite;
if (siteCollection != null)
SPWeb topLevelSite = siteCollection.RootWeb;
// Calculate relative path to site from Web Application root.
string WebAppRelativePath = topLevelSite.ServerRelativeUrl;
WebAppRelativePath += "/";
// Enumerate through each site and apply branding.
foreach (SPWeb site in siteCollection.AllWebs)
site.AlternateCssUrl = WebAppRelativePath +
site.UIVersion = 4;
For the deactivation do the same, except replace the stylesheet path with "" only.