Last active
May 1, 2023 08:02
-
-
Save aspose-com-gists/49c1b75d9a84e149ecf374ece2c2597d to your computer and use it in GitHub Desktop.
Aspose.CAD for Java
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
// load CF2 in an instance of Image via its Load method | |
Image image = Image.load("template.cf2"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export CF2 to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
java// load DGN in an instance of Image via its Load method | |
DgnImage image = (DgnImage) DgnImage.load("template.dgn"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export DGN to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
// load DWF in an instance of Image via its Load method | |
Image image = Image.load("template.dwf"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export DWF to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
// load DWFX in an instance of Image via its Load method | |
Image image = Image.load("template.dwfx"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export DWFX to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
// load DWG in an instance of Image via its Load method | |
Image image = Image.load("template.dwg"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export DWG to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
// load DWT in an instance of Image via its Load method | |
Image image = Image.load("template.dwt"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export DWT to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
// load DXF in an instance of Image via its Load method | |
Image image = Image.load("template.dxf"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export DXF to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
// load FBX in an instance of Image via its Load method | |
Image image = Image.load("template.fbx"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export FBX to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
// load IFC in an instance of Image via its Load method | |
IfcImage image = (IfcImage) IfcImage.load("template.ifc"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export IFC to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
// load IGES in an instance of Image via its Load method | |
IgesImage image = (IgesImage) IgesImage.load("template.iges"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export IGES to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
// load OBJ in an instance of Image via its Load method | |
ObjImage image = (ObjImage) ObjImage.load("template.obj"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export OBJ to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
// load PLT in an instance of Image via its Load method | |
PltImage image = (PltImage) PltImage.load("template.plt"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export PLT to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
// load SVG in an instance of Image via its Load method | |
SvgImage image = (SvgImage) SvgImage.load("template.svg"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export SVG to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
Gist for Aspose.CAD for Java |
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
// Access the setMeteredKey property and pass public and private keys as parameters | |
com.aspose.cad.Metered.setMeteredKey("<valid pablic key>", "<valid private key>"); | |
// Get consumed qantity value before accessing API | |
BigDecimal quantityOld = com.aspose.cad.Metered.getConsumptionQuantity(); | |
System.out.println("Consumption quantity" + quantityOld); | |
// DO PROCESSING | |
//com.aspose.cad.fileformats.cad.CadImage image = | |
// (com.aspose.cad.fileformats.cad.CadImage)com.aspose.cad.Image.load("BlockRefDgn.dwg"); | |
// Get consumed qantity value after accessing API | |
BigDecimal quantity = com.aspose.cad.Metered.getConsumptionQuantity(); | |
System.out.println("Consumption quantity" + quantity()); | |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
// Create an instance of OCR Metered class | |
com.aspose.cad.Metered metered = new com.aspose.cad.Metered(); | |
// Access the setMeteredKey property and pass public and private keys as parameters | |
metered.setMeteredKey("<valid pablic key>", "<valid private key>"); | |
// Get consumed qantity value before accessing API | |
double quantityOld = com.aspose.cad.Metered.getConsumptionQuantity(); | |
System.out.println("Consumption quantity" + quantityOld); | |
// DO PROCESSING | |
//com.aspose.cad.fileformats.cad.CadImage image = | |
// (com.aspose.cad.fileformats.cad.CadImage)com.aspose.cad.Image.load("BlockRefDgn.dwg"); | |
// Get consumed qantity value after accessing API | |
double quantity = com.aspose.cad.Metered.getConsumptionQuantity(); | |
System.out.println("Consumption quantity" + quantity()); |
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
String dataDir = Utils.getDataDir(AdjustingCADDrawingSizeUsingUnitType.class) + "CADConversion/"; | |
// Path to source file | |
String sourceFilePath = dataDir + "sample.dwg"; | |
// Load a CAD drawing in an instance of Image | |
Image image = Image.load(sourceFilePath); | |
// Create an instance of BmpOptions class | |
com.aspose.cad.imageoptions.BmpOptions bmpOptions = new com.aspose.cad.imageoptions.BmpOptions(); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
com.aspose.cad.imageoptions.CadRasterizationOptions cadRasterizationOptions = | |
new com.aspose.cad.imageoptions.CadRasterizationOptions(); | |
bmpOptions.setVectorRasterizationOptions(cadRasterizationOptions); | |
// Set the UnitType property | |
cadRasterizationOptions.setUnitType(com.aspose.cad.imageoptions.UnitType.Centimenter); | |
// Set the layouts property | |
cadRasterizationOptions.setLayouts( new String[] { "Model" } ); | |
// Export layout to BMP format | |
String outPath = sourceFilePath + ".bmp"; | |
image.save(outPath, bmpOptions); |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
// Path to source file | |
String sourceFilePath = "sample.dwg"; | |
// Load a CAD drawing in an instance of Image | |
com.aspose.cad.Image objImage = com.aspose.cad.Image.load("sourceFilePath"); | |
// Create an instance of BmpOptions class | |
com.aspose.cad.imageoptions.BmpOptions bmpOptions = new com.aspose.cad.imageoptions.BmpOptions(); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
com.aspose.cad.imageoptions.CadRasterizationOptions cadRasterizationOptions = | |
new com.aspose.cad.imageoptions.CadRasterizationOptions(); | |
bmpOptions.setVectorRasterizationOptions(cadRasterizationOptions); | |
cadRasterizationOptions.setCenterDrawing(true); | |
// Set the UnitType property | |
cadRasterizationOptions.setUnitType(com.aspose.cad.imageoptions.UnitType.Centimenter); | |
// Set the layouts property | |
cadRasterizationOptions.setLayouts( new String[] { "Model" } ); | |
// Export layout to BMP format | |
String outPath = sourceFilePath + ".bmp"; | |
objImage.save(outPath, bmpOptions); |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
// Path to source file | |
String sourceFilePath = "sample.dwg"; | |
// Load a CAD drawing in an instance of Image | |
com.aspose.cad.Image objImage = com.aspose.cad.Image.load("sourceFilePath"); | |
// Create an instance of BmpOptions class | |
com.aspose.cad.imageoptions.BmpOptions bmpOptions = new com.aspose.cad.imageoptions.BmpOptions(); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
com.aspose.cad.imageoptions.CadRasterizationOptions cadRasterizationOptions = | |
new com.aspose.cad.imageoptions.CadRasterizationOptions(); | |
bmpOptions.setVectorRasterizationOptions(cadRasterizationOptions); | |
cadRasterizationOptions.setCenterDrawing(true); | |
// Set the layouts property | |
cadRasterizationOptions.setLayouts( new String[] { "Model" } ); | |
// Export layout to BMP format | |
String outPath = sourceFilePath + ".bmp"; | |
objImage.save(outPath, bmpOptions); |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(ConvertAllCADLayersToSeparateImages.class) + "CADConversion/"; | |
String srcFile = dataDir + "conic_pyramid.dxf"; | |
// Load a CAD drawing in an instance of CadImage | |
CadImage image = (CadImage) Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
// Set image width & height | |
rasterizationOptions.setPageWidth(500); | |
rasterizationOptions.setPageHeight(500); | |
// Set the drawing to render at the center of image | |
rasterizationOptions.setCenterDrawing(true); | |
// Get the layers in an instance of CadLayersDictionary and iterate over the layers | |
for (CadLayerTable layer : image.getLayers().getValuesTyped()) { | |
// Display layer name for tracking | |
System.out.println("Start with " + layer.getName()); | |
// Add the layer name to the CadRasterizationOptions's layer list | |
rasterizationOptions.getLayers().add(layer.getName()); | |
// Create an instance of JpegOptions (or any ImageOptions for raster formats) | |
JpegOptions options = new JpegOptions(); | |
// Set VectorRasterizationOptions property to the instance of CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// Export each layer to JPEG format | |
image.save(dataDir + layer.getName() + "_out_.jpg", options); | |
} |
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
String srcFile = dataDir + "conic_pyramid.dxf"; | |
// Load a CAD drawing in an instance of CadImage | |
CadImage image = (CadImage) Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
// Set image width & height | |
rasterizationOptions.setPageWidth(500); | |
rasterizationOptions.setPageHeight(500); | |
// Get the layers in an instance of CadLayersDictionary. | |
// Iterate over the layers | |
for (String layer : image.getLayers().getLayersNames()) | |
{ | |
// Display layer name for tracking | |
System.out.println("Start with " +layer); | |
List<String> stringList = Arrays.asList(layer); | |
// Add the layer name to the CadRasterizationOptions's layer list | |
rasterizationOptions.setLayers(stringList); | |
// Create an instance of JpegOptions (or any ImageOptions for raster formats) | |
JpegOptions options = new JpegOptions(); | |
// Set VectorRasterizationOptions property to the instance of CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// Export each layer to JPEG format | |
image.save(dataDir + layer + "_out_.jpg", options); | |
} |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
String dataDir = Utils.getDataDir(ConvertCADDrawingToRasterImageFormat.class) + "CADConversion/"; | |
String srcFile = dataDir + "conic_pyramid.dxf"; | |
Image image = Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
// Set page width & height | |
rasterizationOptions.setPageWidth(1200); | |
rasterizationOptions.setPageHeight(1200); | |
// Create an instance of PngOptions for the resultant image | |
ImageOptionsBase options = new PngOptions(); | |
//Set rasterization options | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// Save resultant image | |
image.save(dataDir + "conic_pyramid_raster_image_out_.png", options); |
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
String srcFile = dataDir + "conic_pyramid.dxf"; | |
Image image = Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
// Set page width & height | |
rasterizationOptions.setPageWidth(1200); | |
rasterizationOptions.setPageHeight(1200); | |
// Create an instance of PngOptions for the resultant image | |
ImageOptionsBase options = new PngOptions(); | |
//Set rasterization options | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// Save resultant image | |
image.save(dataDir + "conic_pyramid_raster_image_out_.png", options); |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(ConvertCADLayerToRasterImageFormat.class) + "CADConversion/"; | |
String srcFile = dataDir + "conic_pyramid.dxf"; | |
// Load a CAD drawing in an instance of Image | |
Image image = Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
// Set image width & height | |
rasterizationOptions.setPageWidth(500); | |
rasterizationOptions.setPageHeight(500); | |
// Set the drawing to render at the center of image | |
rasterizationOptions.setCenterDrawing(true); | |
// Add the layer name to the CadRasterizationOptions's layer list | |
rasterizationOptions.getLayers().add("0"); //Most of the CAD drawings have a layer by name 0, you may specify any name | |
// Create an instance of JpegOptions (or any ImageOptions for raster formats) | |
JpegOptions options = new JpegOptions(); | |
// Set VectorRasterizationOptions property to the instance of CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// Export each layer to JPEG format | |
image.save(dataDir + "CADLayersToRasterImageFormats_out_.jpg", options); |
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
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(ConvertCADLayerToRasterImageFormat.class) + "CADConversion/"; | |
String srcFile = dataDir + "conic_pyramid.dxf"; | |
// Load a CAD drawing in an instance of Image | |
Image image = Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
// Set image width & height | |
rasterizationOptions.setPageWidth(500); | |
rasterizationOptions.setPageHeight(500); | |
List<String> stringList = new ArrayList<>(Arrays.asList("0")); | |
// Add the layer name to the CadRasterizationOptions's layer list | |
rasterizationOptions.setLayers(stringList); | |
// Create an instance of JpegOptions (or any ImageOptions for raster formats) | |
JpegOptions options = new JpegOptions(); | |
// Set VectorRasterizationOptions property to the instance of CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// Export each layer to JPEG format | |
image.save(dataDir + "CADLayersToRasterImageFormats_out_.jpg", options); |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(ConvertCADLayoutToRasterImageFormat.class) + "CADConversion/"; | |
String srcFile = dataDir + "conic_pyramid.dxf"; | |
Image image = Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
// Set page width & height | |
rasterizationOptions.setPageWidth(1200); | |
rasterizationOptions.setPageHeight(1200); | |
// Specify a list of layout names | |
rasterizationOptions.setLayouts(new String[] {"Model", "Layout1"}); | |
// Create an instance of TiffOptions for the resultant image | |
ImageOptionsBase options = new TiffOptions(TiffExpectedFormat.Default); | |
// Set rasterization options | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// Save resultant image | |
image.save(dataDir + "conic_pyramid_layoutstorasterimage_out_.tiff", options); |
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
String srcFile = dataDir + "conic_pyramid.dxf"; | |
Image image = Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
// Set page width & height | |
rasterizationOptions.setPageWidth(1200); | |
rasterizationOptions.setPageHeight(1200); | |
// Specify a list of layout names | |
rasterizationOptions.setLayouts(new String[] {"Model", "Layout1"}); | |
// Create an instance of TiffOptions for the resultant image | |
ImageOptionsBase options = new TiffOptions(TiffExpectedFormat.Default); | |
// Set rasterization options | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// Save resultant image | |
image.save(dataDir + "conic_pyramid_layoutstorasterimage_out_.tiff", options); |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(EnableTrackingForCADRenderingProcess.class) + "CADConversion/"; | |
String srcFile = dataDir + "conic_pyramid.dxf"; | |
Image image = Image.load(srcFile); | |
OutputStream stream = new FileOutputStream(dataDir + "conic_pyramid.pdf"); | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions(); | |
pdfOptions.setVectorRasterizationOptions(cadRasterizationOptions); | |
cadRasterizationOptions.setPageWidth(800); | |
cadRasterizationOptions.setPageHeight(600); | |
image.save(stream, pdfOptions); | |
System.out.println("Tracking enabled successfully for CAD rendering process."); |
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
String srcFile = dataDir + "conic_pyramid.dxf"; | |
Image image = Image.load(srcFile); | |
OutputStream stream = new FileOutputStream(dataDir + "conic_pyramid.pdf"); | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions(); | |
pdfOptions.setVectorRasterizationOptions(cadRasterizationOptions); | |
cadRasterizationOptions.setPageWidth(800); | |
cadRasterizationOptions.setPageHeight(600); | |
image.save(stream, pdfOptions); | |
System.out.println("Tracking enabled successfully for CAD rendering process."); |
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
String dataDir = Utils.getDataDir(IntegrateIGESFormat.class) + "CADConversion/"; | |
String sourceFilePath = dataDir + "figa2.igs"; | |
String outPath = dataDir +"meshes.pdf"; | |
Image igesImage = Image.load(sourceFilePath); | |
PdfOptions pdf = new PdfOptions(); | |
CadRasterizationOptions vectorOptions = new CadRasterizationOptions(); | |
vectorOptions.setPageHeight(1000) ; | |
vectorOptions.setPageWidth(1000); | |
pdf.setVectorRasterizationOptions(vectorOptions); | |
igesImage.save(outPath, pdf); |
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
String dataDir = Utils.getDataDir(ListLayouts.class) + "CADConversion/"; | |
String sourceFilePath = dataDir + "conic_pyramid.dxf"; | |
Image image = Image.load(sourceFilePath); | |
CadImage cadImage = (CadImage)image; | |
CadLayoutDictionary layouts = cadImage.getLayouts(); | |
for (CadLayout layout : layouts.getValues()) | |
{ | |
System.out.println("Layout " +layout.getLayoutName()); | |
} | |
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
String dataDir = Utils.getDataDir(MeshSupport.class) + "CADConversion/"; | |
String sourceFilePath = dataDir +"meshes.dwg"; | |
String outPath = dataDir + "meshes.pdf"; | |
CadImage cadImage = (CadImage)Image.load(sourceFilePath); | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
rasterizationOptions.setLayouts( new String[] { "Model" }); | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
cadImage.save(outPath, pdfOptions); | |
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
String dataDir = Utils.getDataDir(PenSupportInExport.class) + "CADConversion/"; | |
String srcFile = dataDir + "conic_pyramid.dxf"; | |
CadImage cadImage = ((CadImage)(Image.load(srcFile))); | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(cadImage.getWidth() * 100); | |
rasterizationOptions.setPageHeight(cadImage.getHeight() * 100); | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Here user can change default start cap and end cap of pens when exporting CadImage object to | |
// image. It can be using for all image formats: pdf, png, bmp, gif, jpeg2000, jpeg, psd, tiff, wmf. | |
// If user doesn't use PenOptions, system will use its own default pens (different in defferent places). | |
PenOptions penOts = new PenOptions(); | |
penOts.setStartCap(LineCap.Flat); | |
penOts.setEndCap(LineCap.Flat); | |
//rasterizationOptions.setPenOptions(penOts); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
cadImage.save((dataDir+"9LHATT-A56_generated.pdf"),pdfOptions); | |
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
String dataDir = Utils.getDataDir(ReadingDWT.class) + "CADConversion/"; | |
String srcFile = dataDir + "conic_pyramid.dxf"; | |
// Load a CAD drawing in an instance of CadImage | |
//CadImage cadImage = (CadImage) Image.load(srcFile); | |
com.aspose.cad.fileformats.cad.CadImage objImage =(CadImage) com.aspose.cad.Image.load(srcFile); | |
for(Object style : objImage.getStyles()) | |
{ | |
// Set the font name | |
((com.aspose.cad.fileformats.cad.cadtables.CadStyleTableObject)style).setPrimaryFontName("Arial"); | |
} | |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(SetBackgroundAndDrawingColor.class) + "CADConversion/"; | |
String srcFile = dataDir + "conic_pyramid.dxf"; | |
Image image = Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
rasterizationOptions.setBackgroundColor(Color.getBeige()); | |
rasterizationOptions.setDrawType(CadDrawTypeMode.UseDrawColor); | |
rasterizationOptions.setDrawColor(Color.getBlue()); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export CAD to PDF | |
image.save("result_out_.pdf", pdfOptions); | |
// Create an instance of TiffOptions | |
TiffOptions tiffOptions = new TiffOptions(TiffExpectedFormat.Default); | |
// Set the VectorRasterizationOptions property | |
tiffOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export CAD to TIFF | |
image.save(dataDir + "result_out_.tiff", tiffOptions); |
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
String srcFile = dataDir + "conic_pyramid.dxf"; | |
// Image image = Image.load(srcFile); | |
com.aspose.cad.Image objImage = com.aspose.cad.Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
rasterizationOptions.setBackgroundColor(com.aspose.cad.Color.getBeige()); | |
rasterizationOptions.setDrawType(CadDrawTypeMode.UseDrawColor); | |
rasterizationOptions.setBackgroundColor(com.aspose.cad.Color.getBlue()); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export CAD to PDF | |
objImage.save(dataDir +"result_out_.pdf", pdfOptions); | |
// Create an instance of TiffOptions | |
TiffOptions tiffOptions = new TiffOptions(TiffExpectedFormat.Default); | |
// Set the VectorRasterizationOptions property | |
tiffOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export CAD to TIFF | |
objImage.save(dataDir + "result_out_.tiff", tiffOptions); |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(SetCanvasSizeAndMode.class) + "CADConversion/"; | |
String srcFile = dataDir + "conic_pyramid.dxf"; | |
Image image = Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
rasterizationOptions.setScaleMethod(ScaleType.GrowToFit); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export CAD to PDF | |
image.save("result_out_.pdf", pdfOptions); | |
// Create an instance of TiffOptions | |
TiffOptions tiffOptions = new TiffOptions(TiffExpectedFormat.Default); | |
// Set the VectorRasterizationOptions property | |
tiffOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export CAD to TIFF | |
image.save(dataDir + "result_out_.tiff", tiffOptions); |
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
String srcFile = dataDir + "conic_pyramid.dxf"; | |
com.aspose.cad.Image objImage = com.aspose.cad.Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
rasterizationOptions.setAutomaticLayoutsScaling(true); | |
rasterizationOptions.setNoScaling(true); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export CAD to PDF | |
objImage.save(dataDir +"result_out_.pdf", pdfOptions); | |
// Create an instance of TiffOptions | |
TiffOptions tiffOptions = new TiffOptions(TiffExpectedFormat.Default); | |
// Set the VectorRasterizationOptions property | |
tiffOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export CAD to TIFF | |
objImage.save(dataDir + "result_out_.tiff", tiffOptions); |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(SettingAutoLayoutScaling.class) + "CADConversion/"; | |
String srcFile = dataDir + "conic_pyramid.dxf"; | |
Image image = Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// Set Auto Layout Scaling | |
rasterizationOptions.setAutomaticLayoutsScaling(true); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export the CAD to PDF | |
image.save(dataDir + "result_out_.pdf", pdfOptions); |
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
String srcFile = dataDir + "conic_pyramid.dxf"; | |
Image image = Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// Set Auto Layout Scaling | |
rasterizationOptions.setAutomaticLayoutsScaling(true); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export the CAD to PDF | |
image.save(dataDir + "result_out_.pdf", pdfOptions); |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(SubstituteFont.class) + "CADConversion/"; | |
String srcFile = dataDir + "conic_pyramid.dxf"; | |
// Load a CAD drawing in an instance of CadImage | |
CadImage cadImage = (CadImage) Image.load(srcFile); | |
// Iterate over the items of CadStylesDictionary | |
for (CadStyleTableObject style : cadImage.getStyles().getValuesTyped()) { | |
// Set the font name | |
style.setPrimaryFontName("Arial"); | |
} |
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
String srcFile = dataDir + "conic_pyramid.dxf"; | |
// Load a CAD drawing in an instance of CadImage | |
CadImage cadImage = (CadImage) Image.load(srcFile); | |
// Iterate over the items of CadStylesDictionary | |
for(Object style : cadImage.getStyles()) | |
{ | |
// Set the font name | |
((com.aspose.cad.fileformats.cad.cadtables.CadStyleTableObject)style).setPrimaryFontName("Arial"); | |
} | |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(SubstituteFontOfAParticularStyle.class) + "CADConversion/"; | |
String srcFile = dataDir + "conic_pyramid.dxf"; | |
// Load a CAD drawing in an instance of CadImage | |
CadImage cadImage = (CadImage)Image.load(srcFile); | |
// Specify the font for one particular style | |
cadImage.getStyles().get_Item("Roman").setPrimaryFontName("Arial"); |
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
String srcFile = dataDir + "conic_pyramid.dxf"; | |
// Load a CAD drawing in an instance of CadImage | |
CadImage cadImage = (CadImage)Image.load(srcFile); | |
// Specify the font for one particular style | |
((com.aspose.cad.fileformats.cad.cadtables.CadStyleTableObject)cadImage.getStyles().get_Item(0)).setPrimaryFontName("Arial"); |
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
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(SupportOfLayers.class) + "DWFDrawings/"; | |
String srcFile = dataDir + "for_layers_test.dwf"; | |
String outFile = dataDir + "for_layers_test.jpg"; | |
Image image = Image.load(srcFile); | |
/// Create an instance of CadRasterizationOptions and set its various properties | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// Add desired layers | |
List<String> stringList = new ArrayList<>(Arrays.asList("LayerA")); | |
rasterizationOptions.setLayers(stringList); | |
JpegOptions jpegOptions = new JpegOptions(); | |
jpegOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export the DXF to JPG | |
image.save(outFile, jpegOptions); |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
String SourceDir = Utils.getDataDir_DWFXDrawings(); | |
String OutputDir = Utils.getDataDir_Output(); | |
String filePath = SourceDir + "Tyrannosaurus.dwfx"; | |
Image cadImageDwf = Image.load(filePath); | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(cadImageDwf.getSize().getWidth()); | |
rasterizationOptions.setPageHeight(cadImageDwf.getSize().getHeight()); | |
PdfOptions CADf = new PdfOptions(); | |
CADf.setVectorRasterizationOptions(rasterizationOptions); | |
cadImageDwf.save(OutputDir + "OpenDwfxFile_out.pdf", CADf); |
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
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(AccessingUnderlayFlagsofDWG.class) + "DWGDrawings/"; | |
// Input file name and path | |
String fileName = dataDir + "BlockRefDgn.dwg"; | |
// Load an existing DWG file and convert it into CadImage | |
CadImage image = (CadImage)Image.load(fileName); | |
// Go through each entity inside the DWG file | |
for(CadBaseEntity entity : image.getEntities()) | |
{ | |
// Check if entity is of CadDgnUnderlay type | |
if (entity instanceof CadDgnUnderlay) | |
{ | |
// Access different underlay flags | |
CadUnderlay underlay = (CadUnderlay) entity; | |
System.out.println(underlay.getUnderlayPath()); | |
System.out.println(underlay.getUnderlayName()); | |
System.out.println(underlay.getInsertionPoint().getX()); | |
System.out.println(underlay.getInsertionPoint().getY()); | |
System.out.println(underlay.getRotationAngle()); | |
System.out.println(underlay.getScaleX()); | |
System.out.println(underlay.getScaleY()); | |
System.out.println(underlay.getScaleZ()); | |
System.out.println((underlay.getFlags() & UnderlayFlags.UnderlayIsOn) == UnderlayFlags.UnderlayIsOn); | |
System.out.println((underlay.getFlags() & UnderlayFlags.ClippingIsOn) == UnderlayFlags.ClippingIsOn); | |
System.out.println((underlay.getFlags() & UnderlayFlags.Monochrome) != UnderlayFlags.Monochrome); | |
break; | |
} | |
} | |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
// Input file name and path | |
String fileName = "BlockRefDgn.dwg"; | |
// Load an existing DWG file and convert it into CadImage | |
com.aspose.cad.fileformats.cad.CadImage image = (com.aspose.cad.fileformats.cad.CadImage) com.aspose.cad.Image.load(fileName); | |
// Go through each entity inside the DWG file | |
for (com.aspose.cad.fileformats.cad.cadobjects.CadBaseEntity entity : image.getEntities()) | |
{ | |
// Check if entity is of CadDgnUnderlay type | |
if (entity instanceof com.aspose.cad.fileformats.cad.cadobjects.CadDgnUnderlay) | |
{ | |
// Access different underlay flags | |
com.aspose.cad.fileformats.cad.cadobjects.CadUnderlay underlay = (com.aspose.cad.fileformats.cad.cadobjects.CadUnderlay) entity; | |
System.out.println(underlay.getUnderlayPath()); | |
System.out.println(underlay.getUnderlayName()); | |
System.out.println(underlay.getInsertionPoint().getX()); | |
System.out.println(underlay.getInsertionPoint().getY()); | |
System.out.println(underlay.getRotationAngle()); | |
System.out.println(underlay.getScaleX()); | |
System.out.println(underlay.getScaleY()); | |
System.out.println(underlay.getScaleZ()); | |
System.out.println((underlay.getFlags() & com.aspose.cad.fileformats.cad.cadobjects.UnderlayFlags.UnderlayIsOn) == com.aspose.cad.fileformats.cad.cadobjects.UnderlayFlags.UnderlayIsOn); | |
System.out.println((underlay.getFlags() & com.aspose.cad.fileformats.cad.cadobjects.UnderlayFlags.ClippingIsOn) == com.aspose.cad.fileformats.cad.cadobjects.UnderlayFlags.ClippingIsOn); | |
System.out.println((underlay.getFlags() & com.aspose.cad.fileformats.cad.cadobjects.UnderlayFlags.Monochrome) != com.aspose.cad.fileformats.cad.cadobjects.UnderlayFlags.Monochrome); | |
break; | |
} | |
} |
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
String dataDir = Utils.getDataDir(AddTextInDWG.class) + "DWGDrawings/"; | |
String dwgPathToFile = dataDir + "SimpleEntites.dwg"; | |
Image image = Image.load(dwgPathToFile); | |
CadText cadText = new CadText(); | |
cadText.setStyleType("Standard"); | |
cadText.setDefaultValue("Some custom text"); | |
cadText.setColorId(256); | |
cadText.setLayerName("0"); | |
cadText.getFirstAlignment().setX(47.9); | |
cadText.getFirstAlignment().setY(5.56); | |
cadText.setTextHeight(0.8); | |
cadText.setScaleX(0); | |
CadImage cadImage = ((CadImage)(image)); | |
cadImage.getBlockEntities().get_Item("*Model_Space").addEntity(cadText); | |
PdfOptions pdfOptions = new PdfOptions(); | |
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions(); | |
pdfOptions.setVectorRasterizationOptions(cadRasterizationOptions); | |
cadRasterizationOptions.setDrawType(CadDrawTypeMode.UseObjectColor); | |
cadRasterizationOptions.setPageHeight(1600); | |
cadRasterizationOptions.setPageWidth(1600); | |
cadRasterizationOptions.setLayouts(new String[] {"Model"}); | |
image.save(dataDir+"SimpleEntites_generated.dwg.pdf", pdfOptions); | |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(ConvertDWGFileToPDF.class) + "DWGDrawings/"; | |
String srcFile = dataDir + "Bottom_plate.dwg"; | |
Image image = Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setBackgroundColor(Color.getWhite()); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export the DWG to PDF | |
image.save(dataDir + "Bottom_plate_out_.pdf", pdfOptions); |
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
String srcFile = dataDir + "Bottom_plate.dwg"; | |
com.aspose.cad.Image objImage = com.aspose.cad.Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setBackgroundColor(Color.getWhite()); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export the DWG to PDF | |
objImage.save(dataDir + "Bottom_plate_out_.pdf", pdfOptions); |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
String srcFile = dataDir + "visualization_-_conference_room.dwg"; | |
CadImage cadImage = (CadImage)Image.load(srcFile); | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setLayouts(new String[]{"Model"}); | |
rasterizationOptions.setNoScaling(true); | |
// note: preserving some empty borders around part of image is the responsibility of customer | |
// top left point of region to draw | |
Point topLeft = new Point(500, 1000); | |
double width = 3108; | |
double height = 2489; | |
CadVportTableObject newView = new CadVportTableObject(); | |
CadStringParameter cadStringParameter = new CadStringParameter(); | |
cadStringParameter.init("*Active"); | |
newView.setName(cadStringParameter); | |
newView.getCenterPoint().setX(topLeft.getX() + width / 2f); | |
newView.getCenterPoint().setY(topLeft.getY() - height / 2f); | |
newView.getViewHeight().setValue(height);; | |
newView.getViewAspectRatio().setValue(width / height); | |
for (int i = 0; i < cadImage.getViewPorts().size(); i++) | |
{ | |
CadVportTableObject currentView = (CadVportTableObject)(cadImage.getViewPorts().get_Item(i)); | |
if (cadImage.getViewPorts().size() == 1 || currentView.getName().getValue().equalsIgnoreCase("*active")) | |
{ | |
cadImage.getViewPorts().set_Item(i, newView); | |
break; | |
} | |
} | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
dataDir = dataDir + "ConvertDWGToPDFBySupplyingCoordinates_out.pdf"; | |
//Export the DWG to PDF | |
cadImage.save(dataDir, pdfOptions); | |
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
String srcFile = dataDir + "Bottom_plate.dwg"; | |
com.aspose.cad.Image objImage = com.aspose.cad.Image.load(srcFile); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(new CadRasterizationOptions()); | |
pdfOptions.setCorePdfOptions(new PdfDocumentOptions()); | |
pdfOptions.getCorePdfOptions().setCompliance(PdfCompliance.PdfA1a); | |
objImage.save(dataDir+"Saved1.pdf", pdfOptions); | |
pdfOptions.getCorePdfOptions().setCompliance(PdfCompliance.PdfA1b); | |
objImage.save(dataDir+"Saved.pdf", pdfOptions); |
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
String dataDir = Utils.getDataDir(DWGToDWF.class) + "DWGDrawings/"; | |
String inputFile = dataDir+ "Line.dwg"; | |
String outFile = dataDir+ "Line.dwf"; | |
CadImage cadImage = (CadImage)Image.load(inputFile); | |
cadImage.save(outFile); |
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
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(DWGToDXF.class) + "DWGDrawings/"; | |
String inputFile = dataDir+ "Line.dwg"; | |
String outFile = dataDir+ "Line.dxf"; | |
CadImage cadImage = (CadImage)Image.load(inputFile); | |
cadImage.save(outFile); |
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
public static void main(String[] args) | |
{ | |
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(ExportDWGToPDFOrRaster.class) + "DWGDrawings/"; | |
String srcFile = dataDir + "Bottom_plate.dwg"; | |
com.aspose.cad.Image objImage = com.aspose.cad.Image.load(srcFile); | |
Boolean currentUnitIsMetric = IsMetric(objImage.getUnitType()); | |
int currentUnitCoefficient = objImage.getUnitType(); | |
if (currentUnitIsMetric) | |
{ | |
double metersCoeff = 1 / 1000.0; | |
double scaleFactor = metersCoeff / currentUnitCoefficient; | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth((float)(210 * scaleFactor)); | |
rasterizationOptions.setPageHeight((float)(297 * scaleFactor)); | |
rasterizationOptions.setUnitType(UnitType.Millimeter); | |
} | |
else | |
{ | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth((float)(8.27f / currentUnitCoefficient)); | |
rasterizationOptions.setPageHeight((float)(11.69f / currentUnitCoefficient)); | |
rasterizationOptions.setUnitType(UnitType.Inch); | |
} | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(new CadRasterizationOptions()); | |
objImage.save(dataDir+"Saved.pdf", pdfOptions); | |
} | |
public static Boolean IsMetric(int initial) | |
{ | |
Boolean isMetric = true; | |
switch (initial) | |
{ | |
case UnitType.Inch: | |
case UnitType.MicroInch: | |
case UnitType.Mil: | |
case UnitType.Foot: | |
case UnitType.Yard: | |
case UnitType.Mile: | |
case UnitType.Unitless: | |
isMetric = false; | |
} | |
return isMetric; | |
} | |
private Double Coefficient(int unitType) | |
{ | |
Double coefficient = 1.0; | |
switch (unitType) | |
{ | |
case UnitType.Parsec: | |
coefficient = 3.0857 * 10000000000000000.0; | |
break; | |
case UnitType.LightYear: | |
coefficient = 9.4607 * 1000000000000000.0; | |
break; | |
case UnitType.AstronomicalUnit: | |
coefficient = 1.4960 * 100000000000.0; | |
break; | |
case UnitType.Gigameter: | |
coefficient = 1000000000.0; | |
break; | |
case UnitType.Kilometer: | |
coefficient = 1000.0; | |
break; | |
case UnitType.Decameter: | |
coefficient = 10.0; | |
break; | |
case UnitType.Hectometer: | |
coefficient = 100.0; | |
break; | |
case UnitType.Meter: | |
coefficient = 1.0; | |
break; | |
case UnitType.Centimenter: | |
coefficient = 0.01; | |
break; | |
case UnitType.Decimeter: | |
coefficient = 0.1; | |
break; | |
case UnitType.Millimeter: | |
coefficient = 0.001; | |
break; | |
case UnitType.Micrometer: | |
coefficient = 0.000001; | |
break; | |
case UnitType.Nanometer: | |
coefficient = 0.000000001; | |
break; | |
case UnitType.Angstrom: | |
coefficient = 0.0000000001; | |
break; | |
case UnitType.Inch: | |
coefficient = 1.0; | |
break; | |
case UnitType.MicroInch: | |
coefficient = 0.000001; | |
break; | |
case UnitType.Mil: | |
coefficient = 0.001; | |
break; | |
case UnitType.Foot: | |
coefficient = 12.0; | |
break; | |
case UnitType.Yard: | |
coefficient = 36.0; | |
break; | |
case UnitType.Mile: | |
coefficient = 63360.0; | |
break; | |
} | |
return coefficient; | |
} | |
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
String dataDir = Utils.getDataDir(ExportOLEObjects.class) + "DWGDrawings/"; | |
String[] files = new String[] { "D ZD junior D10m H2m.dwg", "ZD - Senior D6m H2m45.dwg" }; | |
PngOptions pngOptions = new PngOptions(); | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
pngOptions.setVectorRasterizationOptions(rasterizationOptions); | |
rasterizationOptions.setLayouts(new String[] { "Layout1" }); | |
for(String file : files) | |
{ | |
CadImage cadImage = (CadImage)Image.load(dataDir + file); | |
cadImage.save(dataDir + file + "_out.png", pngOptions); | |
} | |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(ExportSpecificDWGLayoutToPDF.class) + "DWGDrawings/"; | |
String srcFile = dataDir + "visualization_-_conference_room.dwg"; | |
Image image = Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// Specify desired layout name | |
rasterizationOptions.setLayouts(new String[] {"Layout1"}); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export the DWG to PDF | |
image.save(dataDir + "ExportSpecificLayoutToPDF_out_.pdf", pdfOptions); |
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
String srcFile = dataDir + "visualization_-_conference_room.dwg"; | |
Image image = Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// Specify desired layout name | |
rasterizationOptions.setLayouts(new String[] {"Layout1"}); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export the DWG to PDF | |
image.save(dataDir + "ExportSpecificLayoutToPDF_out_.pdf", pdfOptions); |
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
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(ExportToSVG.class) + "DWGDrawings/"; | |
Image image = Image.load(dataDir + "meshes.dwg"); | |
{ | |
SvgOptions options = new SvgOptions(); | |
options.setColorType(SvgColorMode.Grayscale); | |
options.setTextAsShapes(true); | |
image.save(dataDir + "meshes.svg"); | |
} |
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
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Java | |
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(GetBlockAttributeValueOfExternalReference.class) + "DWGDrawings/"; | |
// Load an existing DWG file as CadImage. | |
CadImage cadImage = (CadImage) Image.load(dataDir + "sample.dwg"); | |
// Access the external path name property | |
String sXternalRef = cadImage.getBlockEntities().get_Item("*MODEL_SPACE").getXRefPathName(); | |
System.out.println(sXternalRef); |
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
// Load an existing DWG file as CadImage. | |
CadImage cadImage = (CadImage) Image.load(dataDir + "sample.dwg"); | |
// Access the external path name property | |
CadStringParameter sXternalRef = cadImage.getBlockEntities().get_Item("*MODEL_SPACE").getXRefPathName(); | |
System.out.println(sXternalRef); |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
String srcFile = dataDir + "Drawing11.dwg"; | |
Image image = Image.load(srcFile); | |
CadRasterImageDef cadRasterImageDef = new CadRasterImageDef("road-sign-custom.png", 640, 562); | |
cadRasterImageDef.setObjectHandle("A3B4"); | |
Cad3DPoint insertionPoint = new Cad3DPoint(26.77, 22.35); | |
Cad3DPoint uVector = new Cad3DPoint(0.0061565450840500831, 0); | |
Cad3DPoint vVector = new Cad3DPoint(0, 0.0061565450840500822); | |
CadRasterImage cadRasterImage = new CadRasterImage(cadRasterImageDef, insertionPoint, uVector, vVector); | |
cadRasterImage.setImageDefReference("A3B4"); | |
cadRasterImage.setDisplayFlags((short)7); | |
cadRasterImage.setClippingState((short)0); | |
cadRasterImage.getClipBoundaryVertexList().add(new Cad2DPoint(-0.5, 0.5)); | |
cadRasterImage.getClipBoundaryVertexList().add(new Cad2DPoint(639.5, 561.5)); | |
CadImage cadImage = ((CadImage)(image)); | |
cadImage.getBlockEntities().get_Item("*Model_Space").addEntity(cadRasterImage); | |
CadBaseObject[] objs = cadImage.getObjects(); | |
CadBaseObject[] arr = new CadBaseObject[objs.length + 1]; | |
int ind = 0; | |
for (CadBaseObject obj : objs) | |
{ | |
arr[ind] = obj; | |
ind++; | |
} | |
arr[ind] = cadRasterImageDef; | |
cadImage.setObjects(arr); | |
PdfOptions pdfOptions = new PdfOptions(); | |
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions(); | |
pdfOptions.setVectorRasterizationOptions(cadRasterizationOptions); | |
cadRasterizationOptions.setDrawType(CadDrawTypeMode.UseObjectColor); | |
cadRasterizationOptions.setPageHeight(1600); | |
cadRasterizationOptions.setPageWidth(1600); | |
cadRasterizationOptions.setLayouts(new String[] {"Model"}); | |
image.save((srcFile + "_generated.pdf"), pdfOptions); |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(ListAllLayoutsInAnAutoCADDrawing.class) + "DWGDrawings/"; | |
String srcFile = dataDir + "conic_pyramid.dxf"; | |
Image image = Image.load(srcFile); | |
CadImage cadImage = (CadImage)image; | |
CadLayoutDictionary layouts = cadImage.getLayouts(); | |
for (CadLayout layout : layouts.getValues()) { | |
System.out.println("Layout " + layout.getLayoutName()); | |
} |
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
String srcFile = dataDir + "conic_pyramid.dxf"; | |
Image image = Image.load(srcFile); | |
CadImage cadImage = (CadImage)image; | |
CadLayoutDictionary layouts = cadImage.getLayouts(); | |
for (CadLayout layout : layouts.getValues()) | |
{ | |
System.out.println("Layout " + layout.getLayoutName()); | |
} | |
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
String srcFile = dataDir + "meshes.dwg"; | |
// com.aspose.cad. objImage = com.aspose.cad.CImage.load(srcFile); | |
CadImage cadImage =(CadImage) com.aspose.cad.Image.load(srcFile); | |
try | |
{ | |
for (CadBaseEntity entity : cadImage.getEntities()) | |
{ | |
if (entity instanceof CadPolyFaceMesh) | |
{ | |
CadPolyFaceMesh asFaceMesh= (CadPolyFaceMesh)entity; | |
if (asFaceMesh != null) | |
{ | |
System.out.println("Vetexes count: " + asFaceMesh.getMeshMVertexCount()); | |
} | |
} | |
else if (entity instanceof CadPolygonMesh) | |
{ | |
CadPolygonMesh asPolygonMesh= (CadPolygonMesh)entity; | |
if (asPolygonMesh != null) | |
{ | |
System.out.println("Vetexes count: " + asPolygonMesh.getMeshMVertexCount()); | |
} | |
} | |
} | |
} | |
finally | |
{ | |
cadImage.dispose(); | |
} |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
String SourceDir = Utils.getDataDir_DWGDrawings(); | |
String dwgPathToFile = SourceDir + "SimpleEntites.dwg"; | |
LoadOptions opts = new LoadOptions(); | |
opts.setSpecifiedEncoding(CodePages.Japanese); | |
opts.setSpecifiedMifEncoding(MifCodePages.Japanese); | |
opts.setRecoverMalformedCifMif(false); | |
CadImage cadImage = (CadImage) Image.load(dwgPathToFile, opts); | |
//do export or something else with cadImage | |
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
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(ParticularDWGToImage.class) + "DWGDrawings/"; | |
String sourceFilePath = dataDir + "visualization_-_conference_room.dwg"; | |
CadImage cadImage = ((CadImage)(Image.load(sourceFilePath))); | |
CadBaseEntity[] entities = cadImage.getEntities(); | |
List<CadBaseEntity> filteredEntities = new ArrayList<CadBaseEntity>(); | |
for (CadBaseEntity baseEntity : entities) { | |
// selection or filtration of entities | |
if ((baseEntity.getTypeName() == CadEntityTypeName.TEXT)) { | |
filteredEntities.add(baseEntity); | |
} | |
} | |
CadBaseEntity[] arr = new CadBaseEntity[filteredEntities.size()]; | |
cadImage.setEntities(filteredEntities.toArray(arr)); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// Set Auto Layout Scaling | |
rasterizationOptions.setAutomaticLayoutsScaling(true); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
String outFile = dataDir + "result_out_generated.pdf"; | |
// Export the CAD to PDF | |
cadImage.save(outFile, pdfOptions); |
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
CadImage image = (CadImage)Image.load(dataDir+"Bottom_plate.dwg"); | |
{ | |
for (CadBaseEntity entity : image.getEntities()) | |
{ | |
if (entity instanceof CadUnderlay) | |
{ | |
//XREF entity with metadata | |
Cad3DPoint insertionPoint = ((CadUnderlay) entity).getInsertionPoint(); | |
String path = ((CadUnderlay) entity).getUnderlayPath(); | |
} | |
} | |
} |
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
String srcFile = dataDir + "visualization_-_conference_room.dwg"; | |
Image image = Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// Specify desired layout name | |
rasterizationOptions.setLayouts(new String[] {"Layout1"}); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export the DWG to PDF | |
image.save(dataDir + "ExportSpecificLayoutToPDF_out_.pdf", pdfOptions); | |
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
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Java | |
// Load an existing DWG file as CadImage. | |
CadImage cadImage = (CadImage) CadImage.load(dataDir + "sample_file.dwg"); | |
// get all layout names and link each layout with corresponding block with entities | |
CadLayoutDictionary layouts = cadImage.getLayouts(); | |
String[] layoutNames = new String[layouts.size()]; | |
int i = 0; | |
for (com.aspose.cad.fileformats.cad.cadobjects.CadLayout layout : layouts.getValues()) { | |
layoutNames[i++] = layout.getLayoutName(); | |
System.out.println("Layout " + layout.getLayoutName() + " is found"); | |
// find block, applicable for DWG only | |
CadBlockTableObject blockTableObjectReference = null; | |
for (CadBlockTableObject tableObject : cadImage.getBlocksTables()) { | |
if (String.CASE_INSENSITIVE_ORDER.compare(tableObject.getHardPointerToLayout(), layout.getObjectHandle()) == 0) { | |
blockTableObjectReference = tableObject; | |
break; | |
} | |
} | |
// Collection cadBlockEntity.Entities contains information about all entities on specific layout | |
// if this collection has no elements it means layout is a copy of Model layout and contains the same entities | |
// Below line of code is for reference | |
CadBlockEntity cadBlockEntity = cadImage.getBlockEntities().get_Item(blockTableObjectReference.getBlockName()); | |
} |
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
private static final String dataDir = Utils.getDataDir(SearchTextInDWGAutoCADFile.class) + "DWGDrawings/"; | |
public static void main(String[] args) { | |
// Search Text In DWG AutoCAD File | |
searchTextInDWGAutoCADFile(); | |
// Search For Text In Specific Layout | |
} | |
public static void searchTextInDWGAutoCADFile() | |
{ | |
//String dataDir="Test_Apsose.CAD\\"; | |
// Load an existing DWG file as CadImage. | |
CadImage cadImage = (CadImage) CadImage.load(dataDir + "sample_file.dwg"); | |
for (CadBaseEntity entity : cadImage.getEntities()) | |
{ | |
IterateCADNodeEntities(entity); | |
} | |
// Search for text in the block section | |
for (CadBlockEntity blockEntity : cadImage.getBlockEntities().getValues()) | |
{ | |
for (CadBaseEntity entity : blockEntity.getEntities()) | |
{ | |
IterateCADNodeEntities(entity); | |
} | |
} | |
} | |
//Recursive function to iterate nodes inside nodes | |
private static void IterateCADNodeEntities(CadBaseEntity obj) | |
{ | |
switch (obj.getTypeName()) | |
{ | |
case CadEntityTypeName.TEXT: | |
CadText childObjectText = (CadText) obj; | |
System.out.println(childObjectText.getDefaultValue()); | |
break; | |
case CadEntityTypeName.MTEXT: | |
CadMText childObjectMText = (CadMText) obj; | |
System.out.println(childObjectMText.getText()); | |
break; | |
case CadEntityTypeName.INSERT: | |
CadInsertObject childInsertObject = (CadInsertObject) obj; | |
for (CadBaseEntity tempobj : childInsertObject.getChildObjects()) | |
{ | |
IterateCADNodeEntities(tempobj); | |
} | |
break; | |
case CadEntityTypeName.ATTDEF: | |
CadAttDef attDef = (CadAttDef) obj; | |
System.out.println(attDef.getDefaultString()); | |
break; | |
case CadEntityTypeName.ATTRIB: | |
CadAttrib attAttrib = (CadAttrib) obj; | |
System.out.println(attAttrib.getDefaultText()); | |
break; | |
} | |
} | |
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
String file = dataDir + "Multileaders.dwg"; | |
Image image = Image.load(file); | |
// Test | |
CadImage cadImage = (CadImage)image; | |
Assert.areNotEqual(cadImage.getEntities().length, 0); | |
CadMLeader cadMLeader = (CadMLeader)cadImage.getEntities()[2]; | |
Assert.areEqual(cadMLeader.getStyleDescription(), "Standard"); | |
Assert.areEqual(cadMLeader.getLeaderStyleId(), "12E"); | |
Assert.areEqual(cadMLeader.getArrowHeadId1(), "639"); | |
Assert.areEqual(cadMLeader.getLeaderLineTypeID(), "14"); | |
CadMLeaderContextData context = cadMLeader.getContextData(); | |
Assert.areEqual(context.getArrowHeadSize(), 30.0, 0.1); | |
Assert.areEqual(context.getBasePoint().getX(), 481, 1); | |
Assert.areEqual(context.getContentScale(), 1.0, 0.01); | |
Assert.areEqual(context.getDefaultText().getValue(), "This is multileader with huge text\\P{\\H1.5x;6666666666666666666666666666\\P}bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); | |
Assert.areEqual(context.hasMText(), true); | |
CadMLeaderNode mleaderNode = context.getLeaderNode(); | |
Assert.areEqual(mleaderNode.getLastLeaderLinePoint().getX(), 473, 1); | |
CadMLeaderLine leaderLine = mleaderNode.getLeaderLine(); | |
Assert.areEqual(leaderLine.getBreakEndPoint().toString(), null); | |
Assert.areEqual(Integer.toString(leaderLine.getBreakPointIndex().getValue()), Integer.toString(0)); | |
Assert.areEqual(leaderLine.getBreakStartPoint().toString(), null); | |
Assert.areEqual(Integer.toString(leaderLine.getLeaderLineIndex().getValue()), Integer.toString(0)); | |
Assert.areEqual(Integer.toString(leaderLine.getLeaderPoints().size()), Integer.toString(4)); | |
Assert.areEqual(Integer.toString(mleaderNode.getBranchIndex()), Integer.toString(0)); | |
Assert.areEqual(mleaderNode.getDogLegLength(), 8.0, 0.1); | |
Assert.areEqual(context.hasMText(), true); | |
// Assert.IsTrue((context.hasMText()==true , "Invalid Z value"); | |
Assert.areEqual(context.getTextAttachmentType().getValue(), (short)1); | |
Assert.areEqual(context.getTextBackgroundColor().getValue(), 18); | |
Assert.areEqual(context.getTextHeight(), 20.0, 0.1); | |
Assert.areEqual(context.getTextStyleID().getValue(), "11"); | |
Assert.areEqual(context.getTextRotation().getValue(), 0.0, 0.01); | |
Assert.areEqual(cadMLeader.getArrowHeadId1(), "639"); | |
Assert.areEqual(cadMLeader.getLeaderType(), 1); | |
Assert.areEqual(cadMLeader.getBlockContentColor(), 0); | |
Assert.areEqual(cadMLeader.getLeaderLineColor(), 0); | |
Assert.areEqual(cadMLeader.getTextHeight(), 1.0, 0.01); | |
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
String dataDir = Utils.getDataDir(DistinguishDWTAndDWGFormats.class) + "DWTDrawings/"; | |
String fileName2 = dataDir +"Sample.dwg"; | |
String fileName3 = dataDir +"sample.dwt"; | |
String fileName4 = dataDir +"sample.dxf"; | |
long formatType2 = Image.getFileFormat(fileName2); | |
Assert.areEqual(formatType2 >= FileFormat.CadR010 && formatType2 <= FileFormat.CadR2013); | |
long formatType3 = Image.getFileFormat(fileName3); | |
Assert.areEqual(formatType3 >= FileFormat.DwtCadR010 && formatType3 <= FileFormat.DwtCadR2013); | |
long formatType4 = Image.getFileFormat(fileName4); | |
Assert.areEqual(formatType4 >= FileFormat.DXFCadR010 && formatType4 <= FileFormat.DXFCadR2013); |
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
String srcFile = dataDir + "conic_pyramid.dxf"; | |
CadImage cadImage =(CadImage) Image.load(srcFile); | |
List<CadBaseEntity> mtextList = new ArrayList<CadBaseEntity>(); | |
List<CadBaseEntity> attribList = new ArrayList<CadBaseEntity>(); | |
try | |
{ | |
for (CadBaseEntity entity : cadImage.getEntities()) | |
{ | |
if (entity.getTypeName() == CadEntityTypeName.MTEXT) | |
{ | |
mtextList.add(entity); | |
} | |
if (entity.getTypeName() == CadEntityTypeName.INSERT) | |
{ | |
for (CadBaseEntity childObject : entity.getChildObjects()) | |
{ | |
if (childObject.getTypeName() == CadEntityTypeName.ATTRIB) | |
{ | |
attribList.add(childObject); | |
} | |
} | |
} | |
} | |
System.out.println("MText Size: "+ mtextList.size()); | |
System.out.println("Attribute Size: "+ attribList.size()); | |
} | |
finally | |
{ | |
cadImage.dispose(); | |
} | |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
String dataDir = Utils.getDataDir(ExportDXFToWMF.class) + "DXFDrawings/"; | |
String srcFile = dataDir + "conic_pyramid.dxf"; | |
String outFile = dataDir + "AddCustomProperties_out.dxf"; | |
CadImage cadImage = (CadImage)Image.load(srcFile); | |
cadImage.getHeader().getCustomProperties().put("CUSTOM_PROPERTY_1", "Custom property test 1"); | |
cadImage.getHeader().getCustomProperties().put("CUSTOM_PROPERTY_2", "Custom property test 2"); | |
cadImage.getHeader().getCustomProperties().put("CUSTOM_PROPERTY_3", "Custom property test 3"); | |
cadImage.save(outFile); |
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
String srcFile = dataDir + "conic_pyramid.dxf"; | |
CadImage cadImage =(CadImage) Image.load(srcFile); | |
try | |
{ | |
for (int i=0; i<cadImage.getEntities().length;i++) | |
{ | |
if (cadImage.getEntities()[i].getTypeName() == CadEntityTypeName.INSERT) | |
{ | |
CadBlockEntity block = | |
(CadBlockEntity)cadImage.getBlockEntities().get_Item(((CadInsertObject)cadImage.getEntities()[i]).getName()); | |
for (CadBaseEntity blockChild : block.getEntities()) | |
{ | |
// process entities | |
} | |
} | |
} | |
} | |
finally | |
{ | |
cadImage.dispose(); | |
} |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
public static class ErrorHandler extends CadRasterizationOptions.CadRenderHandler | |
{ | |
@Override | |
public void invoke(CadRenderResult result) { | |
System.out.println("Tracking results of exporting"); | |
if (result.isRenderComplete()) | |
return; | |
System.out.println("Have some problems:"); | |
int idxError = 1; | |
for (RenderResult rr : result.getFailures()) | |
{ | |
System.out.printf("{0}. {1}, {2}", idxError, rr.getRenderCode(), rr.getMessage()); | |
idxError++; | |
} | |
} | |
} |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(EnableTracking.class) + "DXFDrawings/"; | |
Image image = Image.load(dataDir + "conic_pyramid.dxf"); | |
{ | |
OutputStream stream = new FileOutputStream(dataDir + "output_conic_pyramid.pdf"); | |
{ | |
PdfOptions pdfOptions = new PdfOptions(); | |
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions(); | |
pdfOptions.setVectorRasterizationOptions(cadRasterizationOptions); | |
cadRasterizationOptions.setPageWidth(800); | |
cadRasterizationOptions.setPageHeight(600); | |
cadRasterizationOptions.RenderResult = new ErrorHandler(); | |
System.out.println("Exporting to pdf format"); | |
image.save(stream, pdfOptions); | |
} | |
} |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(ExportDXFDrawingToPDF.class) + "DXFDrawings/"; | |
String srcFile = dataDir + "conic_pyramid.dxf"; | |
Image image = Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setBackgroundColor(Color.getWhite()); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export the DXF to PDF | |
image.save(dataDir + "conic_pyramid_out_.pdf", pdfOptions); |
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
String srcFile = dataDir + "conic_pyramid.dxf"; | |
Image image = Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setBackgroundColor(Color.getWhite()); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export the DXF to PDF | |
image.save(dataDir + "conic_pyramid_out_.pdf", pdfOptions); |
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
String srcFile = dataDir + "conic_pyramid.dxf"; | |
Image image = Image.load(srcFile); | |
IfcImage cadImage = (IfcImage)Image.load((dataDir +"example.ifc")); | |
try | |
{ | |
{ | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(100); | |
rasterizationOptions.setPageHeight(100); | |
WmfOptions wmfOptions = new WmfOptions(); | |
cadImage.save(dataDir+" example.ifc.wmf", wmfOptions); | |
} | |
} | |
finally | |
{ | |
cadImage.dispose(); | |
} | |
// Export the DXF to PDF | |
image.save(dataDir + "conic_pyramid_out_.pdf"); | |
} |
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
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(RenderDXFAsPDF.class) + "DXFDrawings/"; | |
File[] files = new File(dataDir).listFiles(); | |
for (File file : files) { | |
String extension = GetFileExtension(file); | |
if(extension == ".dxf"){ | |
// **************************** | |
// Set new font per document | |
// **************************** | |
CadImage cadImage = (CadImage)Image.load(file.getName()); | |
for (Object style : cadImage.getStyles()) { | |
// Set font name | |
((com.aspose.cad.fileformats.cad.cadtables.CadStyleTableObject)style).setPrimaryFontName("Broadway"); | |
} | |
cadImage.save(file.getName() + "_font.dxf"); | |
// **************************** | |
// Hide all "straight" lines | |
// **************************** | |
CadImage cadImageEntity = (CadImage)Image.load(file.getName()); | |
for (CadBaseEntity entity : cadImageEntity.getEntities()) { | |
// Make lines invisible | |
if ((entity.getTypeName() == CadEntityTypeName.LINE)) { | |
entity.setVisible((short)0); | |
} | |
} | |
cadImageEntity.save(file.getName() + "_lines.dxf"); | |
// **************************** | |
// Manipulations with text | |
// **************************** | |
CadImage cadImageText = (CadImage)Image.load(file.getName()); | |
for (CadBaseEntity entity : cadImageText.getEntities()) { | |
// Make lines invisible | |
if ((entity.getTypeName() == CadEntityTypeName.TEXT)) { | |
((CadText)entity).setDefaultValue("New text here!!! :)"); | |
break; | |
} | |
} | |
cadImageText.save(file.getName() + "_text.dxf"); | |
}//If extension = .dxf | |
} | |
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
private static String GetFileExtension(File file) { | |
String extension = ""; | |
try { | |
if (file != null && file.exists()) { | |
String name = file.getName(); | |
extension = name.substring(name.lastIndexOf(".")); | |
} | |
} catch (Exception e) { | |
extension = ""; | |
} | |
return extension; | |
} |
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
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(ExportSpecificDXFLayoutToPDF.class) + "DXFDrawings\\"; | |
String srcFile = dataDir + "for_layers_test.dwf"; | |
DwfImage image =(DwfImage)Image.load(srcFile); | |
List<String> layersNames=image.getLayers().getLayersNames(); | |
DwfWhipLayer layer = image.getLayers().getLayerByName("0"); | |
for (DwfWhipLayer lr : image.getLayers()) | |
{ | |
//... | |
} | |
// Create an instance of CadRasterizationOptions and set its various properties | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
String[] stringArray = Arrays.copyOf(layersNames.toArray(), layersNames.toArray().length, String[].class); | |
List<String> stringList = Arrays.asList(stringArray); | |
// Add desired layers | |
rasterizationOptions.setLayers(stringList); | |
JpegOptions jpegOptions = new JpegOptions(); | |
jpegOptions.setVectorRasterizationOptions(rasterizationOptions); | |
String output = dataDir+"for_layers_test.jpg"; | |
// Export the DXF to Image | |
image.save(output, jpegOptions); | |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(ExportSpecificDXFLayoutToPDF.class) + "DXFDrawings/"; | |
String srcFile = dataDir + "conic_pyramid.dxf"; | |
Image image = Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// Specify desired layout name | |
rasterizationOptions.setLayouts(new String[] {"Model"}); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export the DXF to PDF | |
image.save(dataDir + "conic_pyramid_layout_out_.pdf", pdfOptions); |
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
String srcFile = dataDir + "conic_pyramid.dxf"; | |
Image image = Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// Specify desired layout name | |
rasterizationOptions.setLayouts(new String[] {"Model"}); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export the DXF to PDF | |
image.save(dataDir + "conic_pyramid_layout_out_.pdf", pdfOptions); |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(ExportSpecificLayerOfDXFDrawingToPDF.class) + "DXFDrawings/"; | |
String srcFile = dataDir + "conic_pyramid.dxf"; | |
Image image = Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// Add desired layers | |
rasterizationOptions.getLayers().add("0"); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export the DXF to PDF | |
image.save(dataDir + "conic_pyramid_layer_out_.pdf", pdfOptions); |
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
String srcFile = dataDir + "conic_pyramid.dxf"; | |
Image image = Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// Add desired layers | |
List<String> stringList = new ArrayList<>(Arrays.asList("0")); | |
rasterizationOptions.setLayers(stringList); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export the DXF to PDF | |
image.save(dataDir + "conic_pyramid_layer_out_.pdf", pdfOptions); |
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
String srcFile = dataDir + "conic_pyramid.dxf"; | |
Image image = Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setBackgroundColor(Color.getWhite()); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export the DXF to PDF | |
image.save(dataDir + "conic_pyramid_out_.pdf", pdfOptions); |
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
String dataDir = Utils.getDataDir(SaveDXFFiles.class) + "CADConversion/"; | |
String srcFile = dataDir + "conic_pyramid.dxf"; | |
CadImage cadImage = (CadImage)Image.load(srcFile); | |
cadImage.save(dataDir+"conic.dxf"); | |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(RenderDXFAsPDF.class) + "DXFDrawings/"; | |
String inputFile = dataDir + "SLS-CW-CD-CE001-R01_blockClip.dxf"; | |
String outputFile = dataDir + "SLS-CW-CD-CE001-R01_blockClip.pdf"; | |
CadImage cadImage = (CadImage)Image.load(inputFile); | |
Margins margins = new Margins(); | |
margins.setTop(5); | |
margins.setRight(30); | |
margins.setBottom(5); | |
margins.setLeft(30); | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setBackgroundColor(Color.getWhite()); | |
rasterizationOptions.setDrawType(CadDrawTypeMode.UseObjectColor); | |
rasterizationOptions.setPageWidth(1200); | |
rasterizationOptions.setPageHeight(1600); | |
rasterizationOptions.setMargins(margins); | |
rasterizationOptions.setLayouts( new String[] { "Model" } ); | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
cadImage.save(outputFile, pdfOptions); | |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(Export3DAutoCADImagesToPDF.class) + "ExportingCAD/"; | |
String srcFile = dataDir + "conic_pyramid.dxf"; | |
Image cadImage = Image.load(srcFile); | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(500); | |
rasterizationOptions.setPageHeight(500); | |
rasterizationOptions.setTypeOfEntities(TypeOfEntities.Entities3D); | |
rasterizationOptions.setLayouts(new String[] {"Model"}); | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
cadImage.save(dataDir + "Export3DImagestoPDF_out_.pdf", pdfOptions); |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(ExportCADLayoutsToPDF.class) + "ExportingCAD/"; | |
String srcFile = dataDir + "conic_pyramid.dxf"; | |
// Create an instance of CadImage class and load the file. | |
Image cadImage = Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions class | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// Set the Entities type property to Entities3D. | |
rasterizationOptions.setTypeOfEntities(TypeOfEntities.Entities3D); | |
rasterizationOptions.setScaleMethod(ScaleType.GrowToFit); | |
rasterizationOptions.setContentAsBitmap(true); | |
// Set Layouts | |
rasterizationOptions.setLayouts(new String[] {"Model"}); | |
// Create an instance of PDF options class | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Set Graphics options | |
rasterizationOptions.getGraphicsOptions().setSmoothingMode(SmoothingMode.HighQuality); | |
rasterizationOptions.getGraphicsOptions().setTextRenderingHint(TextRenderingHint.AntiAliasGridFit); | |
rasterizationOptions.getGraphicsOptions().setInterpolationMode(InterpolationMode.HighQualityBicubic); | |
// Export to PDF by calling the Save method | |
cadImage.save(dataDir + "CADLayoutsToPDF_out_.pdf", pdfOptions); |
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
String srcFile = dataDir + "conic_pyramid.dxf"; | |
// Create an instance of CadImage class and load the file. | |
Image cadImage = Image.load(srcFile); | |
// Create an instance of CadRasterizationOptions class | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// Set the Entities type property to Entities3D. | |
// rasterizationOptions.setTypeOfEntities(TypeOfEntities.Entities3D); | |
rasterizationOptions.setAutomaticLayoutsScaling(true); | |
rasterizationOptions.setNoScaling (false); | |
//rasterizationOptions.setScaleMethod(ScaleType.GrowToFit); | |
rasterizationOptions.setContentAsBitmap(true); | |
// Set Layouts | |
rasterizationOptions.setLayouts(new String[] {"Model"}); | |
// Create an instance of PDF options class | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Set Graphics options | |
rasterizationOptions.getGraphicsOptions().setSmoothingMode(SmoothingMode.HighQuality); | |
rasterizationOptions.getGraphicsOptions().setTextRenderingHint(TextRenderingHint.AntiAliasGridFit); | |
rasterizationOptions.getGraphicsOptions().setInterpolationMode(InterpolationMode.HighQualityBicubic); | |
// Export to PDF by calling the Save method | |
cadImage.save(dataDir + "CADLayoutsToPDF_out_.pdf", pdfOptions); |
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
String fileName = (dataDir + "site.dwf"); | |
com.aspose.cad.Image image = com.aspose.cad.Image.load(fileName); | |
BmpOptions bmpOptions = new BmpOptions(); | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
bmpOptions.setVectorRasterizationOptions(rasterizationOptions); | |
rasterizationOptions.setPageHeight(500); | |
rasterizationOptions.setPageWidth(500); | |
rasterizationOptions.setLayouts(new String[] { "Model" }); | |
// export | |
String outPath = dataDir +"site.bmp"; | |
image.save(outPath, bmpOptions); | |
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
String fileName = (dataDir +"site.dwf"); | |
com.aspose.cad.Image image = com.aspose.cad.Image.load(fileName); | |
{ | |
PdfOptions pdfOptions = new PdfOptions(); | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
rasterizationOptions.setPageHeight(500); | |
rasterizationOptions.setPageWidth(500); | |
rasterizationOptions.setLayouts(new String[] { "Model" }); | |
// export | |
String outPath = dataDir + "site.pdf"; | |
image.save(outPath, pdfOptions); | |
} | |
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
String dataDir = Utils.getDataDir(AccessingUnderlayFlagsofDWG.class) + "DWGDrawings/"; | |
String fileName = dataDir + "BlockRefDgn.dwg"; | |
// Load an existing DWG file and convert it into CadImage | |
com.aspose.cad.fileformats.cad.CadImage image = (com.aspose.cad.fileformats.cad.CadImage) com.aspose.cad.Image.load(fileName); | |
// Go through each entity inside the DWG file | |
for (com.aspose.cad.fileformats.cad.cadobjects.CadBaseEntity entity : image.getEntities()) | |
{ | |
// Check if entity is of CadDgnUnderlay type | |
if (entity instanceof com.aspose.cad.fileformats.cad.cadobjects.CadDgnUnderlay) | |
{ | |
// Access different underlay flags | |
com.aspose.cad.fileformats.cad.cadobjects.CadUnderlay underlay = (com.aspose.cad.fileformats.cad.cadobjects.CadUnderlay) entity; | |
System.out.println(underlay.getUnderlayPath()); | |
System.out.println(underlay.getUnderlayName()); | |
System.out.println(underlay.getInsertionPoint().getX()); | |
System.out.println(underlay.getInsertionPoint().getY()); | |
System.out.println(underlay.getRotationAngle()); | |
System.out.println(underlay.getScaleX()); | |
System.out.println(underlay.getScaleY()); | |
System.out.println(underlay.getScaleZ()); | |
System.out.println((underlay.getFlags() & com.aspose.cad.fileformats.cad.cadobjects.UnderlayFlags.UnderlayIsOn) == com.aspose.cad.fileformats.cad.cadobjects.UnderlayFlags.UnderlayIsOn); | |
System.out.println((underlay.getFlags() & com.aspose.cad.fileformats.cad.cadobjects.UnderlayFlags.ClippingIsOn) == com.aspose.cad.fileformats.cad.cadobjects.UnderlayFlags.ClippingIsOn); | |
System.out.println((underlay.getFlags() & com.aspose.cad.fileformats.cad.cadobjects.UnderlayFlags.Monochrome) != com.aspose.cad.fileformats.cad.cadobjects.UnderlayFlags.Monochrome); | |
break; | |
} | |
} |
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
// Input and Output file paths | |
String dataDir = Utils.getDataDir(ExportDGNAsPartofDWG.class) + "ExportingDGN/"; | |
// Input and Output file paths | |
String fileName = dataDir + "BlockRefDgn.dwg"; | |
String outPath = dataDir +"BlockRefDgn.dwg.pdf"; | |
// Create an instance of PdfOptions class as we are exporting the DWG file to PDF format | |
com.aspose.cad.imageoptions.PdfOptions exportOptions = new com.aspose.cad.imageoptions.PdfOptions(); | |
// Load any existing DWG file as image and convert it to CadImage type | |
com.aspose.cad.fileformats.cad.CadImage cadImage = (com.aspose.cad.fileformats.cad.CadImage) com.aspose.cad.Image.load(fileName); | |
// Go through each entity inside the DWG file | |
for (com.aspose.cad.fileformats.cad.cadobjects.CadBaseEntity baseEntity : cadImage.getEntities()) | |
{ | |
// Check if entity is an image definition | |
if (baseEntity.getTypeName() == com.aspose.cad.fileformats.cad.cadconsts.CadEntityTypeName.DGNUNDERLAY) | |
{ | |
com.aspose.cad.fileformats.cad.cadobjects.CadDgnUnderlay dgnFile = (com.aspose.cad.fileformats.cad.cadobjects.CadDgnUnderlay)baseEntity; | |
// Get external reference to object | |
System.out.println(dgnFile.getUnderlayPath()); | |
} | |
} | |
// Define settings for CadRasterizationOptions object | |
com.aspose.cad.imageoptions.CadRasterizationOptions vectorRasterizationOptions = new com.aspose.cad.imageoptions.CadRasterizationOptions(); | |
vectorRasterizationOptions.setPageWidth(1600); | |
vectorRasterizationOptions.setPageHeight(1600); | |
vectorRasterizationOptions.setLayouts(new String[] { "Model" }); | |
vectorRasterizationOptions.setAutomaticLayoutsScaling(false); | |
vectorRasterizationOptions.setNoScaling(true); | |
vectorRasterizationOptions.setBackgroundColor(com.aspose.cad.Color.getBlack()); | |
vectorRasterizationOptions.setDrawType(com.aspose.cad.fileformats.cad.CadDrawTypeMode.UseObjectColor); | |
// Set Vector Rasterization Options | |
exportOptions.setVectorRasterizationOptions(vectorRasterizationOptions); | |
// Export the DWG to PDF by calling Save method | |
cadImage.save(outPath, exportOptions); | |
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
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Java | |
// Input and Output file paths | |
String fileName = "BlockRefDgn.dwg"; | |
String outPath = "BlockRefDgn.dwg.pdf"; | |
// Create an instance of PdfOptions class as we are exporting the DWG file to PDF format | |
com.aspose.cad.imageoptions.PdfOptions exportOptions = new com.aspose.cad.imageoptions.PdfOptions(); | |
// Load any existing DWG file as image and convert it to CadImage type | |
com.aspose.cad.fileformats.cad.CadImage cadImage = (com.aspose.cad.fileformats.cad.CadImage) com.aspose.cad.Image.load(fileName); | |
// Go through each entity inside the DWG file | |
for (com.aspose.cad.fileformats.cad.cadobjects.CadBaseEntity baseEntity : cadImage.getEntities()) | |
{ | |
// Check if entity is an image definition | |
if (baseEntity.getTypeName() == com.aspose.cad.fileformats.cad.cadconsts.CadEntityTypeName.DGNUNDERLAY) | |
{ | |
com.aspose.cad.fileformats.cad.cadobjects.CadDgnUnderlay dgnFile = (com.aspose.cad.fileformats.cad.cadobjects.CadDgnUnderlay)baseEntity; | |
// Get external reference to object | |
System.out.println(dgnFile.getUnderlayPath()); | |
} | |
} | |
// Define settings for CadRasterizationOptions object | |
com.aspose.cad.imageoptions.CadRasterizationOptions vectorRasterizationOptions = new com.aspose.cad.imageoptions.CadRasterizationOptions(); | |
vectorRasterizationOptions.setPageWidth(1600); | |
vectorRasterizationOptions.setPageHeight(1600); | |
vectorRasterizationOptions.setCenterDrawing(true); | |
vectorRasterizationOptions.setLayouts(new String[] { "Model" }); | |
vectorRasterizationOptions.setScaleMethod(com.aspose.cad.fileformats.cad.ScaleType.None); | |
vectorRasterizationOptions.setBackgroundColor(com.aspose.cad.Color.getBlack()); | |
vectorRasterizationOptions.setDrawType(com.aspose.cad.fileformats.cad.CadDrawTypeMode.UseObjectColor); | |
// Set Vector Rasterization Options | |
exportOptions.setVectorRasterizationOptions(vectorRasterizationOptions); | |
// Export the DWG to PDF by calling Save method | |
cadImage.save(outPath, exportOptions); |
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
String dataDir = Utils.getDataDir(ExportEmbeddedDGN.class) + "ExportingDGN/"; | |
String fileName = dataDir + "BlockRefDgn.dwg"; | |
com.aspose.cad.Image objImage = com.aspose.cad.Image.load(fileName); | |
{ | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setLayouts(new String[] {"Model"}); | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
objImage.save(dataDir + "BlockRefDgn.pdf", pdfOptions); | |
} |
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
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Java | |
String dataDir = Utils.getDataDir(ExportingDGNAutoCADFormatToPDF.class) + "ExportingDGN/"; | |
// load an existing DGN file as DgnImage. | |
DgnImage dgnImage = (DgnImage)Image.load(dataDir + "Nikon_D90_Camera.dgn"); | |
DgnRasterizationOptions rasterizationOptions = new DgnRasterizationOptions(); | |
// Create an object of CadRasterizationOptions class and define/set different properties | |
PdfOptions options = new PdfOptions(); | |
rasterizationOptions.setPageWidth(600); | |
rasterizationOptions.setPageHeight(300); | |
rasterizationOptions.setCenterDrawing(true); | |
rasterizationOptions.setAutomaticLayoutsScaling(false); | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
OutputStream outStream = new FileOutputStream(dataDir + "ExportDGNToPdf_Out.pdf"); | |
// Call the save method of the DgnImage class object. | |
dgnImage.save(outStream, options); |
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
// load an existing DGN file as DgnImage. | |
DgnImage dgnImage = (DgnImage)Image.load(dataDir + "Nikon_D90_Camera.dgn"); | |
// Create an object of CadRasterizationOptions class and define/set different properties | |
PdfOptions options = new PdfOptions(); | |
CadRasterizationOptions vectorOptions = new CadRasterizationOptions(); | |
vectorOptions.setPageWidth(1500); | |
vectorOptions.setPageHeight(1500); | |
vectorOptions.setNoScaling(true); | |
vectorOptions.setAutomaticLayoutsScaling(false); | |
options.setVectorRasterizationOptions(vectorOptions); | |
OutputStream outStream = new FileOutputStream(dataDir + "ExportDGNToPdf_Out.pdf"); | |
// Call the save method of the DgnImage class object. | |
dgnImage.save(outStream, options); |
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
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Java | |
String dataDir = Utils.getDataDir(ExportingDGNAutoCADFormatToRasterImageFormat.class) + "ExportingDGN/"; | |
// Load an existing DGN file as DgnImage. | |
DgnImage dgnImage = (DgnImage) Image.load(dataDir + "Nikon_D90_Camera.dgn"); | |
// Create an object of DgnRasterizationOptions class and define/set different properties | |
DgnRasterizationOptions rasterizationOptions = new DgnRasterizationOptions(); | |
// Create an object of JpegOptions class as we are converting the DGN to JPEG and assign DgnRasterizationOptions object to it. | |
ImageOptionsBase options = new JpegOptions(); | |
rasterizationOptions.setPageWidth(600); | |
rasterizationOptions.setPageHeight(400); | |
rasterizationOptions.setCenterDrawing(true); | |
rasterizationOptions.setAutomaticLayoutsScaling(false); | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
OutputStream outStream = new FileOutputStream(dataDir + "ExportDGNToRasterImage_Out.jpg"); | |
// Call the save method of the CadImage class object. | |
dgnImage.save(outStream, options); |
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
// Load an existing DGN file as DgnImage. | |
DgnImage dgnImage = (DgnImage) Image.load(dataDir + "Nikon_D90_Camera.dgn"); | |
// Create an object of JpegOptions class as we are converting the DGN to JPEG and assign DgnRasterizationOptions object to it. | |
ImageOptionsBase options = new JpegOptions(); | |
CadRasterizationOptions vectorOptions = new CadRasterizationOptions(); | |
vectorOptions.setPageWidth(600); | |
vectorOptions.setPageHeight(400); | |
vectorOptions.setNoScaling(true); | |
vectorOptions.setAutomaticLayoutsScaling(false); | |
options.setVectorRasterizationOptions(vectorOptions); | |
OutputStream outStream = new FileOutputStream(dataDir + "ExportDGNToRasterImage_Out.jpg"); | |
// Call the save method of the CadImage class object. | |
dgnImage.save(outStream, options); | |
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
// Input and Output file paths | |
String fileName = "BlockRefDgn.dwg"; | |
String outPath = "BlockRefDgn.dwg.pdf"; | |
DgnImage dgnImage = (DgnImage)Image.load(dataDir); | |
{ | |
for (DgnDrawingElementBase element : dgnImage.getElements()) | |
{ | |
switch (element.getMetadata().getType()) | |
{ | |
case DgnElementType.Line: | |
case DgnElementType.Ellipse: | |
case DgnElementType.Curve: | |
case DgnElementType.BSplineCurveHeader: | |
case DgnElementType.Arc: | |
case DgnElementType.Shape: | |
case DgnElementType.PolyLine: | |
case DgnElementType.TextNode: | |
case DgnElementType.Text: | |
case DgnElementType.ComplexShapeHeader: | |
case DgnElementType.ComplexChainHeader: | |
{ | |
//previously supported entities, now supported also for 3D | |
break; | |
} | |
case DgnElementType.SolidHeader3D: | |
case DgnElementType.Cone: | |
case DgnElementType.CellHeader: | |
{ | |
//supported 3D entities | |
break; | |
} | |
} |
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
String fileName = dataDir + "Nikon_D90_Camera.dgn"; | |
String outFile = dataDir + "Nikon_D90_Camera.dgn"; | |
DgnImage objImage = (DgnImage)com.aspose.cad.Image.load(fileName); | |
PdfOptions options = new PdfOptions(); | |
CadRasterizationOptions vectorOptions = new CadRasterizationOptions(); | |
vectorOptions.setPageWidth(1500); | |
vectorOptions.setPageHeight(1500); | |
vectorOptions.setAutomaticLayoutsScaling(true); | |
vectorOptions.setBackgroundColor(Color.getBlack()); | |
vectorOptions.setLayouts(new String[] { "1", "2", "3", "9" });//only export 4 (1,2,3 and 9) views | |
options.setVectorRasterizationOptions(vectorOptions); | |
objImage.save(outFile, options); | |
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
String dataDir = Utils.getDataDir(AddWatermark.class) + "DWGDrawings/"; | |
// Path to source file | |
String sourceFilePath = dataDir+"Drawing11.dwg"; | |
CadImage cadImage = (CadImage) Image.load(sourceFilePath); | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.setText("Watermark message"); | |
watermark.setInitialTextHeight(40); | |
watermark.setInsertionPoint(new Cad3DPoint(300, 40)); | |
watermark.setLayerName("0"); | |
cadImage.getBlockEntities().get_Item("*Model_Space").addEntity(watermark); | |
// or add more simple entity like Text | |
CadText text = new CadText(); | |
text.setDefaultValue("Watermark text"); | |
text.setTextHeight(40); | |
text.setFirstAlignment(new Cad3DPoint(300, 40)); | |
text.setLayerName("0") ; | |
cadImage.getBlockEntities().get_Item("*Model_Space").addEntity(text); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
rasterizationOptions.setLayouts(new String[]{"Model"}); | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
cadImage.save(dataDir + "AddWatermark_out.pdf", pdfOptions); |
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
String dataDir = Utils.getDataDir(CFFToPDF.class) + "CFF/"; | |
// Path to source file | |
String sourceFilePath = dataDir+"WineBottle_Die.cf2"; | |
Image image = Image.load(sourceFilePath); | |
{ | |
PdfOptions options = new PdfOptions(); | |
image.save(dataDir + "WineBottle_Die_out.pdf",options); | |
} | |
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
String dataDir = Utils.getDataDir(FreePointOfView.class) + "CADConversion/"; | |
// Path to source file | |
String sourceFilePath = dataDir+"conic_pyramid.dxf"; | |
// Load a CAD drawing in an instance of Image | |
com.aspose.cad.Image objImage = com.aspose.cad.Image.load(sourceFilePath); | |
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions(); | |
cadRasterizationOptions.setPageHeight(1500); | |
cadRasterizationOptions.setPageWidth(1500); | |
// Create an instance of JpegOptions class | |
com.aspose.cad.imageoptions.JpegOptions options = new com.aspose.cad.imageoptions.JpegOptions(); | |
options.setVectorRasterizationOptions(cadRasterizationOptions); | |
float xAngle = 10; //Angle of rotation along the X axis | |
float yAngle = 30; //Angle of rotation along the Y axis | |
float zAngle = 40; //Angle of rotation along the Z axis | |
ObserverPoint obvPoint = new ObserverPoint(xAngle,yAngle,zAngle); | |
cadRasterizationOptions.setObserverPoint(obvPoint); | |
options.setVectorRasterizationOptions(cadRasterizationOptions); | |
//Saving to Image | |
objImage.save(dataDir+"FreePointOfView_out.jpeg", options); |
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
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java | |
final String SourceDir = Utils.getDataDir_DWGDrawings(); | |
final String OutputDir = Utils.getDataDir_Output(); | |
final InterruptionTokenSource source = new com.aspose.cad.InterruptionTokenSource(); | |
try { | |
final CadImage cadImageBig = (CadImage)Image.load(SourceDir + "Drawing11.dwg"); | |
try { | |
CadRasterizationOptions rasterizationOptionsBig = new CadRasterizationOptions(); | |
rasterizationOptionsBig.setPageWidth(cadImageBig.getSize().getWidth() / 2); | |
rasterizationOptionsBig.setPageHeight(cadImageBig.getSize().getHeight() / 2); | |
final PdfOptions CADfBig = new PdfOptions(); | |
CADfBig.setVectorRasterizationOptions(rasterizationOptionsBig); | |
CADfBig.setInterruptionToken(source.getToken()); | |
java.lang.Thread thread = new java.lang.Thread(new Runnable() { | |
@Override | |
public void run() { | |
try { | |
cadImageBig.save(OutputDir + "PutTimeoutOnSave_out.pdf", CADfBig); | |
} catch (Throwable th) { | |
System.out.println("interrupted !!!"); | |
} | |
} | |
}); | |
thread.start(); | |
TimeUnit.SECONDS.sleep(3); | |
source.interrupt(); | |
thread.join(); | |
} finally { | |
cadImageBig.dispose(); | |
} | |
} finally { | |
source.dispose(); | |
} |
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
String dataDir = Utils.getDataDir(SinglePDFWithDifferentLayouts.class) + "DWGDrawings/"; | |
CadImage cadImage = (CadImage)Image.load(dataDir + "City skyway map.dwg"); | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1000); | |
rasterizationOptions.setPageHeight(1000); | |
//custom sizes for several layouts | |
rasterizationOptions.getLayoutPageSizes().addItem("ANSI C Plot", new SizeF(500, 1000)); | |
rasterizationOptions.getLayoutPageSizes().addItem("8.5 x 11 Plot", new SizeF(1000, 100)); | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
cadImage.save(dataDir + "singlePDF_out.pdf", pdfOptions); | |
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
String dataDir = Utils.getDataDir(EditHyperlink.class) + "DWGDrawings/"; | |
CadImage cadImage = (CadImage)Image.load(dataDir + "AutoCad_Sample.dwg"); | |
for (CadBaseEntity entity : cadImage.getEntities()) | |
{ | |
if (entity instanceof CadInsertObject) | |
{ | |
CadBlockEntity block = cadImage.getBlockEntities().get_Item(((CadInsertObject)entity).getName()); | |
String value = block.getXRefPathName().getValue(); | |
if (value != null && !value.contentEquals("")) | |
{ | |
block.getXRefPathName().setValue("new file reference.dwg"); | |
} | |
} | |
if (entity.getHyperlink() == "https://products.aspose.com") | |
{ | |
entity.setHyperlink("https://www.aspose.com"); | |
} | |
} | |
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
String fileName = dataDir +"example.ifc"; | |
IfcImage cadImage = (IfcImage)Image.load(fileName); | |
CadRasterizationOptions vectorOptions = new CadRasterizationOptions(); | |
vectorOptions.setPageWidth(1500); | |
vectorOptions.setPageHeight(1500); | |
PngOptions pngOptions = new PngOptions(); | |
pngOptions.setVectorRasterizationOptions(vectorOptions); | |
String outPath = dataDir + "example.png"; | |
cadImage.save(dataDir, pngOptions); | |
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
String dataDir = Utils.getDataDir(SupportOfOBJ.class) + "OBJDrawings/"; | |
Image cadDoc = Image.load(dataDir + "example-580-W.obj"); | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(cadDoc.getSize().getWidth()); | |
rasterizationOptions.setPageHeight(cadDoc.getSize().getHeight()); | |
PdfOptions CADf = new PdfOptions(); | |
CADf.setVectorRasterizationOptions(rasterizationOptions); | |
cadDoc.save(dataDir + "example-580-W_custom.pdf", CADf); | |
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
String dataDir = Utils.getDataDir(ExportSTLToPNG.class) + "ExportingSTL/"; | |
String fileName = dataDir + "example.stl"; | |
CadImage cadImage = (CadImage)Image.load(fileName); | |
CadRasterizationOptions vectorOptions = new CadRasterizationOptions(); | |
vectorOptions.setPageWidth(1500); | |
vectorOptions.setPageHeight(1500); | |
PngOptions pngOptions = new PngOptions(); | |
//pngOptions.setVectorRasterizationOptions(rasterizationOptions); | |
String outPath = dataDir + "galeon.stl.png"; | |
cadImage.save(outPath, pngOptions); | |
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
String dataDir = Utils.getDataDir(ExportIGEStoPDF.class) + "IGESDrawings/"; | |
String PLTPathToFile = dataDir + "figa2.igs"; | |
Image image = Image.load(PLTPathToFile); | |
//Setting PDF Options | |
PdfOptions pdfOptions = new PdfOptions(); | |
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions(); | |
cadRasterizationOptions.setDrawType(CadDrawTypeMode.UseObjectColor); | |
cadRasterizationOptions.setPageHeight(1000); | |
cadRasterizationOptions.setPageWidth(1000); | |
pdfOptions.setVectorRasterizationOptions(cadRasterizationOptions); | |
//Saving to PDF | |
image.save(dataDir+"figa2.pdf", pdfOptions); | |
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
String PLTPathToFile = dataDir + "50states.plt"; | |
Image image = Image.load(PLTPathToFile); | |
//Setting PDF Options | |
ImageOptionsBase imageOptions = new JpegOptions(); | |
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions(); | |
cadRasterizationOptions.setDrawType(CadDrawTypeMode.UseObjectColor); | |
cadRasterizationOptions.setPageHeight(1600); | |
cadRasterizationOptions.setPageWidth(1600); | |
cadRasterizationOptions.setBackgroundColor(com.aspose.cad.Color.getBlack()); | |
imageOptions.setVectorRasterizationOptions(cadRasterizationOptions); | |
//Saving to Image | |
image.save(dataDir+"50states.jpeg", imageOptions); | |
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
String dataDir = Utils.getDataDir(ExportPLTtoPDF.class) + "PLTDrawings\\"; | |
String PLTPathToFile = dataDir + "50states.plt"; | |
Image image = Image.load(PLTPathToFile); | |
//Setting PDF Options | |
PdfOptions pdfOptions = new PdfOptions(); | |
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions(); | |
cadRasterizationOptions.setDrawType(CadDrawTypeMode.UseObjectColor); | |
cadRasterizationOptions.setPageHeight(1600); | |
cadRasterizationOptions.setPageWidth(1600); | |
cadRasterizationOptions.setBackgroundColor(com.aspose.cad.Color.getBlack()); | |
pdfOptions.setVectorRasterizationOptions(cadRasterizationOptions); | |
//Saving to PDF | |
image.save(dataDir+"50states.pdf", pdfOptions); | |
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
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions(); | |
for (String layoutName : cadImage.getLayouts().getKeysTyped()) | |
{ | |
CadLayout layout = cadImage.getLayouts().get(layoutName); | |
if (layout.getLayoutName() == "Model") continue; | |
System.out.println(layout.getLayoutName()); | |
SizeF pageSize = GetPageSizeFromLayout(layout); | |
cadRasterizationOptions.getLayoutPageSizes().put(layout.getLayoutName(), pageSize); | |
} | |
private static SizeF GetPageSizeFromLayout(CadLayout layout) | |
{ | |
boolean isLandscape = IsLayoutLandscape(layout); | |
float pageWidth; | |
float pageHeight; | |
if (layout.getPlotPaperUnits() == CadPlotPaperUnits.PlotInInches) | |
{ | |
pageWidth = (float)MillimetersToInches(layout.getPlotPaperSize().getWidth()); | |
pageHeight = (float)MillimetersToInches(layout.getPlotPaperSize().getHeight()); | |
} | |
else | |
{ | |
pageWidth = (float)layout.getPlotPaperSize().getWidth(); | |
pageHeight = (float)layout.getPlotPaperSize().getHeight(); | |
} | |
if (isLandscape) | |
{ | |
return new SizeF(pageHeight, pageWidth); | |
} | |
else | |
{ | |
return new SizeF(pageWidth, pageHeight); | |
} | |
} | |
private static boolean IsLayoutLandscape(CadLayout layout) | |
{ | |
short plotRotation = layout.getPlotRotation(); | |
return plotRotation == CadPlotRotation.Clockwise90Degrees || plotRotation == CadPlotRotation.Counterclockwise90Degrees; | |
} | |
private static double MillimetersToInches(double millimeters) | |
{ | |
double MillimetersToInchesFactor = 0.0393701; | |
return millimeters * MillimetersToInchesFactor; | |
} |
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
final Image cadImage = Image.load(in); | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(5000); | |
rasterizationOptions.setPageHeight(5000); | |
rasterizationOptions.setDrawType(CadDrawTypeMode.UseObjectColor); | |
rasterizationOptions.setObserverPoint(new ObserverPoint(15,5,5)); | |
final PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
cadImage.save(out, pdfOptions); |
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
final Image cadImage = Image.load(in); | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(5000); | |
rasterizationOptions.setPageHeight(5000); | |
rasterizationOptions.setDrawType(CadDrawTypeMode.UseObjectColor); | |
rasterizationOptions.setRenderMode3D(RenderMode3D.Wireframe); | |
final PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
cadImage.save(out, pdfOptions); |
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
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions(); | |
boolean isMetric = false; | |
double coefficient = 1.0; | |
switch (cadImage.getUnitType()) | |
{ | |
// it is possible to extend this with more types that may appear in drawings | |
case UnitType.Meter: | |
isMetric = true; | |
coefficient = 1.0; | |
break; | |
case UnitType.Millimeter: | |
isMetric = true; | |
coefficient = 0.001; | |
break; | |
case UnitType.Inch: | |
coefficient = 1.0; | |
break; | |
} | |
SizeF size; | |
if (isMetric) | |
{ | |
double metersCoeff = 1 / 1000.0; | |
double scaleFactor = metersCoeff / coefficient; | |
size = new SizeF((float)(210 * scaleFactor), (float)(297 * scaleFactor)); | |
cadRasterizationOptions.setUnitType(UnitType.Millimeter); | |
} | |
else | |
{ | |
size = new SizeF((float)(8.3f / coefficient), (float)(11.7f / coefficient)); | |
cadRasterizationOptions.setUnitType(UnitType.Inch); | |
} | |
cadRasterizationOptions.setPageSize(size); |
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
String ctbFile = "Plotstyle.ctb"; | |
Map ctbFiles = new HashMap(); | |
FileStream ctbStream = new FileStream(ctbFile, FileMode.Open); | |
ctbFiles.put(ctbFile, ctbStream.toInputStream()); | |
cadRasterizationOptions.setCtbSources(ctbFiles); |
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
List<ShxCodePage> shxCodePages = new ArrayList<ShxCodePage>(); | |
shxCodePages.add(new ShxCodePage("someFont.shx", CodePages.Japanese)); | |
shxCodePages.add(new ShxCodePage("someFont2.shx", CodePages.SimpChinese)); | |
cadRasterizationOptions.setShxCodePages(shxCodePages); |
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
final CadImage cadImage = (CadImage)Image.load(…); | |
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions(); | |
cadRasterizationOptions.setShxFonts( new String[] { | |
"pathToFolderWithFonts\\gbcbig.shx", | |
"pathToFolderWithFonts\\gbenor.shx", | |
}); | |
// set other options and export | |
… |
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
CadImage img = (CadImage)Image.load("template.cf2"); | |
String TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
for (CadBaseEntity CadEntity : img.getEntities()) | |
{ | |
if (CadEntity.getTypeName() == CadEntityTypeName.TEXT) | |
{ | |
CadText CadTextObject = (CadText) CadEntity; | |
TextExtractedFromFile += CadTextObject.getDefaultValue(); | |
} | |
} | |
//Save the text extracted from CF2 file using File Stream | |
FileStream FStream = new FileStream(dataDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.write(TextExtractedFromFile); | |
SWriter.flush(); | |
//Close file objects | |
SWriter.close(); | |
FStream.close(); |
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
DgnImage img = (DgnImage) Image.load("template.dgn"); | |
String TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
for (String CadEntity : img.getStrings()) | |
{ | |
TextExtractedFromFile += CadEntity + System.lineSeparator(); | |
} | |
//Save the text extracted from DGN file using File Stream | |
FileStream FStream = new FileStream(dataDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.write(TextExtractedFromFile); | |
SWriter.flush(); | |
//Close file objects | |
SWriter.close(); | |
FStream.close(); |
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
CadImage img = (CadImage)Image.load("template.dwf"); | |
String TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
for (CadBaseEntity CadEntity : img.getEntities()) | |
{ | |
if (CadEntity.getTypeName() == CadEntityTypeName.TEXT) | |
{ | |
CadText CadTextObject = (CadText) CadEntity; | |
TextExtractedFromFile += CadTextObject.getDefaultValue(); | |
} | |
} | |
//Save the text extracted from DWF file using File Stream | |
FileStream FStream = new FileStream(dataDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.write(TextExtractedFromFile); | |
SWriter.flush(); | |
//Close file objects | |
SWriter.close(); | |
FStream.close(); |
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
CadImage img = (CadImage)Image.load("template.dwfx"); | |
String TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
for (CadBaseEntity CadEntity : img.getEntities()) | |
{ | |
if (CadEntity.getTypeName() == CadEntityTypeName.TEXT) | |
{ | |
CadText CadTextObject = (CadText) CadEntity; | |
TextExtractedFromFile += CadTextObject.getDefaultValue(); | |
} | |
} | |
//Save the text extracted from DWFX file using File Stream | |
FileStream FStream = new FileStream(dataDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.write(TextExtractedFromFile); | |
SWriter.flush(); | |
//Close file objects | |
SWriter.close(); | |
FStream.close(); |
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
CadImage img = (CadImage)Image.load("template.dwg"); | |
String TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
for (CadBaseEntity CadEntity : img.getEntities()) | |
{ | |
if (CadEntity.getTypeName() == CadEntityTypeName.TEXT) | |
{ | |
CadText CadTextObject = (CadText) CadEntity; | |
TextExtractedFromFile += CadTextObject.getDefaultValue(); | |
} | |
} | |
//Save the text extracted from DWG file using File Stream | |
FileStream FStream = new FileStream(dataDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.write(TextExtractedFromFile); | |
SWriter.flush(); | |
//Close file objects | |
SWriter.close(); | |
FStream.close(); |
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
CadImage img = (CadImage)Image.load("template.dwt"); | |
String TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
for (CadBaseEntity CadEntity : img.getEntities()) | |
{ | |
if (CadEntity.getTypeName() == CadEntityTypeName.TEXT) | |
{ | |
CadText CadTextObject = (CadText) CadEntity; | |
TextExtractedFromFile += CadTextObject.getDefaultValue(); | |
} | |
} | |
//Save the text extracted from DWT file using File Stream | |
FileStream FStream = new FileStream(dataDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.write(TextExtractedFromFile); | |
SWriter.flush(); | |
//Close file objects | |
SWriter.close(); | |
FStream.close(); |
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
CadImage img = (CadImage)Image.load("template.dxf"); | |
String TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
for (CadBaseEntity CadEntity : img.getEntities()) | |
{ | |
if (CadEntity.getTypeName() == CadEntityTypeName.TEXT) | |
{ | |
CadText CadTextObject = (CadText) CadEntity; | |
TextExtractedFromFile += CadTextObject.getDefaultValue(); | |
} | |
} | |
//Save the text extracted from DXF file using File Stream | |
FileStream FStream = new FileStream(dataDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.write(TextExtractedFromFile); | |
SWriter.flush(); | |
//Close file objects | |
SWriter.close(); | |
FStream.close(); |
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
FbxImage img = (FbxImage) Image.load("template.fbx"); | |
String TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
for (String CadEntity : img.getStrings()) | |
{ | |
TextExtractedFromFile += CadEntity + System.lineSeparator(); | |
} | |
//Save the text extracted from FBX file using File Stream | |
FileStream FStream = new FileStream(dataDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.write(TextExtractedFromFile); | |
SWriter.flush(); | |
//Close file objects | |
SWriter.close(); | |
FStream.close(); |
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
IfcImage img = (IfcImage) Image.load("template.ifc"); | |
String TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
for (String CadEntity : img.getStrings()) | |
{ | |
TextExtractedFromFile += CadEntity + System.lineSeparator(); | |
} | |
//Save the text extracted from IFC file using File Stream | |
FileStream FStream = new FileStream(dataDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.write(TextExtractedFromFile); | |
SWriter.flush(); | |
//Close file objects | |
SWriter.close(); | |
FStream.close(); |
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
IgesImage img = (IgesImage) Image.load("template.iges"); | |
String TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
for (String CadEntity : img.getStrings()) | |
{ | |
TextExtractedFromFile += CadEntity + System.lineSeparator(); | |
} | |
//Save the text extracted from IGES file using File Stream | |
FileStream FStream = new FileStream(dataDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.write(TextExtractedFromFile); | |
SWriter.flush(); | |
//Close file objects | |
SWriter.close(); | |
FStream.close(); |
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
ObjImage img = (ObjImage) Image.load("template.obj"); | |
String TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
for (String CadEntity : img.getStrings()) | |
{ | |
TextExtractedFromFile += CadEntity + System.lineSeparator(); | |
} | |
//Save the text extracted from OBJ file using File Stream | |
FileStream FStream = new FileStream(dataDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.write(TextExtractedFromFile); | |
SWriter.flush(); | |
//Close file objects | |
SWriter.close(); | |
FStream.close(); |
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
PltImage img = (PltImage) Image.load("template.plt"); | |
String TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
for (String CadEntity : img.getStrings()) | |
{ | |
TextExtractedFromFile += CadEntity + System.lineSeparator(); | |
} | |
//Save the text extracted from PLT file using File Stream | |
FileStream FStream = new FileStream(dataDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.write(TextExtractedFromFile); | |
SWriter.flush(); | |
//Close file objects | |
SWriter.close(); | |
FStream.close(); |
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
CadImage img = (CadImage)Image.load("template.stl"); | |
String TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
for (CadBaseEntity CadEntity : img.getEntities()) | |
{ | |
if (CadEntity.getTypeName() == CadEntityTypeName.TEXT) | |
{ | |
CadText CadTextObject = (CadText) CadEntity; | |
TextExtractedFromFile += CadTextObject.getDefaultValue(); | |
} | |
} | |
//Save the text extracted from STL file using File Stream | |
FileStream FStream = new FileStream(dataDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.write(TextExtractedFromFile); | |
SWriter.flush(); | |
//Close file objects | |
SWriter.close(); | |
FStream.close(); |
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
SvgImage img = (SvgImage) Image.load("template.dgn"); | |
String TextExtractedFromFile = ""; | |
// Search for text in the entities section | |
for (String CadEntity : img.getStrings()) | |
{ | |
TextExtractedFromFile += CadEntity + System.lineSeparator(); | |
} | |
//Save the text extracted from Svg file using File Stream | |
FileStream FStream = new FileStream(dataDir + "ExtractTextFromFormat.txt", FileMode.Create); | |
StreamWriter SWriter = new StreamWriter(FStream); | |
//Write extracted text to the file | |
SWriter.write(TextExtractedFromFile); | |
SWriter.flush(); | |
//Close file objects | |
SWriter.close(); | |
FStream.close(); |
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
// load CF2 in an instance of Image via its Load method | |
Image image = Image.load("template.cf2"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export CF2 to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
// load DGN in an instance of Image via its Load method | |
DgnImage image = (DgnImage) DgnImage.load("template.dgn"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export DGN to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
// load DWF in an instance of Image via its Load method | |
Image image = Image.load("template.dwf"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export DWF to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
// load DWFX in an instance of Image via its Load method | |
Image image = Image.load("template.dwfx"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export DWFX to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
// load DWG in an instance of Image via its Load method | |
Image image = Image.load("template.dwg"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export DWG to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
// load DWT in an instance of Image via its Load method | |
Image image = Image.load("template.dwt"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export DWT to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
// load DXF in an instance of Image via its Load method | |
Image image = Image.load("template.dxf"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export DXF to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
// load FBX in an instance of Image via its Load method | |
Image image = Image.load("template.fbx"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export FBX to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
// load IFC in an instance of Image via its Load method | |
IfcImage image = (IfcImage) IfcImage.load("template.ifc"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export IFC to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
// load IGES in an instance of Image via its Load method | |
IgesImage image = (IgesImage) IgesImage.load("template.iges"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export IGES to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(output); |
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
// load OBJ in an instance of Image via its Load method | |
ObjImage image = (ObjImage) ObjImage.load("template.obj"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export OBJ to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
// load PLT in an instance of Image via its Load method | |
PltImage image = (PltImage) PltImage.load("template.plt"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export PLT to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
// load STL in an instance of Image via its Load method | |
Image image = Image.load("template.stl"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export STL to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
// load SVG in an instance of Image via its Load method | |
SvgImage image = (SvgImage) SvgImage.load("template.svg"); | |
// create an instance of CadRasterizationOptions and set page height & width | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// create an instance of TiffOptions | |
TiffOptions options = new TiffOptions(); | |
// set the VectorRasterizationOptions property as CadRasterizationOptions | |
options.setVectorRasterizationOptions(rasterizationOptions); | |
// export SVG to TIFF | |
image.save("output.tiff", options); | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(); |
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
CadImage cadImage = (CadImage) Image.load("template.cf2"); | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.setText("Watermark message"); | |
watermark.setInitialTextHeight(40); | |
watermark.setInsertionPoint(new Cad3DPoint(300, 40)); | |
watermark.setLayerName("0"); | |
cadImage.getBlockEntities().get_Item("*Model_Space").addEntity(watermark); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
rasterizationOptions.setLayouts(new String[]{"Model"}); | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
cadImage.save(dataDir + "AddWatermark_out.pdf", pdfOptions); |
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
DgnImage cadImage = (DgnImage) Image.load("template.dgn"); | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.setText("Watermark message"); | |
watermark.setInitialTextHeight(40); | |
watermark.setInsertionPoint(new Cad3DPoint(300, 40)); | |
watermark.setLayerName("0"); | |
cadImage.getBlockEntities().get_Item("*Model_Space").addEntity(watermark); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
rasterizationOptions.setLayouts(new String[]{"Model"}); | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
cadImage.save(dataDir + "AddWatermark_out.pdf", pdfOptions); |
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
CadImage DwfImage = (DwfImage) Image.load("template.dwf"); | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.setText("Watermark message"); | |
watermark.setInitialTextHeight(40); | |
watermark.setInsertionPoint(new Cad3DPoint(300, 40)); | |
watermark.setLayerName("0"); | |
cadImage.getBlockEntities().get_Item("*Model_Space").addEntity(watermark); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
rasterizationOptions.setLayouts(new String[]{"Model"}); | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
cadImage.save(dataDir + "AddWatermark_out.pdf", pdfOptions); |
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
CadImage cadImage = (CadImage) Image.load("template.dwfx"); | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.setText("Watermark message"); | |
watermark.setInitialTextHeight(40); | |
watermark.setInsertionPoint(new Cad3DPoint(300, 40)); | |
watermark.setLayerName("0"); | |
cadImage.getBlockEntities().get_Item("*Model_Space").addEntity(watermark); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
rasterizationOptions.setLayouts(new String[]{"Model"}); | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
cadImage.save(dataDir + "AddWatermark_out.pdf", pdfOptions); |
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
CadImage cadImage = (CadImage) Image.load("template.dwg"); | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.setText("Watermark message"); | |
watermark.setInitialTextHeight(40); | |
watermark.setInsertionPoint(new Cad3DPoint(300, 40)); | |
watermark.setLayerName("0"); | |
cadImage.getBlockEntities().get_Item("*Model_Space").addEntity(watermark); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
rasterizationOptions.setLayouts(new String[]{"Model"}); | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
cadImage.save(dataDir + "AddWatermark_out.pdf", pdfOptions); |
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
CadImage cadImage = (CadImage) Image.load("template.dwt"); | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.setText("Watermark message"); | |
watermark.setInitialTextHeight(40); | |
watermark.setInsertionPoint(new Cad3DPoint(300, 40)); | |
watermark.setLayerName("0"); | |
cadImage.getBlockEntities().get_Item("*Model_Space").addEntity(watermark); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
rasterizationOptions.setLayouts(new String[]{"Model"}); | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
cadImage.save(dataDir + "AddWatermark_out.pdf", pdfOptions); |
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
CadImage cadImage = (CadImage) Image.load("template.dxf"); | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.setText("Watermark message"); | |
watermark.setInitialTextHeight(40); | |
watermark.setInsertionPoint(new Cad3DPoint(300, 40)); | |
watermark.setLayerName("0"); | |
cadImage.getBlockEntities().get_Item("*Model_Space").addEntity(watermark); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
rasterizationOptions.setLayouts(new String[]{"Model"}); | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
cadImage.save(dataDir + "AddWatermark_out.pdf", pdfOptions); |
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
FbxImage cadImage = (FbxImage) Image.load("template.fbx"); | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.setText("Watermark message"); | |
watermark.setInitialTextHeight(40); | |
watermark.setInsertionPoint(new Cad3DPoint(300, 40)); | |
watermark.setLayerName("0"); | |
cadImage.getBlockEntities().get_Item("*Model_Space").addEntity(watermark); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
rasterizationOptions.setLayouts(new String[]{"Model"}); | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
cadImage.save(dataDir + "AddWatermark_out.pdf", pdfOptions); |
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
IfcImage cadImage = (IfcImage) Image.load("template.ifc"); | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.setText("Watermark message"); | |
watermark.setInitialTextHeight(40); | |
watermark.setInsertionPoint(new Cad3DPoint(300, 40)); | |
watermark.setLayerName("0"); | |
cadImage.getBlockEntities().get_Item("*Model_Space").addEntity(watermark); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
rasterizationOptions.setLayouts(new String[]{"Model"}); | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
cadImage.save(dataDir + "AddWatermark_out.pdf", pdfOptions); |
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
IgesImage cadImage = (IgesImage) Image.load("template.iges"); | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.setText("Watermark message"); | |
watermark.setInitialTextHeight(40); | |
watermark.setInsertionPoint(new Cad3DPoint(300, 40)); | |
watermark.setLayerName("0"); | |
cadImage.getBlockEntities().get_Item("*Model_Space").addEntity(watermark); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
rasterizationOptions.setLayouts(new String[]{"Model"}); | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
cadImage.save(dataDir + "AddWatermark_out.pdf", pdfOptions); |
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
ObjImage cadImage = (ObjImage) Image.load("template.obj"); | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.setText("Watermark message"); | |
watermark.setInitialTextHeight(40); | |
watermark.setInsertionPoint(new Cad3DPoint(300, 40)); | |
watermark.setLayerName("0"); | |
cadImage.getBlockEntities().get_Item("*Model_Space").addEntity(watermark); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
rasterizationOptions.setLayouts(new String[]{"Model"}); | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
cadImage.save(dataDir + "AddWatermark_out.pdf", pdfOptions); |
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
PltImage cadImage = (PltImage) Image.load("template.plt"); | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.setText("Watermark message"); | |
watermark.setInitialTextHeight(40); | |
watermark.setInsertionPoint(new Cad3DPoint(300, 40)); | |
watermark.setLayerName("0"); | |
cadImage.getBlockEntities().get_Item("*Model_Space").addEntity(watermark); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
rasterizationOptions.setLayouts(new String[]{"Model"}); | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
cadImage.save(dataDir + "AddWatermark_out.pdf", pdfOptions); |
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
CadImage cadImage = (CadImage) Image.load("template.plt"); | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.setText("Watermark message"); | |
watermark.setInitialTextHeight(40); | |
watermark.setInsertionPoint(new Cad3DPoint(300, 40)); | |
watermark.setLayerName("0"); | |
cadImage.getBlockEntities().get_Item("*Model_Space").addEntity(watermark); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
rasterizationOptions.setLayouts(new String[]{"Model"}); | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
cadImage.save(dataDir + "AddWatermark_out.pdf", pdfOptions); |
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
CadImage cadImage = (CadImage) Image.load("template.svg"); | |
//add new MTEXT | |
CadMText watermark = new CadMText(); | |
watermark.setText("Watermark message"); | |
watermark.setInitialTextHeight(40); | |
watermark.setInsertionPoint(new Cad3DPoint(300, 40)); | |
watermark.setLayerName("0"); | |
cadImage.getBlockEntities().get_Item("*Model_Space").addEntity(watermark); | |
// export to pdf | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
rasterizationOptions.setLayouts(new String[]{"Model"}); | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
cadImage.save(dataDir + "AddWatermark_out.pdf", pdfOptions); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment