Register for a free webinar to learn more about the latest version of our software.
This is an old documentation. Go to the latest Customer's Canvas docs

Loading Templates

The Design Atoms Framework allows for loading Photoshop and InDesign templates. The Creating Product Templates section describes the supported features and demonstrates how you can create your templates. To load these templates, you can use the ITemplateParser interface. In the previous example, you learned how to instantiate this interface through DI.

var parser = Injector.Instance.Resolve<ITemplateParser>();

Now, let us see how you can:

  • Load a multipage IDML template:
    var product = parser.FromIdml("invitation.idml");
  • Load a one-page template:
    var product = parser.FromFile("postcard.psd");
  • Load two templates for a two-page product:
    var product = parser.FromFiles("businesscard_front.psd", "businesscard_back.psd");

When you need to load three or more templates, you can pass an array of their file names into the FromFiles(String[]) method. You can also create a product based on a surface definition as in the following sample.

The Sample

This sample illustrates how you can create a two-page product by using the FromDefinition(SurfaceTemplate[]) method. Here, we load the card.idml into the first page.

using System.IO;
using System.Drawing;
using Aurigma.DesignAtoms.Configuration;
using Aurigma.DesignAtoms.Convert;
using Aurigma.DesignAtoms.Rendering;
using Autofac;
using Newtonsoft.Json;

namespace DesignAtomsConsole
    class Program
        static void Main(string[] args)
            // Setup dependency injection.
            Injector.CurrentFactory = () => DefaultInjectorFactory.Create();

            // Instantiate TemplateParser.
            var parser = Injector.Instance.Resolve<ITemplateParser>();
            // Create a product based on a surface definition.
            var product = parser.FromDefinition(new[] {
                new SurfaceTemplate
                    // Load an IDML template.
                    DesignFilename = "card.idml"
                new SurfaceTemplate
                    // Create an empty surface.
                    Size = new SizeF(300, 300)

            // Instantiate IProductRenderer.
            var renderer = Injector.Instance.Resolve<IProductRenderer>();
            using (var fileStream = File.Create("card.pdf"))
                // Render the product to a file.
                renderer.RenderHiRes(fileStream, product);

See Also