Good day.
We are importing sections of one document into another. As we do this, we set style and font properties to match the destination document styles.
We noticed a problem in which some text was coming over incorrectly from the source document. I think I’ve narrowed it down to a specific issue.
Please see the attached document. This is a portion the “source” document. You can see that all the text has a Tahoma 8.5 font applied if viewed in MS Word 2010.
When we import, we iterate through the paragraphs, and within each paragraph, each Run.
The following is the toTxt() of the paragraph node. Below it is the ParagraphFormat and font information for this paragraph as extracted via Aspose:
<div style="margin-left:30px;color:#909090">
<font size="2">
With the majority of the mission critical business systems
currently being hosted in Timbuktu, maximum business network latency has
been defined as being from each remote site to the Timbuktu co-loc
computer center. RFP Spreadsheet D provides the max latency by site. For
providers proposing a global speed solution, committed business system
latencies should be from each site to the Timbuktu co-lo compute center.
For providers proposing a regional solution, the cross connects will be
done at the regional co-loc computer centers so latency commitments
should be from the site to the co-lo compute center where the cross
connect will be performed in the other region. Engineering latency
commitments should be defined as being from the engineering site to the
in-region compute ranch.
</font>
</div><font size="2">
Style: Body Text,
Line spacing: 12,
Line spacing rule: 2,
<font color="#FF0000">
Font name: Times New Roman,
Font size: 10
</font>
</font>
</blockquote>We are using the following ColdFusion code to extract those values:
<blockquote>
<font face="Courier New" size="1">
Style: #currNode.getParagraphFormat().getStyleName()#,
Line spacing: #currNode.getParagraphFormat().getLineSpacing()#,
</font><font face="Courier New" size="1">
</font><font face="Courier New" size="1">
Line spacing rule: #currNode.getParagraphFormat().getLineSpacingRule()#,
</font><font face="Courier New" size="1">
</font><font face="Courier New" size="1">
Font name: #currNode.getParagraphFormat().getStyle().getFont().getName()#,
</font><font face="Courier New" size="1">
</font><font face="Courier New" size="1">
ont size: #currNode.getParagraphFormat().getStyle().getFont().getSize()#
</font>
</blockquote>So, it reads the correct style name ("Body Text"), but it shows an incorrect font face and size (Times New Roman). So far, not an issue, as some of the runs could override the paragraph style.
But f we iterate through the runs within this node, and show the font face and size of each run, it still seems to be incorrect:
<ul>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
With the majority of the mission critical business systems currently being hosted in
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
Timbuktu
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
, maximum business network latency has been defined as being from each remote site to the
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
Timbuktu
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
co-
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
loc
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
computer
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
center
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
. RFP
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
Spreadsheet
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
D provides the max latency by site. For providers proposing a global
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
speed
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
solution, committed business system latencies should be from each site to the
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
Timbuktu
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
co-lo compute
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
center
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
. For providers proposing a regional solution, the cross connects will be done at the regional co-
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
loc
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
computer
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
centers
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
so latency commitments should be from the site to the co-lo compute
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
center
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
where the cross connect will be performed in the other region. Engineering laten
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
<li>
<div style="margin-left:30px;color:#909090">
<font size="2">
cy commitments should be defined as being from the engineering site to the in-region compute ranch.
</font>
</div><font size="2">
Font name: Times New Roman,
Font size: 8.5
</font>
</li>
</ul>
That was generated with the following code:
<cfset runs=currNode.getRuns()>
<cfset ri=runs.iterator()>
Made up of: <br />
<ul>
<cfloop condition="#ri.hasNext()#">
<cfset run=ri.next()>
<li>
<div style="margin-left:30px;color:##909090">
#run.getText()#
</div>
Font name: #run.getFont().getName()#,
Font size: #run.getFont().getSize()#
</li>
</cfloop>
</ul>
So it seems no matter how I extract the font properties, Aspose properties indicate Times New Roman, while the real font is something else.
I think the reason that the style properties shown in Aspose do not match the properties shown in Word, is that the Body Text style is a linked style. At least, in my much larger document, I am not able to properly convert any text that uses a linked style in the source document.
Am I misunderstanding linked styles and how Aspose is reading the font face and size? Is there a way to extract the actual font/formatting information for the text that has a linked style? In the end, I am trying to set the fonts as well, but I think if I solve the former issue the latter may fall into place.
Thank you.