word in the test.docx set the text attribute “Shadow”, but run.Font.Shadow property value is false using of aspose.word version number 22.4, I wonder whether the Font.Shadow can corresponds to the text attribute of the “Shadow”, if not, which is the correct attribute of the “Shadow”.
test.docx (22.2 KB)
The Font.Shadow
property in Aspose.Words is designed to reflect the shadow effect applied to text. However, it appears that there may be some discrepancies between the text attributes set in your document and the values returned by the Font.Shadow
property.
Currently, the Aspose.Words API has a logged issue (WORDSNET-20812) regarding the exposure of an API to work with font shadow effects. This indicates that the functionality you are looking for may not be fully implemented or may not behave as expected in the version you are using (22.4) [1].
To check if the shadow effect is being applied correctly, you can use the following code snippet to create a document with shadowed text and verify the property:
import com.aspose.words.*;
public class ShadowTextExample {
public static void main(String[] args) throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Set the shadow property to true
builder.getFont().setShadow(true);
builder.getFont().setSize(36);
builder.writeln("This text has a shadow.");
doc.save("ShadowText.docx");
// Load the document to check the shadow property
doc = new Document("ShadowText.docx");
Run run = doc.getFirstSection().getBody().getParagraphs().get(0).getRuns().get(0);
// Verify the shadow property
System.out.println("Shadow property: " + run.getFont().getShadow());
}
}
This code creates a document with a shadow effect and then checks the Font.Shadow
property to see if it returns true
. If it does not, it may indicate that the shadow effect is not being recognized correctly in your version of the library.
If you continue to experience issues, consider checking for updates or patches in newer versions of Aspose.Words, as the issue may have been addressed in subsequent releases.
Sources:
[1]: Format Text Font in Word DOCX Document with Shadow Effects using C# .NET or Java
@Melancholy In your documents the runs have DML shadow effect applied. You can use Font.HasDmlEffect method to check whether the effect is applied:
Document doc = new Document(@"C:\Temp\in.docx");
Run r = (Run)doc.FirstSection.Body.FirstParagraph.FirstChild;
Console.WriteLine(r.Font.HasDmlEffect(TextDmlEffect.Shadow));