Images
TX Text Control is especially powerful for importing images into word processing documents and supports a wide range of image file formats. There are basically three different approaches to image import: Inserted at character position, fixed position and anchored to a paragraph. TX Text Control also supports various text flow options around images.
This demo uses the MVC version of TXTextControl.Web included in TX Text Control .NET Server for ASP.NET. The functionality is compatible across all supported platforms.
Version 32.0 SP4
Sample Source Code
<!-- Create TextControl and load document --> | |
<div class="tx-container"> | |
@Html.TXTextControl().TextControl(settings => | |
{ | |
settings.Dock = DockStyle.Fill; | |
}).LoadText(Server.MapPath("~/App_Data/Documents/editing_images.tx"), | |
StreamType.InternalUnicodeFormat).Render() | |
</div> | |
... | |
<!-- Input for a local image --> | |
<input type="file" ... accept=".gif,.png,.jpg,.jpeg,.bmp,*" onchange="LoadLocalImage(this.files)"> |
No code required.
TXTextControl.addEventListener("ribbonTabsLoaded", function () { | |
TXTextControl.ribbon.selectedTab = "tabInsert"; | |
}); | |
function LoadLocalImage(files) { | |
var file = files; | |
if (!file) return; | |
var reader = new FileReader(); | |
reader.onload = function () { | |
// Convert data to Base64 | |
var base64 = btoa(reader.result); | |
// Load image data in TextControl | |
TXTextControl.images.addInline(base64, -1, function () { }, function (errArgs) { | |
// Show error message in a custom way. | |
$('.alert-danger').text(errArgs.error.message).show().delay(5000).fadeOut(); | |
errArgs.handled = true; | |
}); | |
}; | |
reader.readAsBinaryString(files[0]); | |
} |
No code required.
© 2025 Copyright Text Control GmbH and Text Control, LLC. All rights reserved. We ♥ documents.