Trabajando con Marca de Agua
Agregar Marca de Agua en un DWG
A veces, deseas agregar algunas marcas de agua a los dibujos para indicar cuál es el propósito de los dibujos o quién los creó. Aspose.CAD para .NET te permite agregar una marca de agua en un archivo DWG. Esto se puede hacer creando una entidad de Texto o MTexto con una altura de texto específica, rotación, estilo, ajustes y demás que también deben ser ajustados para dar un buen aspecto. Para esto, la API proporciona CadMText y CadText clases.
Código de Ejemplo
El código a continuación muestra cómo lograr el mismo objetivo utilizando Aspose.CAD para .NET
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
using(CadImage cadImage = (CadImage)Image.Load(MyDir + "Drawing11.dwg")) { | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.Text = "Watermark message"; | |
watermark.InitialTextHeight = 40; | |
watermark.InsertionPoint = new Cad3DPoint(300, 40); | |
watermark.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(watermark); | |
// or add more simple entity like Text | |
CadText text = new CadText(); | |
text.DefaultValue = "Watermark text"; | |
text.TextHeight = 40; | |
text.FirstAlignment = new Cad3DPoint(300, 40); | |
text.LayerName = "0"; | |
cadImage.BlockEntities["*Model_Space"].AddEntity(text); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
rasterizationOptions.Layouts = new[] { "Model" }; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir + "AddWatermark_out.pdf", pdfOptions); | |
} | |