Recently a partner approached us with an interesting request from a DocMaker customer.
They had noticed that you can download InDesign documents as PDF files in DocMaker Studio and wondered
if it would be possible to do something similar when ordering InDesign documents in AssetStudio.
Ideally, the customer would also like to use different PDF export settings depending on the application (e.g. screen
resolution vs. print resolution).
It turns out that it is quite easy to do this once you put all pieces of the puzzle together. It also turns out
that this makes an excellent topic for a blog post, so here we go.
Defining PDF export presets
The first thing we need to do is decide which PDF export presets we want to make available for use on the server.
You can always use the predefined presets but you can also define custom presets using Adobe InDesign:

When defining new presets, you can specify detailed options for compression, color conversion and much more.
For instance, here we specify that the exported PDF should include color bars and bottom bleed.

All presets are stored in the common Adobe PDF Settings folder, so they can be used by both InDesign and InDesign Server
if running on the same system. If you want to use your custom presets on a different server, you can copy them manually
to the settings folder. On Windows Server 2008, the location of this folder is C:\Users\[User]\AppData\Roaming\Adobe\Adobe PDF\Settings.
You will need to restart InDesign Server before using the new presets.
Creating the custom order target action
To be able to export InDesign documents to PDF when ordering files in AssetStudio, we need to create a custom order target
action. How to do this in general is explained in the ADAM Developer Guide. Here we will focus on how we can use the
DocMaker API to accomplish our goal in a simple way.
DocMaker 3.0 includes an InDesignServerMediaEngine that communicates with InDesign Server through the DocMaker Queuing Service.
This media engine supports several media actions that are used when indexing or downloading InDesign documents.
Of course all of this fits right into the generic ADAM provider framework, so you are not limited to using it
in a Web2Print context.
The media action needed for our purpose is the CreatePdfMediaAction. When running this action, you can
specify the original InDesign document, the path for the exported PDF, and the name of the PDF export preset that
should be used. The preset name can be made a property of our custom order target action. Full source code is included
below, but the interesting part is how a MediaManager is used to run a CreatePdfMediaAction
against an InDesignServerMediaEngine when executing the order:
| C# |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
protected override void OnExecute()
{
string originalPath = Target.Path;
string newFileName = Path.GetFileNameWithoutExtension(originalPath) + ".pdf";
string newPath = Path.Combine(App.GetEmptyFolder(), newFileName);
InDesignServerMediaEngine mediaEngine = new InDesignServerMediaEngine(App);
CreatePdfMediaAction mediaAction = string.IsNullOrEmpty(PresetName)
? new CreatePdfMediaAction(true, originalPath, newPath)
: new CreatePdfMediaAction(true, originalPath, newPath, PresetName);
MediaManager mediaManager = new MediaManager(App);
mediaManager.Run(new MediaEngine[] { mediaEngine }, new MediaAction[] { mediaAction });
if (mediaAction.IsSuccess)
{
Target.Path = newPath;
Target.OrderedName = newFileName;
}
}
|
Since we want to allow users to choose the preset used when ordering the exported PDF, we also need to implement a web
control that binds an input field (e.g. a text box or a dropdown list) to the preset name property of the order target
action. See the source code listing for details.
Putting it all together
The final step is to register our new class library either in the GAC or in the ADAM database (as explained in the ADAM
Developer Guide). We also need to add our custom provider (consisting of an order target action and a web control) to the
"Order target action providers" setting in ADAM:
| XML |
1
2
3
|
<engines>
<add name="ExportToPdfAction" type="ExportToPdfLibrary.ExportToPdfAction,ExportToPdfLibrary" webControl="ExportToPdfLibrary.PresetNameUI,ExportToPdfLibrary" />
</engines>
|
Here is what it looks like when ordering an InDesign file in AssetStudio. We can now add an
ExportToPdfAction to our order and specify the name of the PDF export preset that should be used:

The result is that we no longer order the original InDesign file, but a PDF version instead.
This is what the exported PDF file looks like, including the color bars and bottom bleed specified in our custom preset:

This is the behavior the customer was looking for, and thanks to the DocMaker API, it only took us a few lines of code to implement.
Of course, for all of this to work, InDesign Server and the DocMaker Queuing Service need to be up and running.
As promised, the full source code is included for all of you to try out, but the usual warning applies
that the code has been kept as simple as possible for illustrative purposes and that you should at least
add more robust exception handling etc. before taking it into production.
Sample Code
The article contains sample code project(s).
You must be logged in to view or download sample code.
Sign in now