איורים DXF
ייצוא איורי DXF ל-PDF
Aspose.CAD מספקת את האפשרות לטעון ישויות איור DXF של AutoCAD ולהציג את כולן בפורמט PDF. גישת המרה מ-DXF ל-PDF מתבצעת כך:
- טען קובץ איור DXF באמצעות המתודת Image.Load.
- צור אובייקט של מחלקת CadRasterizationOptions וקבע את המאפיינים PageHeight & PageWidth.
- צור אובייקט של מחלקת PdfOptions וקבע את מאפיין ה-VectorRasterizationOptions.
- קרא ל-Image.Save תוך העברת אובייקט של PdfOptions כעוד פרמטר.
דוגמת הקוד למטה מראה כיצד להמיר קובץ באמצעות הגדרות ברירת מחדל.
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.BackgroundColor = Aspose.CAD.Color.White; | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
// Create an instance of PdfOptions | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "conic_pyramid_out.pdf"; | |
//Export the DXF to PDF | |
image.Save(MyDir, pdfOptions); | |
} |
פורמטים נתמכים
נכון לעכשיו אנו תומכים במלואם בפורמטי קבצים DXF 2010 של AutoCAD. לא מובטחת תקValidity של גרסאות DXF הקודמות. אנו מתכננים לכלול פורמטים נוספים ופיצ’רים בגרסאות עתידיות של Aspose.CAD.
ישויות נתמכות
נכון לעכשיו אנו תומכים בכל הישויות 2D הנפוצות ובפרמטרים ברירת המחדל הבסיסיים שלהם כדלקמן:
- ממד מיושר
- ממד זוויתי
- קשת
- מאפיין
- הפניה לחסימה
- עיגול
- ממד קוטר
- אליפסה
- הדגשה
- קו
- טקסט מרובה שורות
- ממד סדרתי
- נקודה
- פוליליין
- ממד רדיאלי
- קרן
- ממד מסובב
- טבלה
- טקסט
- קו X
ניהול זיכרון
המאפיין ExactReallocateOnly של מחלקת Cache יכול לשמש לשליטה על שידור מחדש של זיכרון. שידור מחדש הוא בגדר הסבירות שיתקיים עבור מטמונות שהוקצו מראש. זה יכול לקרות כאשר המערכת מגלה שהמרחב שהוקצה לא יהיה מספיק.
- אם ExactReallocateOnly מוגדר לערך ברירת המחדל, False, המרחב יוקצה מחדש לאותו מדיה.
- כאשר זה מוגדר ל-True, השידור מחדש לא יכול לעלות על המרחב המקסימלי המוגדר. במקרה זה, המטמון המוקצה בזיכרון הקיים (המצריך שידור מחדש) מתפנה ומרחב נוסף מוקצה בדיסק.
ייצוא שכבת DXF ספציפית ל-PDF
גישת זו מתבצעת כך:
- פתח קובץ איור DXF באמצעות המתודת Image.Load.
- צור מופע של CadRasterizationOptions וקבע את המאפיינים PageWidth & PageHeight.
- הוסף שכבות לאובייקט של CadRasterizationOptions.
- צור מופע של PdfOptions וקבע את המאפיין VectorRasterizationOptions.
- קרא למתודת Image.Save ועבר את האובייקט של PdfOptions כעוד פרמטר.
דוגמת הקוד למטה מראה כיצד להמיר שכבת DXF ספציפית ל-PDF.
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
// Add desired layers | |
rasterizationOptions.Layers = new string[] { "LayerA" }; | |
// Create an instance of PdfOptions | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "conic_pyramid_layer_out.pdf"; | |
//Export the DXF to PDF | |
image.Save(MyDir, pdfOptions); | |
} |
Render PDF files as a part of DXF drawings
גישת זו מתבצעת כך:
- טען קובץ איור DXF באמצעות המתודת Image.Load.
- צור אובייקט של מחלקת CadRasterizationOptions וטען קבצי PDF.
- קבע את המאפיינים PageHeight & PageWidth.
- קרא Image.Save ושמור את הקובץ.
דוגמת הקוד למטה מראה כיצד להציג קבצי PDF כחלק מאיורי DXF.
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
// Specify desired layout name | |
rasterizationOptions.Layouts = new string[] { "Model" }; | |
// Create an instance of PdfOptions | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "conic_pyramid_layout_out.pdf"; | |
//Export the DXF to PDF | |
image.Save(MyDir, pdfOptions); | |
} |
Export embedded DGN underlay for DXF format
Aspose.CAD מספקת את הפיצ’ר לטעון קובצי DXF של AutoCAD ולייצא את ה-DGN המשולב עבור פורמט DXF.
דוגמת הקוד למטה מראה כיצד להשיג דרישות ספציפיות.
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.Layouts = new[] { "Model" }; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir + "conic_pyramid.pdf", pdfOptions); | |
} |
Support for Saving DXF Files
Aspose.CAD מספקת את האפשרות לטעון קובצי DXF של AutoCAD ולבצע שינויים בהם ולשמור אותם שוב כקובץ DXF.
דוגמת הקוד למטה מראה כיצד להשיג דרישות ספציפיות.
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
// any entities updates | |
cadImage.Save(MyDir+"conic.dxf"); | |
} | |
Export DXF to WMF
גישת זו מתבצעת כך:
- טען קובץ איור DXF באמצעות המתודת Image.Load.
- צור אובייקט של מחלקת CadRasterizationOptions וטען קבצי PDF.
- קבע את המאפיינים PageHeight & PageWidth.
- קרא Image.Save ושמור את הקובץ.
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (var image = Image.Load("NRB-GRID-BLOCK-MD-PROVALVDK-241000-162000-45400.dgn")) | |
{ | |
var vectorOptions = new CadRasterizationOptions(); | |
vectorOptions.AutomaticLayoutsScaling = true; | |
vectorOptions.BackgroundColor = Color.Black; | |
vectorOptions.PageWidth = 500; | |
vectorOptions.PageHeight = 500; | |
WmfOptions wmfOptions = new WmfOptions() | |
{ | |
VectorRasterizationOptions = vectorOptions | |
}; | |
image.Save("NRB-GRID-BLOCK-MD-PROVALVDK-241000-162000-45400.dgn.wmf", wmfOptions); | |
} |
Exporting Specific DXF Layout to PDF
גישת זו מתבצעת כך:
- פתח קובץ איור DXF באמצעות המתודת Image.Load.
- צור מופע של CadRasterizationOptions וקבע את המאפיינים PageWidth & PageHeight.
- ציין את השמות הרצויים של הליירים באמצעות המאפיין CadRasterizationOptions.Layouts.
- צור מופע של PdfOptions וקבע את המאפיין VectorRasterizationOptions.
- ייצא את האיור ל-PDF על ידי קריאה למתודת Image.Save ועבר את האובייקט של PdfOptions כעוד פרמטר.
דוגמת הקוד למטה מראה כיצד להמיר שכבה ספציפית של DXF ל-PDF.
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
// Specify desired layout name | |
rasterizationOptions.Layouts = new string[] { "Model" }; | |
// Create an instance of PdfOptions | |
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "conic_pyramid_layout_out.pdf"; | |
//Export the DXF to PDF | |
image.Save(MyDir, pdfOptions); | |
} |
Support of Block Clipping
Aspose.CAD מספקת את האפשרות של חיתוך בלוקים. גישת חיתוך בלוקים עובדת כך:
- טען קובץ איור DXF באמצעות המתודת Image.Load.
- צור אובייקט של מחלקת CadRasterizationOptions וטען קבצי PDF.
- קבע את המאפיינים הרצויים של CadRasterizationOptions.
- קרא ל-Image.Save בעת העברת אובייקט של PdfOptions כעוד פרמטר ושמור את הקובץ.
דוגמת הקוד למטה מראה כיצד חיתוך בלוקים עובד.
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET | |
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string inputFile = MyDir + "SLS-CW-CD-CE001-R01_blockClip.dxf"; | |
string outputFile = MyDir + "SLS-CW-CD-CE001-R01_blockClip.pdf"; | |
using (CadImage cadImage = (CadImage)Image.Load(inputFile)) | |
{ | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions | |
{ | |
BackgroundColor = Aspose.CAD.Color.White, | |
DrawType = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseObjectColor, | |
PageWidth = 1200, | |
PageHeight = 1600, | |
Margins = new Margins | |
{ | |
Top = 5, | |
Right = 30, | |
Bottom = 5, | |
Left = 30 | |
}, | |
Layouts = new string[] { "Model" } | |
}; | |
PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions | |
{ | |
VectorRasterizationOptions = rasterizationOptions | |
}; | |
cadImage.Save(outputFile, pdfOptions); |
ייצוא תמונות ל-DXF
באמצעות Aspose.CAD, אתה יכול לייצא תמונות לפורמט DXF. באמצעות גישה זו, תוכל לבצע את הפעולות הבאות:
- קבע גופן חדש
- הסתר ישויות
- עדכן טקסט
דוגמת הקוד הבאה מראה לך כיצד לבצע את הפעולות המפורטות לעיל.
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
foreach (var file in new DirectoryInfo(MyDir).EnumerateFiles("*.dxf")) | |
{ | |
// **************************** | |
// Set new font per document | |
// **************************** | |
using (var cadImage = (CadImage)Image.Load(file.FullName)) | |
{ | |
// Iterate over the items of CadStyleTableObject | |
foreach (CadStyleTableObject style in cadImage.Styles) | |
{ | |
// Set font name | |
style.PrimaryFontName = "Broadway"; | |
} | |
cadImage.Save(file.FullName + "_font.dxf"); | |
} | |
// **************************** | |
// Hide all "straight" lines | |
// **************************** | |
using (var cadImage = (CadImage)Image.Load(file.FullName)) | |
{ | |
foreach (var entity in cadImage.Entities) | |
{ | |
// Make lines invisible | |
if (entity.TypeName == CadEntityTypeName.LINE) | |
{ | |
entity.Visible = 0; | |
} | |
} | |
cadImage.Save(file.FullName + "_lines.dxf"); | |
} | |
// **************************** | |
// Manipulations with text | |
// **************************** | |
using (var cadImage = (CadImage)Image.Load(file.FullName)) | |
{ | |
foreach (var entity in cadImage.Entities) | |
{ | |
if (entity.TypeName == CadEntityTypeName.TEXT) | |
{ | |
((CadText)entity).DefaultValue = "New text here!!! :)"; | |
break; | |
} | |
} | |
cadImage.Save(file.FullName + "_text.dxf"); | |
} | |
} | |
ייצוא שכבת DXF ספציפית לתמונה
גישת זו מתבצעת כך:
- פתח קובץ איור DXF באמצעות המתודת Image.Load.
- צור מופע של CadRasterizationOptions וקבע את המאפיינים PageWidth וה-PageHeight.
- הוסף שכבות לאובייקט של CadRasterizationOptions.
- צור מופע של JpegOptions וקבע את המאפיין VectorRasterizationOptions.
- ייצא את האיור ל-PDF באמצעות המתודת Image.Save.
דוגמת הקוד למטה מראה כיצד להמיר שכבה ספציפית של DXF לתמונה.
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "for_layers_test.dwf"; | |
using (var image = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions | |
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
// Set image width & height | |
rasterizationOptions.PageWidth = 500; | |
rasterizationOptions.PageHeight = 500; | |
// Set the drawing to render at the center of image | |
// rasterizationOptions.CenterDrawing = true; | |
// Get the layers in an instance of CadLayersDictionary | |
var layersList = image.Layers; | |
// Iterate over the layers | |
foreach (var layerName in layersList.GetLayersNames()) | |
{ | |
// Display layer name for tracking | |
Console.WriteLine("Start with " + layerName); | |
// Add the layer name to the CadRasterizationOptions's layer list | |
rasterizationOptions.Layers = new string[] { "LayerA" }; | |
// Create an instance of JpegOptions (or any ImageOptions for raster formats) | |
var options = new Aspose.CAD.ImageOptions.JpegOptions(); | |
// Set VectorRasterizationOptions property to the instance of CadRasterizationOptions | |
options.VectorRasterizationOptions = rasterizationOptions; | |
//Export each layer to Jpeg format | |
image.Save(layerName + "_out.jpg", options); | |
} | |
} |