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

Free Support Forum - aspose.com

Linq reporting doc template uri

hello
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.

@miniseb31

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);
    builder.MoveTo(e.MatchNode);
    string docTag = string.Format("<<doc [\"{0}/", this.relativePath);
    builder.Write(docTag);
    return ReplaceAction.Replace;
  }
}

@miniseb31

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.