Txt2Resource.AddTextRecord
Txt2Resource.AddTextRecord method
Ajoute l’enregistrement de texte à la ressource et renvoie l’ID de l’enregistrement de texte.
public int AddTextRecord(string text, RectangleF bounds)
Paramètre | Taper | La description |
---|---|---|
text | String | Le texte de l’enregistrement. |
bounds | RectangleF | Les bornes. |
Return_Value
Renvoie l’ID de l’enregistrement de texte pour la ressource
Exceptions
exception | condition |
---|---|
PsdImageException | Version de ressource Txt2 inconnue. |
Exemples
Le code suivant illustre la prise en charge de la prise en charge des nouvelles propriétés ITextStyle.
[C#]
void AssertAreEqual(object expected, object actual)
{
if (!object.Equals(expected, actual))
{
throw new FormatException(
string.Format("Actual value {0} are not equal to expected {1}.", actual, expected));
}
}
string srcFile = "A.psd";
string outputFile = "output.psd";
using (var psdImage = (PsdImage)Image.Load(srcFile))
{
var textLayer = (TextLayer)psdImage.Layers[1];
textLayer.UpdateText("abc");
psdImage.Save(outputFile);
}
// Vérifier les valeurs
using (var srcImage = (PsdImage)Image.Load(srcFile))
{
var srcTextLayer = (TextLayer)srcImage.Layers[1];
var etalonStyle = srcTextLayer.TextData.Items[0].Style;
using (var outImage = (PsdImage)Image.Load(outputFile))
{
var outTextLayer = (TextLayer)outImage.Layers[1];
var resultStyle = outTextLayer.TextData.Items[0].Style;
AssertAreEqual(etalonStyle.AutoLeading, resultStyle.AutoLeading);
AssertAreEqual(etalonStyle.FontIndex, resultStyle.FontIndex);
AssertAreEqual(etalonStyle.Underline, resultStyle.Underline);
AssertAreEqual(etalonStyle.Strikethrough, resultStyle.Strikethrough);
AssertAreEqual(etalonStyle.AutoKerning, resultStyle.AutoKerning);
AssertAreEqual(etalonStyle.StandardLigatures, resultStyle.StandardLigatures);
AssertAreEqual(etalonStyle.DiscretionaryLigatures, resultStyle.DiscretionaryLigatures);
AssertAreEqual(etalonStyle.ContextualAlternates, resultStyle.ContextualAlternates);
AssertAreEqual(etalonStyle.LanguageIndex, resultStyle.LanguageIndex);
AssertAreEqual(etalonStyle.VerticalScale, resultStyle.VerticalScale);
AssertAreEqual(etalonStyle.HorizontalScale, resultStyle.HorizontalScale);
AssertAreEqual(etalonStyle.Fractions, resultStyle.Fractions);
}
}
Voir également
- struct RectangleF
- class Txt2Resource
- espace de noms Aspose.PSD.FileFormats.Psd.Layers.LayerResources
- Assemblée Aspose.PSD