When adding a text annotation with hebrew text on a PDF, on the output document the text is reversed, left to right instead of right to left.
You can see in the picture bellow, displayed in Adobe Reader, the text in the red box should be the same as the text just above. However, in the shortcut in the right panel, the text is correct. Screenshot 2025-12-08 170921.png (4.4 KB)
If I resize the annotation box just a little, Adobe Redraw the text in the correct orientation. Screenshot 2025-12-08 171015.png (3.5 KB)
My guess is Aspose ignores the RTL specificity of hebrew on the creation of the annotation when generating the default appearance. Adobe recreate this appearance on resize in the correct orientation.
The text is being rendered from the annotation’s default‑appearance stream that Aspose.PDF generates. At the moment the library does not apply the Unicode Bidi algorithm when building that stream, so RTL scripts (Hebrew, Arabic, etc.) are drawn left‑to‑right. Adobe Reader re‑creates the appearance on a resize, which is why the text looks correct after you adjust the box.
What we need to investigate further
Aspose.PDF for .NET version you are using (including the exact build number).
The code snippet you use to create the TextAnnotation (including font selection).
Whether you are setting a custom appearance (Annotation.Appearance) or relying on the default one.
Suggested immediate checks
Upgrade to the latest Aspose.PDF for .NET release (if you are not already on it). Some RTL handling improvements were added in recent builds.
Try setting a custom appearance for the annotation, e.g.:
TextAnnotation annot = new TextAnnotation(page, new Rectangle(100, 500, 300, 550));
annot.Contents = "שלום עולם"; // Hebrew text
annot.Font = FontRepository.FindFont("Arial Unicode MS"); // or any Hebrew‑capable TTF
// Build a FormXObject with the correct Bidi order yourself
FormXObject appearance = new FormXObject(annot.Rect);
appearance.Canvas.BeginText();
appearance.Canvas.SetFontAndSize(annot.Font, 12);
appearance.Canvas.ShowText(annot.Contents); // use a library that respects RTL, e.g., System.Drawing
appearance.Canvas.EndText();
annot.Appearance = appearance;
If the custom appearance displays correctly, it confirms the issue is limited to the automatically generated default appearance.
Next step
Please reply with the version number, a minimal reproducible code sample, and the font you are using. With that information we can reproduce the problem and log a defect for the RTL handling in annotation appearance.
FormXObject is a class from Aspose.PDF for .NET (namespace Aspose.Pdf).
It represents a PDF form XObject – a reusable content stream that can be drawn anywhere in the document.
When you write
FormXObject appearance = new FormXObject(annot.Rect);
you are creating a new, empty form XObject whose media box is the same rectangle as the annotation (annot.Rect).
The object is completely under your control:
Create the XObject – the constructor takes the rectangle that will define the XObject’s size.
Draw into it – obtain its Canvas (appearance.Canvas) and use the usual drawing methods (BeginText, SetFontAndSize, ShowText, EndText, etc.).
Assign it to the annotation – set annot.Appearance = appearance; (or annot.NormalAppearance = appearance; for a specific state).
So the FormXObject does not come from the PDF file or from Aspose automatically; you instantiate it yourself to build a custom appearance stream for the annotation. This is the recommended way to render RTL text correctly, because you can control the text layout (e.g., apply a Bidi algorithm or use a font that supports Hebrew) before assigning the appearance to the annotation.
If you need a minimal example:
// assume 'page' is a Page object and 'annot' is a TextAnnotation
FormXObject appearance = new FormXObject(annot.Rect);
var canvas = appearance.Canvas;
canvas.BeginText();
canvas.SetFontAndSize(FontRepository.FindFont("Arial Unicode MS"), 12);
canvas.ShowText(annot.Contents); // Hebrew string – you may reorder characters here
canvas.EndText();
annot.Appearance = appearance; // replace default appearance
Make sure you are using a recent Aspose.PDF for .NET version, as later releases contain bug‑fixes for RTL handling. If the custom appearance renders correctly while the default one does not, it confirms that the issue lies in the library‑generated default appearance stream.
I am using the last Aspose.PDF repository and there is no FormXObject in the Aspose.PDF namespace.
The sample code provided does not look like the way Aspose works with XForm and Appearance.
I find nothing called “Canvas” in aspose PDF either.
We apologize for the confusion caused by the AI response. Please feel free to disregard it.
Would you kindly provide the sample code snippet that you have been using to add the text annotation? We will test the scenario in our environment and address it accordingly.