We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Linq reporting doc template uri

I see in the documenation we can have sub template with
<<doc [document_expression] -build >>

is it possible to set the document expression with a relative path, from where the main template is located ?

we want to use sub template but if the path needs to be absolute it is difficult to share between users.


You cannot use the document expression with relative path. When document is loaded into Aspose.Words’ DOM, it does not contain any information about document’s path.

We suggest you please read the following article about document expression.
Inserting Documents Dynamically

ok thanks, what i did is to change manually the template doc to introduce this feature. (quite easy to do using )

FindReplaceOptions replaceOptions = new FindReplaceOptions();
// <<doc [".
replaceOptions.ReplacingCallback = new ReplaceRelativePathInSubTemplateEvaluator(templatePath);
doc.Range.Replace(new Regex("<<doc \["\.\/"), string.Empty, replaceOptions);

internal class ReplaceRelativePathInSubTemplateEvaluator : IReplacingCallback
string relativePath = string.Empty;

  public ReplaceRelativePathInSubTemplateEvaluator(string templatePath)
    this.relativePath = Path.GetDirectoryName(templatePath).Replace("\\", "/");

  public ReplaceAction Replacing(ReplacingArgs e)
    DocumentBuilder builder = new DocumentBuilder((Document)e.MatchNode.Document);
    string docTag = string.Format("<<doc [\"{0}/", this.relativePath);
    return ReplaceAction.Replace;


It is nice to hear from you that you have found the solution of your query. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.