Steps to create LINQ image tags in MS Word Docs

Hi,

Q: What are the steps to create an image tag for LINQ replacement in MS Word?

I’ve been copying/editing from the samples on GitHub (eg. SingleRow.doc), but I want to know how to create the tag from within Word.

I’m using the most recent version of Word for Mac 2019 (v16.23). The sample documents open in “compatibility mode”, so I’m recreating my LINQ docs from scratch. I’m chasing an odd parsing problem, so hopefully knowing how to create image tags will either resolve or highlight the issue.

Thanks in advance,
Erik

@ewestland

Thanks for your inquiry. The LINQ Reporting syntax is simple plain text that you need to write in Word document. Please read the following articles.
Template Syntax
Inserting Images Dynamically

You do not need to create document from scratch. Could you please share some detail about your issue that you are facing while using Aspose.Words? We will then provide you more information about your query.

Tahir,

In most (all other?) cases LINQ tags are “simple plain text”, but not the image tag.

Simply adding a simple text tag for “image” results in an error.
<<image [manager.getPhoto()]>>

The result is:

Exception in thread "main" java.lang.IllegalStateException: **Tag 'image' is not well-formed. Tag 'image' must be located within an image container.**
	at com.aspose.words.internal.zzOI.zzZ(Unknown Source)
	at com.aspose.words.internal.zzCR.zzZ(Unknown Source)
	at com.aspose.words.ReportingEngine.buildReport(Unknown Source)
	at com.aspose.words.ReportingEngine.buildReport(Unknown Source)
	at com.aspose.words.examples.linq.SingleRow.main(SingleRow.java:22)

Rather than opening your doc and copying an image container to my doc, I’d like the minimal steps to create the tag from scratch in Word.

I’ve attached a SingleRow.doc.zip (3.5 KB)
modified SingleDoc.doc from your sample on GitHub (eg. SingleRow.doc ),

Thanks,
Erik

P.S. As an added bonus, it would be helpful to know how to programmatically create the “image” LINQ tag using the Word and Cells APIs. I’m creating reusable template documents and the formatting is very difficult to control. If I can create programmatically, I should be able to twiddle the bits necessary to get the formatting as desired.

In looking closer at the wording of Inserting Images Dynamically, the existence of a “textbox” container is mentioned.

"While building a report, the following procedure is applied to an image tag:

  1. The expression declared within the tag is evaluated and its result is used to form an image.
  2. The corresponding textbox is filled with this image.
  3. The tag is removed from the textbox."

In the latest version of word (16.23), I’ve attached two ways to create the container (aka “textbox”) for the image tag. It would be helpful to clarify this in the documentation. It would also be helpful to mention the joys of anchoring.

Also, it looks like this is how you’d create the TextBox from the:

I haven’t tried creating the LINQ image tags using the APIs yet, but I’ll give it a shot.

Thanks,
Erik

Create_TextBox_from_Insert_menu_ribbon.png (6.9 KB)
Create_TextBox_from_Insert_menu.jpg (82.1 KB)

1 Like

@ewestland

Thanks for your inquiry. We have tested the scenario using the code example from Aspose.Words for Java example repository at Github. We have not faced any exception. It seems that you modified the document using Word for MAC. Could you please share the document that you are using at your end?