Friday, August 30, 2013

Sitecore and APS Saga. Configurations, setting up of Print Studio Projects, PDF generation

A little bit of history

I have been working on this project where we need to generate a PDF version of biographies that would be looking nice enough for print. Another goal is to join these biographies into one brochure. We are a Sitecore shop, and needless to say APS (Adaptive Print Studio) module was the first one to be considered. Everything sounds great during the sales pitch, and looking through JetStream solution was very convincing. Then the real world came up on us. I started implementing it and realized that it is not as simple as I would hope.

My APS journey was a road of extensive back and forth with Sitecore support team, digging through documentation, trying things out, researching through writing code that I hoped would produce necessary results and so on until I was introduced to Mark Demeny from Sitecore. He was very helpful and provided me with information I was so desperately seeking. Only after speaking with Mark, I started to understand the magnitude of APS and what it is capable of.

I figured I would share what I've learnt and results I've managed to accomplish. If you are looking into possibility of using APS module for your solution, this post might save you a few days of searching for answers.

Task at hand

Here is quick overview of the requirements:
  • Create PDF version (print quality) for every biography on the site (1,200 of them);

  • Join some of these biographies and related articles into a book (PDF). This should be author controlled. Book needs to be personalized for every user who chooses to download it.
Overview of implementation turned out to be a long document with lots of screenshots. I was debating whether to post it as a bunch of posts or as one PDF file and decided in favor of a PDF. I believe it will be easier to read and work with if you decide to reuse some of the code included in it.

Overview of implementation (PDF):



Configuring Elmah in GAC


If you are running several applications on the same server and prefer not to configure Elmah separately for each application, you can configure Elmah in GAC. The following article was extremely helpful and covers most of the process: http://www.codeproject.com/Articles/235201/ELMAH-in-the-GAC-Using-ELMAH-from-the-Global-Assem However following it didn't really get me where I wanted and my Elmah logging still didn't work. So here is what I ended up doing.

Steps

  1. Install Elmah strongly signed assembly to GAC.
  2. Add Elmah connection string to Connection Strings in features view (IIS 7) on server level.
  3. Change .NET Framework version to 4.0
  4. Make sure all apps are running .NET 4 (in my case they are).
  5. Open C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\web.config as admin
  6. Add the following lines: 
<configsections> 
    ...
    <!-- Begin an ELMAH specific section -->
    <sectionGroup name="elmah">
      <section name="security" requirePermission="false"
         type="Elmah.SecuritySectionHandler, Elmah, Version=1.2.14706.0, Culture=neutral, PublicKeyToken=d91c50d0d0b9de11"/>
      <section name="errorLog" requirePermission="false"
         type="Elmah.ErrorLogSectionHandler, Elmah, Version=1.2.14706.0, Culture=neutral, PublicKeyToken=d91c50d0d0b9de11"/>
    </sectionGroup>
    <!-- End an ELMAH specific section -->

</configSections>

  <!-- Begin an ELMAH specific section -->
  <elmah>
    <security allowRemoteAccess="yes" />
    <errorLog type="Elmah.SqlErrorLog, Elmah, Version=1.2.14706.0, Culture=neutral, PublicKeyToken=d91c50d0d0b9de11"
       connectionStringName="ELMAH" />
  </elmah>
    <!-- End an ELMAH specific section -->

 <!-- Begin an ELMAH specific section -->
    <location path="elmah.axd">
        <system.web>
            <authorization>
                <deny users="?"/>
            </authorization>
        </system.web>
    </location>
    <!-- End an ELMAH specific section -->


  1. In Features View on the server level open Modules and add : Name = Elmah, Type = Elmah.ErrorLogModule, Elmah, Version=1.2.14706.0, Culture=neutral, PublicKeyToken=d91c50d0d0b9de11
  2. In Features View on the server level open Handler Mappings and add Managed Handler. Name = Elmah-Logging, Path=elmah.axd, Type = Elmah.SecuritySectionHandler, Elmah, Version=1.2.14706.0, Culture=neutral, PublicKeyToken=d91c50d0d0b9de11
  3. Make an app throw an exception.
  4. Check Elmah DB for logged errors.