Configuring and Troubleshooting

Note

You can refer to the web-to-print solution based on AJAX Vector Objects, Customer's Canvas. You can consider it as a ready-to-use editor that you may want to embed into your website or as an example demonstrating how AJAX Vector Objects can be used for your needs.

This topic describes how to configure AJAX Vector Objects to store temporary files in a cache.

It also describes different approaches for determining issues, which may occur when your application works on both the server and client sides.

Working with Cache

When you launch an application using AJAX Vector Objects, it automatically creates a cache that preserves temporary files. By default, the cache is located in \App_Data\FileCache of your web application. However, you can configure the cache, changing its path and the time the files are stored. If you need to specify cache settings, create a section inside the <configSections> tag of the web.config file and specify parameters as the following snippet shows:

ASP.NET
<configSections>
    <section name="Aurigma.GraphicsMill.AjaxControls.VectorObjects.FileCacheConfiguration" type="System.Configuration.NameValueSectionHandler, 
      System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<Aurigma.GraphicsMill.AjaxControls.VectorObjects.FileCacheConfiguration>
    <add key="RootPath" value="C:\AJAXVectorObjectSamples\App_Data\Cache"/>
    <add key="MaxSize" value="4294967296" />
    <add key="CleanUpInterval" value="3600" />
    <add key="MaxUtilizationThreshold" value="90" />
    <add key="UtilizationTarget" value="70" />
</Aurigma.GraphicsMill.AjaxControls.VectorObjects.FileCacheConfiguration>

You can see from the snippet that the RootPath key allows you to change the path of the cache. Note, that the value takes the absolute path as a parameter. The MaxSize parameter limits the maximum size of the cache in bytes. This value is 10GB by default. There are two ways how AJAX Vector Objects can trigger the cache cleanup. First, you can specify the CleanUpInterval parameter defining an interval between cleanup runs, which is 1800 seconds by default. Also, you can trigger the cache utilization, combining the UtilizationTarget and MaxUtilizationThreshold parameters. When the cache size reaches MaxUtilizationThreshold, which is 95% by default, then the cleanup process starts. When the cleanup algorithm reaches the utilization level, the cleanup process stops. By default, UtilizationTarget is 70.

Configuring a Font Substitution

Your users may sometimes open PSD templates with fonts that are missing on your server. AJAX Vector Objects allows you to enable a font substitution feature for such cases through the FontSubstitutionEnabled parameter. You can configure this feature inside the <appSettings> section of the web.config file.

ASP.NET
<configuration>
    <appSettings>
        <add key="FontSubstitutionEnabled" value="True" />
        <add key="SubstitutionFontPostScriptName" value="ArialMT" />
        <add key="DefaultFontPostScriptName" value="ArialMT" />
        ...
    </appSettings>
</configuration>

If FontSubstitutionEnabled is False, then it triggers the AdvancedDrawing.FontFallbackException when a font referenced in a template is not found on the server. If this parameter is True, then it substitutes the font. SubstitutionFontPostScriptName allows you to define the PostScript name of the font to substitute a missing font with. By default, the value of this parameter corresponds to DefaultFontPostScriptName, which is the PostScript font name for any new text. By default, DefaultFontPostScriptName is ArialMT.

The FontSubstitutionEnabled parameter is ignored for auto-scaled text. If it meets an unknown font in a template, then it always throws the AdvancedDrawing.FontFallbackException.

Troubleshooting

AJAX Vector Objects provides flexible ways for determining and solving problems occurring when your application works. If an error occurs, AJAX Vector Objects writes a message describing the error to the System.Diagnostics.Debug by default. This means that you can see all the errors in the Output window in Visual Studio. For example, if you specify an incorrect path to fonts, you will see the following warning:

Output Window States an Warning

If you do not want to use Debug for debugging errors in your application, you can create your own logger. AJAX Vector Objects allows you to redirect all error messages to your logger. All you need to do is set the Configuration.LoggerFactoryMethod property. The following snippets demonstrate how to work with LoggerFactoryMethod:

C#
Aurigma.GraphicsMill.AjaxControls.VectorObjects.Logger.ILogger logger =  
    Aurigma.GraphicsMill.AjaxControls.VectorObjects.Logger.DotNetDebugLogger.Instance;
Aurigma.GraphicsMill.AjaxControls.VectorObjects.Configuration.LoggerFactoryMethod = () =>logger;
Note

The logger you create needs to implement the ILogger interface and its ILogger.Trace(System.String), ILogger.Warning(System.String), and ILogger.Error(System.String) methods.

Client Scripts Debugging

If you need to debug your application on the client side, you can use JavaScript console. After you open JavaScript console, you can find CanvasViewer by specifying the following command:

$find("<CanvasViewer_id>")

For instance, to get CanvasViewer created in the Your First Application with AJAX Vector Objects article, we need to specify this command, as the following image illustrates:

Using JavaScriptConsole

After getting CanvasViewer, you can perform the same commands in JavaScript console as on the client side. For example, the following command returns a current object on Canvas:

Using JavaScriptConsole: Getting Current Object

See Also

Reference

Manual

Other