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

Free Support Forum - aspose.com

Update on Printing and IF fields


Please could you give me an update on two pieces of functionality?

  1. IF fields. I am working to convert a Word Automation application to Aspose.Words. One of the things the current application does, is to conditionally display a "voucher". This is just a block of formatted text within the document that is displayed only if a speciifc flag is set within the mailmerge data. The conditional part uses an IF field. Please can you tell me when this functionality is scheduled to be available in Aspose.Words. Could you also suggest a workaround, bearing in mind that my current application has been designed to allow business staff to manage the Word templates themselves, and so I do not really want to have to recode the application, or work with embedded sub-documents (as that will be complex for the business users to understand)
  2. Printing. I believe the printing capability is still in Alpha test, and has quite a few issues. Please can you tell me when this is scheduled to be released as a core part of the Aspose.Words system

Many thanks


<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry.

1. At the moment Aspose.Words does not evaluate IF fields. Calculation of all fields (including TOC and IF) - current estimate is sometime in 2008. But it is not very reliable. As workaround you can move your conditional logic into your SQL query or into MargeField event handler.

2. Rendering/Printing feature is still in beta. Unfortunately I cant provide you any reliable estimate date.

Best regards.

Hi Alexey,

Thanks for your quick updates. Could I ask another final question re the IF fields? I have been playing around with GetChildNodes(Aspose.Words.NodeType.FieldStart,True) method, and believe I might be able to use this to "read" the IF statement into my application, and then conduct the condition logic within the code. This means that within the code, if the application is configured to use Microsoft Word (with Word Automation, as has historically been used), Word can handle the IF clause. If, however, the application has been configured to use Aspose.Words, the application can detect the IF fields, perform the conditional logic in the code, and do what is necessary.

The templates currently display additional text if the IF condition is met, and display nothing at all if the IF condition is not met. So, I'm hoping that I can simply lift the formatted text out of the true condition of the IF clause, and replace the entire IF statement with that text. If the IF condition returns FALSE, then I can delete the entire IF statement.

Do you think this would be possible, and would you be able to provide some example code that I can tailor to meet my needs? Fields within Word seem very easy to manipulate, but within Aspose.Words I am quite confused about the number of Run elements within each field.

Many Thanks

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Here is code that you can use to get field codes of IF field:

Document doc = new Document(@"Test008\in.doc");

//Get collection of field starts

NodeCollection starts = doc.GetChildNodes(NodeType.FieldStart, true);

//Loop through all field starts

foreach (FieldStart start in starts)


//Check whether current FieldStart is start of IF field

if (start.FieldType == FieldType.FieldIf)


//Field code is represented by content between Field Start and FieldSeparator

string fieldCode = string.Empty;

Node currentNode = start.NextSibling;

while (currentNode.NodeType != NodeType.FieldSeparator)


Run fieldPart = currentNode as Run;

if (fieldPart != null)

fieldCode += fieldPart.Text;

//Move to next node

currentNode = currentNode.NextSibling;

//Break loop if current node is null

if (currentNode == null)



//Here you should evaluate conditional expression.


//And execute your logic.



But any way you should evaluate conditional expression. Maybe the following article could be useful for you:


Hope this helps.

Best regards.