Module #09: Custom
Document Converter Lab #02
(Optional)
Course: Programming Estimated Time to Complete: 45 minutes Objectives: · Operating
·
Deliverables: ·
|
Overview: Learn
to create your own Document Converter
Exercise 1 – Create the Converter
Purpose:
Create
a converter to transform a document
Result: A document converter
Task 1 – Create a Console
Application
- Open Visual Studio
- Create a new project
- Click “File->New->Project”
- Select “Console
Application” - For name, type “MyConverter”
- For location, type “D:Lab
Work”
- Click “Ok”
- Add a reference to
WindowsBase - Right click the
project, select “Add reference” - On the .NET tab,
select “WindowsBase” - Click “Ok”
Task 2 – Update the
code
- Update the program.cs file to
the following:
|
- Add a new class called
XmlToXml.cs - Right click the
project, click “New->Item” - Select “Class”
- For Name, type
“XmlToXml.cs”
- Click “Add”
- Modify the class code to the
following:
|
- Review the code you just
pasted in, mainly review the “Main” method - Right click the project, select
“Properties” - Click the “Debug” tab
- For Command line arguments,
copy the following:
|
- Compile the code, fix any
errors - Copy the executable (“D:Lab WorkMyConverterMyConverterinDebugMyConverter.exe”)
to the “C:program filesMicrosoft office servers12.0TransformApps”
directory. - NOTE: this is where
your document converters should reside, notice the other converters that
reside here: - DocXPageConverter
- InfoPathPageConverter
- XslApplicatorConverter
Task 3 – Set
permission on HtLauncher directory
1. Open
the “c:Program FilesMicrosoft office Servers12.0Bin” directory
2. Right
click the HtmlTrLauncher directory, select “Properties”
3. Click
“Security”
4. Add
everyone with Full Control
5. Click
“Ok”
Task 4 – Create a
feature and elements file
- Create a new directory called
MyConverter in the /template/features directory of the 12 hive - Create a file called
feature.xml, paste the following into it:
|
- Also note that you need to
replace the [new guid] with a new GUID - Run the D:Lab Files09_Lab02guidgen.exe
tool - Click “Radio #4”
- Click “Copy”
- Paste the GUID into
the feature.xml file - Remove the curly
braces ({}) - Create another file called
MyConverter.xml, paste the following into it:
|
- Be sure you create another
guid id for the converter! - Run the following commands:
|
- NOTE: if you copy and paste
and get an error when running the command, replace the dashes! - Perform an IISRESET
- Your new document converter
is now installed!
Task 5 –Enable
Document Converters
- Open the Central
Administration Site - Click “Application management”
- Click “Manage Web Application
features” - For the “My Converter”
feature, click “Activate” - NOTE: Ensure you are
in context of web application on port 100 - Click “Document Conversions”
- Ensure that the web
application is set to your team site web app - Check the “Yes” radio button
- Select a load balancer server
(you likely only have one to pick from) - Notice your new converter is
listed (“Customize “Xml to Xml” (xml into xml)) - Open in a new tab/windows the
link for the converter, note the settings you can apply - In the original central
administration window, click Apply
Task 6 – Test the
converter
- Open your team site (http://servername:100)
- Add an xml document to the
“Shared Documents” document library called TheirXml.xml with the following
text inside the file:
|
- In the JavaScript dropdown
for the item, select “Convert Document->Xml To Xml”
- For document name, type
“OurXml”
- Click “Ok”
- A timer job will pick up the
conversion request and put the converted document in the Pages document
library. As we mentioned previously
before, a document converter will not run on a domain controller properly.