Ability to superimpose and adjust text on DWF images, thus allowing some degree of editing the resulting render output
Contents
[
Hide
]How to ability to superimpose and adjust text on DWF images
Issue: How to ability to superimpose and adjust text on DWF images.
Tips: To do this, you need to create a DwfWhipText, set the necessary parameters to it and add it to the drawing using the AddElement method, or to remove it, you can use the RemoveElement method
Example:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |