Nov 18 2009

PDC Day 1 KeyNote Notes

Category: ASP.NET, SharePoint, Silverlight, Technology, WCF, WF, WPF, WinFormsAdam Toth @ 8:53 am

    Windows Azure Improvements since last year:

  1. Support PHP, CGI, Apache, other frameworks
  2. Expose very low-level programming efforts (not just .NET).
    Example was a C++ app with pointers exposed as an Azure service
  3. Identity framework (support passing tokens from federated locations i.e. onsite AD instance)

    SQL Azure Improvements since last year:

  1. Not just RESTful consumption of services anymore
  2. Works with standard TDS based tools (SQL management studio)

    Microsoft has a vision of "Three screens and a Cloud".

    The screens include:

  1. Mobile devices
  2. Desktop computers
  3. Internet connected TVs

    They can all be united by data and services in the cloud.

Public Data in the Cloud (Codename "Dallas").

Repository for public data sets that can be consumed in any number of ways (and easily by Azure)

Accessed through Microsoft PinPoint

Sign up for a CTP key

Some data includes NASA mars photos, GIS data, AP News articles

PinPoint:

Centralized marketplace for partner providers, Azure ISVs and implementers, and gateway to "Dallas" public Data.

"System Center" will plugin to Azure to monitor your Azure instances, check to meet SLAs, and enable you to scale up the Azure instances directly.

2010 will include ability to have the Azure cloud be able to establish a network connection to on-premise resources (i.e. self hosted SQL Server)

WordPress is moving to Windows Azure

Tags: , , ,


Jun 25 2009

Review – Accessibility Kit for SharePoint – Half Finished Product?

Category: SharePoint, TechnologyAdam Toth @ 3:29 pm

Rating: ★★☆☆☆

I’m implementing the AKS for a customer, and I’m having a hard time understanding how this product actually made it to a public release. It feels like a product that is half finished, that was used as a springboard to creating a commercial product, while leaving the original free version to the wayside. If you are considering working with this, you might want to read about the frustrations I encountered below:

Installation experience – Where are those .bat files?

When you download the AKS, you’ll get a zip file, which contains a folder and a single EXE installer.

Running the installer will perform the following tasks:

  1. Installs control adapters and reference files into an AKS folder in your Program Files directory.
  2. Copies a feature and master pages/css styles to the /12/Templates/Features folder in your SharePoint installation (if you are running 32 bit).
  3. Creates a Start Menu icon group for AKS tasks and links.

After running through the installer, a quick look at the “Welcome to the Accessibility Kit…” PDF informs you that you need to install and activate the feature:

The AKS Feature
The AKS Feature is not the AKS Kit but a part of the Kit that works as a feature in MOSS. The AKS
Feature installs the Example Master pages and the Modified CSS. You must install this by
selecting Install AKS Feature from the Start Menu:  Start | All Programs | AKS by HiSoftware |
AKS Feature install.  Once the feature is installed, you will still need to activate it within your
SharePoint application through: Site Settings | Site Collection Features. Please note if you are
on a 64 Bit server please follow the 64 Bit instructions.

I looked all over for those “64 bit instructions”, but there was nothing. There was a “64bit Feature Install” icon in the Start Menu, but no text anywhere instructing me to click on it.

I figured out that to install the feature, you need to click on either the 64bit Feature Install icon or the AKS Feature Install icon in the Start menu (note that the shortcuts are only created for the current user, and there is no way to tell the installer to install for everyone). If you run these shortcuts from the Start menu, the command window will flash, execute, and then immediately disappear, before you can check if it finished successfully or not. On a 64 bit server, you’ll see a flash of xcopy commands that copy styles and master pages into the /12 folders.

I wanted to be sure that it installed, so I tried to find the location of the batch file so I could run it again in a command prompt and actually see the result. I right-clicked the shortcut and went to Properties to figure out the target location, and it was greyed out:

image

I looked for the bat file in the Program Files directory, but no luck. Yuck! A .bat file that I can’t see or easily get to?

I figured out that it installed, because I then saw the feature in my Site Collection Features page. I activated it, and then tried to take a look at the master pages and styles.

Control Adapters – Incorrect C#

The AKS comes with several control adapters that rewrite some of the out-of-box control html to make it more compliant. Some of the C# adapter files have mistakes in the C# code that make them not able to compile. For example, in the Web Part Zone Smart Adapter for WCAG2.0, there is an extra curly brace, and even a reference to a variable that is not even declared in the file anywhere:

   1: else

   2: {

   3:

   4:     } // <-- Extra brace?

   5:

   6:     //Output sOutputBuilder to be rendered

   7:     oOutput.Write(sOutputBuilder.ToString()); // <-- sOutputBuilder is never declared in this file!

   8: }

“Smart Adapters” (not too bright)

The AKS comes with several “Smart” control adapters (adapters that do not need a lot of configuration). The Web Part Zone Smart Adapter sounded like it had some promise, as it would convert a web part zone to use divs instead of tables.

However, when you install it, it has the side effect of not rendering any of your web part’s “Titles”. If you want to use the headers that come with the web parts, then this control will not work for you. It also prevented viewing web parts in Design mode, they would just disappear from the page.

Finally, it was hard to see the point of using the adapters at all, as all they appeared to do was add some labels to blogs, wikis, and search boxes. They will certainly not do anything at all if you use the CKS EBE or Wiki versions, or if you have customized/branded the search controls.

Master pages and styles do not exist!

Once you install the feature, a set of master pages and css styles will get installed to the master page and style library galleries for your site collection. I cracked open SharePoint designer, tried to open a master page, and got a nasty error message that the file did not exist and could not be opened.

In order to open the file, I had to run through the SharePoint UI, and “Publish” each master page and CSS style before I could access it via SharePoint designer. There was no mention of this anywhere in the documentation.

Relative font sizes? Good luck!

The AKS stylesheets attempt to change all SharePoint font size declarations into relative sizes in ems, rather than fixed pixel/point sizes. This might work fine for anonymous internet site pages, but if you will ever let your visitors view any of the system pages like list new/edit/upload pages or use out-of-box web parts, good luck tweaking styles for a month to get things right.

Woops, what about default.master?

The AKS installs alternate versions of the out-of-box publishing master pages, such as BlueBand.master, BlackBand.master, etc. I don’t know about you, but none of my customers have ever started from those master pages on internet sites, and all my intranet applications make heavy use of default.master. I was really disappointed to see that there was no alternate version of default.master.

HCCE – Nothing but trouble

The HiSoftware Code Compliance Kit (HCCE) is a SharePoint event handler that will look for a certain string of text in your SharePoint web pages, and replace it with different (possibly more accessible) text. You use a text file in which you specify pipe-delimited lines of text to find and replace (e.g. “Text to find|Text to replace with”). The HCCE has the following problems when implemented:

  • There is only a debug build provided (no release version).
  • There is no source code (you cannot recompile).
  • There is no regex option for pattern matching. All strings must be matched and replaced exactly.
  • The DLL looks for a hard-coded path to the configuration text file in C:\Program Files\HiSoftware… This doesn’t work on 64bit systems because the installer installs to Program Files (x86). Since you can’t recompile the DLL, your only option is to copy the text file to the Program Files directory.
  • Once you implement the feature, your SharePoint Welcome menu will get rendered above the <html> tag, causing it to appear at the top of your screen and out of place. Several posts about this, and no response at all from HiSoftware.
  • The install/uninstall .bat files do not work, and need to be adjusted for 64bit machines. Why no WSP?

Conclusion

Poorly documented, sloppily put together, and full of holes and mistakes, I was very disappointed in the AKS. Coupled with a total lack of support and responsiveness to issues on their web site, I think it reflects poorly on HiSoftware as a company.

Tags: , , ,


Jun 15 2009

BDC Picker.aspx QueryString Triggers Firewall Security

Category: SharePoint, TechnologyAdam Toth @ 10:00 am

The implementation of the BDC entity picker dialog (opened with the Browse button) can cause some firewall and security software to think a worm or sql injection attack is happening and block the traffic.

The manner in which properties and entity IDs are encoded into long query string values makes the urls appear to be injection attacks. On a particular client’s BDC application, the picker dialog used a url similar to the following:

http://domainname.org/_layouts/Picker.aspx?MultiSelect=False&CustomProperty=uU2hhcmVQb2ludC5Qb3J0YWwsIFZlcnNpb249MTIuMC4wLAF%2F%2FAQAAAAAAAA9QcmltYXJ5Q29sdW1uSWQQU3lzdGVtSW5zdGFuY2VAAA
AAAMAgAAAF9NaWNyb3NvZnQjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibG
ljS2V5VG9rZW49NzFlOWJjZTExMWU5NDI5YwUBAAAAPk1pYAEAAAD%2F%2F%23Jvc29mdC5TaGFyZVBvaW50LlBvcnRhbC5XZWJDb250cm9scy5JdGVtUGlja2
VyRXh0ZW5kZWREYXRhB
JZAhFbnRpdHlJZBNTZWNvbmRhcnlDb2×1bW
5zSWRzAAAABw8PDw8CAAAANw4AAAcOAAAIDgAACQMAAAAPAwAAAAAAA
AAPCwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
3D&EntitySeparator=%00&DialogTitle=Choose%20User&DialogImage=%2F_layouts%2Fimages%2Fbizpicker.gif&PickerDialogType=Microsoft.SharePoint.Portal.WebControls.ItemPickerDialog%2C%20Microsoft.SharePoint.Portal%2C%20Version%3D12.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D71e9bce111e9429c&DefaultSearch=

Using the HTTP GET for this kind of thing is a bad idea, and I hope that Microsoft fixes this in the future.

Tags: ,


Apr 23 2009

WSS Script for non-AD Installation

Category: SharePoint, TechnologyAdam Toth @ 9:48 am

Here is a script for configuring WSS 3.0 installation without Active Directory, where SQL Server resides on a separate box:

psconfig -cmd -configdb -create -server DBSERVERNAME -database wss_admin_config -user WSSSERVER\AppPoolAccountName -password p@ssword -dbuser SQLDBUSERNAME -dbpassword p@ssword -admincontentdatabase wss_admin_content

Based on the post here:

http://blogs.msdn.com/fooshen/archive/2007/02/01/installing-moss-without-ad.aspx

Tags: , ,


Apr 15 2009

Spam your own Blog so you can be a SharePoint MVP!

Category: SharePoint, TechnologyAdam Toth @ 9:10 am

Ahh, my rant for today.

With the announcement of the name for the next version of SharePoint on the OFFICIAL SharePoint team blog, I am waiting for the inevitable flood of pingbacks, trackbacks, and reposts about this in my RSS reader. This will be similar to the flood of reposts about “SharePoint Designer is now Free!” I got a week ago. Same goes for the endless stream of tweets and retweets.

Is it really necessary to repost items from the official SharePoint team blog? If you are interested in SharePoint, you should be following this blog already, no?

I think much of this is a direct result of the MVP system and its requirements. When considering candidates for MVP, the quantity of blog posts, page hits, and comments are a big factor. I’ve seen some bloggers with high-quality posts get passed on as MVPs due to low numbers in their web stats. Are some bloggers trying to up their post counts? Is anybody monitoring quality as well as quantity?

I just can’t help but feel that this race to MVP status is encouraging this. Same goes for the MSDN SharePoint forums, where people seem to be falling all over themselves to answer questions as quickly as possible, without providing quality answers or even understanding the questions.

Tags: , ,


Apr 13 2009

SharePoint Field Names have 32 Character Limit – So Do Replicated Profile Property Names

Category: SharePoint, TechnologyAdam Toth @ 9:14 am

I ran into a situation where I created a User Profile Property with the Replicable checkbox set, which had a really long name. There were no errors when saving the profile property, however later on I started receiving errors in the Event Log:

failure trying to synch site [guid] for ContentDB [guid] WebApp [guid].  Exception message was A WSS internal name for profile property ‘ProfilePropertyWithReallyLongName’ could not be found..

Apparently SharePoint has a limit of 32 characters for Internal Field Names. This will also apply to Replicable User Profile Properties since they will get synced down to the WSS Content DB in the UserInfo list.

Tags:


Apr 09 2009

SharePoint May Break Hyperlinks in Workflow Task Emails

Category: SharePoint, TechnologyAdam Toth @ 11:54 am

I ran into an issue where hyperlinks in workflow task emails where being automatically changed by SharePoint from absolute hyperlinks to relative ones.

Scenario:

  1. You create a custom Visual Studio workflow and use the CreateTask activity.
  2. You set your SPWorkflowTaskProperties.Description property to some HTML text.
  3. In your Description HTML text, you have an html hyperlink <a> tag whose href=”” attribute contains an absolute hyperlink to a resource in the same SharePoint farm (i.e. a list item).
  4. Example: “Please review <a href=”http://yourserver/site/lists/yourlist/dispform.aspx?ID=1”>contract #12345</a>”.

Goal:

Users will receive the task email, and be able to click on the absolute URL in the email body to navigate to the SharePoint resource.

Problem:

It appears that SharePoint parses this HTML and readjusts the hyperlink and makes it relative.

Example: “Please review <a href=”/lists/yourlist/dispform.aspx?ID=1”>contract #12345</a>”

This effectively breaks the hyperlink in the email client.

The only workaround was to get rid of the <a> tag and write out the hyperlink in full. For example:

“Please review contract #12345 (http://yourserver/site/lists/yourlist/dispform.aspx?ID=1)”.

In this manner, SharePoint did not adjust the hyperlink at all.

Tags: , ,


Apr 09 2009

BDC Error – Type does not match DotNet type of TypeDescriptor

Category: SharePoint, TechnologyAdam Toth @ 10:36 am

I ran into a BDC error, “Type does not match DotNet type of TypeDescriptor”, with a particular application definition I wrote. In this case, I had a specific finder method that took one input parameter (the identifier) that was of type System.Decimal. It turns out I didn’t specify a default value in the TypeDescriptor for this input parameter in my XML definition. It looks like when you don’t set a default value, it will automatically set one for you and assign it a type of System.String. I was able to see this when I exported the BDC definition fresh, and noticed that SharePoint automatically added this default value and type for me.

Rule of thumb, always specify a default value for each input parameter.

Tags: ,


Apr 03 2009

Workflow Task Locked when AssignedTo Changed to Support Multiple Selections

Category: SharePoint, TechnologyAdam Toth @ 9:53 am

This is an old one, but some co-workers ran into this again recently on a project.

When you have a SharePoint workflow that assigns tasks (either Designer or Visual Studio workflow), when you change the Assigned To column on the task list to allow Multiple Selections, your workflow will hang and become unresponsive when a user edits the task. You’ll receive a message about the task being locked (“This task is currently locked by a running workflow and cannot be edited”). OnTaskChanged events will no longer fire and your workflow will be stuck and unrecoverable.

There is no hotfix or workaround for this, so you simply cannot have the assigned to column support multiple users or groups. Just use a single group instead.

Following are some other resources discussing this:

Tags: , , ,


Mar 19 2009

SharePoint Document Converter to PDF Using Oracle Outside In (How-to)

Category: SharePoint, TechnologyAdam Toth @ 11:55 am

I’ve seen several examples of creating document converters in SharePoint that convert documents to PDF format, using tools like Aspose and other print-based solutions.

I recently did a proof of concept for a customer that used a different product, Outside In PDF Export from Oracle. This is an interpretive converter that can take a slew of file formats (including MS Office) and automatically convert them into a PDF file. If you aren’t familiar with PDF conversion, there are two basic kinds:

  • Print based conversion – This is the Acrobat Distiller approach. Uses a printer driver that accepts the PostScript output from an application (such as Microsoft Word), and converts it to PDF. This approach results in the most accurate conversions, but is hardest to automate because it involves opening the native application and automating its “Print” functionality.
  • Interpretive conversion – This is an approach that reads the contents of a native file format and translates the contents into PDF format. This results in potentially less accurate conversions, but is much easier to automate.

Outside In, and in particular the PDF Export SDK, is an EXE and set of DLLs that contains logic to covert over 400 different file types to PDF. In combination with Transformation Server (a web services wrapper to PDF Export), you can create SharePoint Document Converters that will convert your documents to PDF format.

How I Did It

For the proof of concept, I followed these steps to get it working

  • Download PDF Export, Transformation Server, and SrvAny.exe.
  • Install and Configure the Transformation Server and Web Service
  • Develop and Install the Document Converter

Download of PDF Export 8.3.0 and Transformation Server 8.2.0

You can download both products here:

http://www.oracle.com/technology/products/content-management/oit/oit_dl_otn.html

You’ll have to register with an Oracle account to get it, but it is a freely available trial version, and does not appear to have any trial expiration limitations.

You will also need SrvAny.exe to run Transformation Server as a Windows Service. I found this site that had a download:

http://www.tacktech.com/display.cfm?ttid=197

Install and Configure the Transformation Server and Web Service

Extract the contents of the Transformation Server zip you downloaded to a folder on your server that will do the document conversions (e.g. “C:\PDFConverter”). There will be a bunch of dlls, some wsdl files (we’ll use those later), some EXE’s (which are run as a service), and some XML config files.

Transformation Server doesn’t really know anything about PDF generation, it is just a web service wrapper, so we’ll need to place the PDF Export library into our folder so it can use it. Extract the contents of PDF Export 8.3.0 to a separate folder on your machine. Grab every DLL in the root folder, as well as exporter.exe, px.cfg, and cmmap000.bin and copy those files into “C:\PDFConverter”.

Open the file called server_startup.xml in “C:\PDFConverter”. This configures the service to listen on a specific port and hostname/ip address. I went ahead and changed the port, but you can leave it as is if you wish, just make note of the port for later:

<!--Connections are the TCP/IP socket connections that the server accepts from clients.-->
<connectionsInfo xsi:type="tss:ConnectionsInfo">
    <!--The serverName is the host name, or dotted IP address that the server will use when establishing its presence on the network.-->
    <serverName xsi:type="xsd:string">localhost</serverName>
    <!--The port is the TCP/IP port that the server will establish a listener on for accepting connections.-->
    <port xsi:type="xsd:unsignedInt">9000</port>
    <!--The server will disconnect idle connections that have remained idle for too long. The activityTimeout sets the period of time a connection must be idle before it will be disconnected by the server.-->
    <activityTimeoutSecs xsi:type="xsd:unsignedInt">1800</activityTimeoutSecs>
</connectionsInfo>

Go ahead and double-click tsmanager.exe to make sure it is working. It should open a console window and show you what host/port it is listening on.

tsmanager console

Press Ctrl + C to quit.

Now we need to run this program as a service, so that it is always available, even when nobody is logged on to the server. Place instsrv.exe and srvany.exe in your C:\PDFConverter folder. Run the following command prompt:

C:\PDFConverter>instsrv.exe "Transformation Server" c:\PDFConverter\srvany.exe 

The service was successfuly added! Make sure that you go into the Control Panel
and use the Services applet to change the Account Name and Password that this
newly installed service will use for its Security Context.

Open regedit, and browse to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Transformation Server.

Create a new key called Parameters, and add a new string value inside this key called Application, with a value of C:\PDFConverter\tsmanager.exe.

ts registry entries

Go to the services console and start the Transformation Server service. Optionally, you can also go to the Properties for this service account, and change the Identity that this service runs under.

Develop the Document Converter

Create a new .NET C# console application project and solution from within Visual Studio 2008, called PDFConverter.

Right-click the project in Solution Explorer and choose Add Service Reference…

Since the wsdl files for Transformation Server are not compliant with WCF services, choose the Advanced… button on the Add Service Reference dialog, and then choose the Add Web Reference… button to add a .NET 2.0 style web service reference. In the Add Web Reference dialog, enter the path to the wsdl file: C:\PDFConverter\transform_net_2005.wsdl. Hit Go.

Once your web reference has resolved, enter TransformationServer in the Web reference name box and click the Add Reference button.

Open your Properties/Settings.settings file. There will be one setting in the file for the web service URL. Change this to the right hostname/port in your server_settings.xml for Transformation Server. Make sure to include a trailing “/transform” on the end, e.g.:

http://localhost:9000/transform

A document converter is just a console EXE that is called by SharePoint with command line arguments, so we’ll setup our console app to handle the arguments. In Program.cs, before static void Main, add the following code (taken from the WSS SDK here):

#region Argument Handling Data
 
private enum ArgumentCode
{
    Help,
    InputFile,
    OutputFile,
    LogFile,
    ConfigFile
}
 
private struct ArgumentPair
{
    public ArgumentPair(ArgumentCode c, string s)
    {
        this.argType = c;
        this.argFlagString = s;
    }
 
    public ArgumentCode argType;
    public string argFlagString;
}
 
private static ArgumentPair[] PossibleArguments = new ArgumentPair[] {
    new ArgumentPair(ArgumentCode.Help, "-?"),
    new ArgumentPair(ArgumentCode.Help, "-help"),
    new ArgumentPair(ArgumentCode.InputFile, "-in"),
    new ArgumentPair(ArgumentCode.OutputFile, "-out"),
    new ArgumentPair(ArgumentCode.LogFile, "-log"),
    new ArgumentPair(ArgumentCode.ConfigFile, "-config"),
};
 
private static Dictionary<ArgumentCode, string> actualArguments = new Dictionary<ArgumentCode, string>();
 
#endregion
 
/// <summary>
/// Prints out the usage help to the console.
/// </summary>
static void PrintUsage()
{
    Console.WriteLine("Usage: {0} -in <inputfilename> -out <outputfilename> -config <configfilename> [-log <logfilename>]",
                      Assembly.GetExecutingAssembly().ManifestModule.Name);
}

Add the following code inside static void Main:

#region Argument Handling Code
// Read arguments.
for (int i = 0; i < args.Length; i++)
{
    bool argumentValid = false;
    foreach (ArgumentPair ap in PossibleArguments)
    {
        if (String.Compare(ap.argFlagString, args[i], StringComparison.OrdinalIgnoreCase) == 0)
        {
            switch (ap.argType)
            {
                case ArgumentCode.Help:
                    PrintUsage();
                    return;
 
                case ArgumentCode.InputFile:
                case ArgumentCode.OutputFile:
                case ArgumentCode.ConfigFile:
                case ArgumentCode.LogFile:
                    if (i + 1 < args.Length)
                    {
                        actualArguments[ap.argType] = args[i + 1];
                        i++;
                        argumentValid = true;
                    }
                    break;
            }
            break;
        }
    }
 
    if (!argumentValid)
    {
        Console.WriteLine("unknown argument {0}", args[i]);
        PrintUsage();
        return;
    }
}
 
// Validate arguments.
if (!actualArguments.ContainsKey(ArgumentCode.InputFile) ||
    String.IsNullOrEmpty(actualArguments[ArgumentCode.InputFile]) ||
    !actualArguments.ContainsKey(ArgumentCode.OutputFile) ||
    String.IsNullOrEmpty(actualArguments[ArgumentCode.OutputFile]) ||
    !actualArguments.ContainsKey(ArgumentCode.ConfigFile) ||
    String.IsNullOrEmpty(actualArguments[ArgumentCode.ConfigFile]))
{
    Console.WriteLine("required argument missing");
    PrintUsage();
    return;
}
 
#endregion

Now that the command line arguments can be parsed, it is time to use the web service and do the document conversion. The Transformation Server download contained some code samples for C#, and I was able to basically use as-is, only modifying the input and output file paths. After the argument handling code in static void Main, add the following code:

TransformationServer.transform t = new TransformationServer.transform();
 
TransformationServer.IOSpec source = new TransformationServer.IOSpec();
source.spec = new TransformationServer.stringData();
source.spec.base64 = false;
source.spec.charset = TransformationServer.CharacterSetEnum.windows1250;
source.spec.str = actualArguments[ArgumentCode.InputFile];
source.specType = "path";
TransformationServer.IOSpec sink = new TransformationServer.IOSpec();
sink.spec = new TransformationServer.stringData();
sink.spec.base64 = false;
sink.spec.charset = TransformationServer.CharacterSetEnum.windows1250;
sink.spec.str = actualArguments[ArgumentCode.OutputFile];
sink.specType = "path";
string outputFormat = "pdf";
string optionSet = "";
TransformationServer.Option[] options = new TransformationServer.Option[0];
TransformationServer.stringData resultMsg;
TransformationServer.IOSpec[] resultDocs;
UInt32 result = t.Transform(source, sink, outputFormat, optionSet, options, out resultMsg, out resultDocs);
Console.WriteLine("The result is {0} {1}", result, resultMsg.str);
foreach (TransformationServer.IOSpec ios in resultDocs)
{
    ASCIIEncoding encoding = new ASCIIEncoding();
    string constructedString = encoding.GetString(Convert.FromBase64String(ios.spec.str));
    Console.WriteLine(" {0}", constructedString);
}

Most of this code is cut-and-paste from the sample, and we are just swapping the input file path (source.spec.str) and output file path (sink.spec.str) with the arguments from the command line.

Installing the Converter

To install the converter, you need to create a feature file, install the feature, and place the converter EXE in the proper directory.

Create a feature.xml file and add the following:

<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
    Id="{9E2A5231-0D81-4de8-8504-36A61026680E}"
    Title="PDF Converter"
    Description="PDF Converter."
    Scope="WebApplication">
  <ElementManifests>
    <ElementManifest Location="Elements.xml"/>
    <ElementFile Location="PDFConverter.exe"/>
  </ElementManifests>
</Feature>

Create an Elements.xml file, and add the following code. You can create as many document converter nodes as you need for each file type you want to convert (just make sure each has a unique guid).

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <DocumentConverter Id="{513130EB-A1BC-46d3-919C-1E00B6BCA742}"
      Name="DOCX to PDF Converter"
      App="PDFConverter.exe"
      From="docx"
      To="pdf"
    />
  <DocumentConverter Id="{E7374437-157E-4fb4-A4E9-A19026BAE17A}"
    Name="VSD to PDF Converter"
    App="PDFConverter.exe"
    From="vsd"
    To="pdf"
    />
</Elements>

Place both these files in a folder called PDFConverter in your …/12/TEMPLATE/Features folder, and use stsadm to activate the feature on a particular web application.

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN>stsadm
-o installfeature -name PDFConverter 

Operation completed successfully.  

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN>stsadm
-o activatefeature -name PDFConverter -url http://mossdev:8080 

Operation completed successfully.

After activating the feature, go to Central Administration, Applications tab, and click the Document Conversions link. Ensure that your web application has document conversions turned on. You should see your document converters in the list at the bottom of the screen:

Document Conversion Settings

Since you are using a Web Service, a proxy class needs to be generated dynamically, and so you’ll need to give your SharePoint Document Conversion User Account rights to create this in C:\Windows\Temp (or whatever your system temp directory is). Grant List Folder Contents and Read permissions to the Document Conversion account (usually a local machine account that starts with “HVU_”) on your Temp folder.

The Document Conversion service stores temporary documents in the following folder: C:\Program Files\Microsoft Office Servers\12.0\BIN\HtmlTrLauncher. By default, this folder only grants the Document Conversion User account access. Since the Transformation Server windows service is running under its own account, you need to give this account access to the folder. Grant the account that your Transformation Server windows service is running under Read and Write access to this folder.

The last step involves copying over your compiled console EXE and exe.config file into the following SharePoint folder (the actual path may vary depending on your setup, but you should be able to find the TransformApps folder):

C:\Program Files\Microsoft Office Servers\12.0\TransformApps

Results

Navigate to your SharePoint site. Upload a document into your document library (make sure it is a file extension that you’ve configured in your Elements.xml file). Open the drop down menu and choose Convert Document. Your document converter should appear in the list. Run the conversion. After around a minute if you refresh your document library and all went well, you should see your PDF file in the library.

Generated PDF in document library

Here is a picture of a generated Visio document in PDF format, not too bad:

exported visio file

Tags: , , , , ,


Next Page »