Fähigkeit, Text auf DWF-Bildern zu überlagern und anzupassen, wodurch eine gewisse Bearbeitung des resultierenden Renderausgangs ermöglicht wird

Wie man die Fähigkeit hat, Text auf DWF-Bildern zu überlagern und anzupassen

Problem: Wie man die Fähigkeit hat, Text auf DWF-Bildern zu überlagern und anzupassen.

Tipps: Um dies zu tun, müssen Sie ein DwfWhipText erstellen, die notwendigen Parameter festlegen und es mit der Methode AddElement zur Zeichnung hinzufügen. Um es zu entfernen, können Sie die Methode RemoveElement verwenden.

Beispiel:

using var dwimg = (DwfImage)Image.Load(file);
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.DrawType = CadDrawTypeMode.UseObjectColor;
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.VectorRasterizationOptions = rasterizationOptions;
DwfWhipText text = new DwfWhipText();
text.Color = Color.Red;
text.Text = new CAD.FileFormats.Dwf.Whip.Objects.DwfString("THIS IS A TEST TEXT");
text.Position = new CAD.FileFormats.Dwf.Whip.Objects.DwfWhipLogicalPoint(40000, 70000);
text.Font = new CAD.FileFormats.Dwf.Whip.Objects.Service.DwfWhipFont();
text.Font.Name = new CAD.FileFormats.Dwf.Whip.Objects.Service.Font.DwfWhipOptionFontName();
text.Font.Name.Value = new CAD.FileFormats.Dwf.Whip.Objects.DwfString("times new roman");
text.Font.Height = new CAD.FileFormats.Dwf.Whip.Objects.Service.Font.DwfWhipOptionFontHeight();
text.Font.Height.Value = 2000;
text.IsVisible = true;
dwimg.AddElement(0, text);
image.Save(outFileAdded, pdfOptions);
dwimg.RemoveElement(0, count);
image.Save(outFileAdded, pdfOptions);