Adding reference of doc file within doc


#1

Hi Team,

I am trying to use doc tag to add a link of another document into my existing document but unable to pass the parameter within the inner doc which is referenced from main document. It just print the parameter as text format.

Is there any way we can pass parameter for the the inner document which is referenced from main document ?

I am using .net platform and GroupDocs.Assembly.18.5.0 with .net framework 4.0

Regards,
Harindra


#2

@HarindraShivam,

Thanks for using GroupDocs.Assembly for .NET API.

You can insert the contents of another document into your existing document using doc tags. A doc tag denotes a placeholder within a template for a document to be inserted during run-time. For details, syntax and code snippet please see this documentation.

In case you would have any questions or queries, please feel free to let us know.


#3

@ali.ahmed

Yes in case when the Inserted document has all text it’s fine and works perfectly. But when inserted document has any variable for which value need to be inserted at run time that don’t occur, instead variable name (customer.customername) is printed in document as a text from the document that was inserted during run time…

So my question is does GroupDocs.Assembly support this so that we can have dynamic variable in the document that need to be inserted during run time ? Or we can have this dynamic variable only in the main template and not in the document that is referenced within that template.

Regards,
Harindra


#4

@HarindraShivam,

Thanks for coming back and sharing your views.

You can achieve your mentioned scenario in two steps. First, you can evaluate the tags in the document that need to be inserted. At the second step, insert the output document into your main template.

Following is the code snippet to implement your scenario:


//Setting up source document template
const String strDocumentTemplate = "D:\\Files\\Source Document.docx";
//Setting up Output document to be used for document insertion
const String strDocumentOutput = "D:\\Files\\Source Document Output.docx";
//Setting up outer document template
const String strOuterDocumentTemplate = "D:\\Files\\Outer Document.docx";
//Setting up outer document report
const String strOuterDocumentOutput = "D:\\Files\\Outer Document Report.docx";
try
{
  //Instantiate DocumentAssembler class
  DocumentAssembler assembler = new DocumentAssembler();

  string name = "Ali Ahmed";
  //Assemble Source Document
  assembler.AssembleDocument(strDocumentTemplate,strDocumentOutput, name, "name");
  //Assemble Master Document
  assembler.AssembleDocument(strOuterDocumentTemplate, strOuterDocumentOutput, strDocumentOutput, "document");
}
catch (Exception ex)
{
  Console.WriteLine(ex.Message);
}

In case you would have any questions or queries, please feel free to let us know.