thank you for contacting us.
Currently, in a "Text Document", if you want to add text, you shall use the addBlock function rather than the Import
In WPF, the easier is that you start the Demo sample, and set a breakpoint Line 821 of the MainWindows.xaml.cs: _editor.AddBlock(_lastPointerPosition.X, _lastPointerPosition.Y, blockType, mimeTypes[idx], data);
You can then add text via "right click -> Add -> Add Text". The text block will be added in the "Text Document", with the text you entered.
In the text block, you can then use the insert gesture to add ink and convert it, or erase...
Let us know if this helps.
thanks for the reply. For my specific use case, I'm trying to replace/modify the contents of a Text Block.
I tried exporting the block, changing the text, erasing it and then calling addBlock to add a new Text Block with the modified text at the exact same coordinates, but the editor says that it can't place a block there, probably because the old block is not done erasing?
Indeed you are right, it is not possible to add a block in place of an existing one.
The solution is to remove the previous block, and add the new block (with updated text) instead. You can proceed as we do in the "remove" function, i.e . erase the block:
private void Remove(object sender, RoutedEventArgs e)
var contentBlock = _lastContentSelection as ContentBlock;
if (contentBlock != null)
Let us know if this helps.
That was the first thing I tried before posting here. My code looks like this:
var originalBlock = _lastContentSelection as ContentBlock;
var x = originalBlock.Box.X;
var y = originalBlock.Box.Y;
_editor.AddBlock(x, y , "Text", MimeType.TEXT, modifiedText);
The erasing part works, but I always get an exception on the last line:
add block failed: could not create block at (x, y)
Thank you for your update and your code snippet.
The block Box coordinates correspond to our document model coordinates that are expressed in mm.
But the editor AddBlock works with view coordinate in pixel. (see Editor)
For this reason, you must transform the originalBlock coordinates from model to view coordinates before using them in the addBlock.
Also since you are disposing the original block, you should set the_lastContentSelection to null as well.
var originalBlock = _lastContentSelection as ContentBlock; var transform = _editor.Renderer.GetViewTransform(); var topLeft = transform.Apply(originalBlock.Box.X, originalBlock.Box.Y); var x = topLeft.X; var y = topLeft.Y; _editor.Erase(originalBlock); originalBlock.Dispose(); _lastContentSelection = null; _editor.WaitForIdle(); _editor.AddBlock(x, y , "Text", MimeType.TEXT, modifiedText);
This worked for me, thank you!
I'm trying to import text into a "Text" block, which is inside a "Text Document", but i get an exception from the editor.
Importing Text into a "Text" block that is not inside of a "Text Document" works fine.
The code im using:
block is this snippet is a Text Block which i get from the Children List of the Text Document.
returns only Jiix as a valid import type, but the documentantion says that:
"For parts that can host multiple blocks, such as “Text Document” parts, you need to explicitly specify the target block."
which implies that importing inside a "Text Document" should be possible.
Is there some config I'm missing or am I doing something wrong?
I'm using the latest windows wpf example.