Convert PSD Layers to Raster Images and Export 3D Entities in DXF to PDF using Java

We are pleased to announce the release of Aspose.Imaging for Java 3.1.0. This release allows you to convert PSD layers to PNG, JPEG and TIFF image formats. Support to export 3D entities while converting DXF to PDF has also been incorporated in this release.

Convert PSD Layers to Raster Images in Java

Using Aspose.Imaging for Java, developers can convert PSD layers to PNG, JPEG and TIFF images. Further, an exception with an appropriate message will be thrown in case of an unsupported layer. Following is the code snippet demonstrating how PSD layers can be converted to a PNG image.

// Create an instance of Image class
com.aspose.imaging.Image image = com.aspose.imaging.Image.load(sourceFileName);
        
// Cast image object to PSD image
com.aspose.imaging.fileformats.psd.PsdImage psdImage = (com.aspose.imaging.fileformats.psd.PsdImage)image;
    
// Create an instance of PngOptions class
PngOptions pngOptions = new PngOptions();
pngOptions.setColorType(com.aspose.imaging.fileformats.png.PngColorType.TruecolorWithAlpha);

// Access the list of layers in the PSD image object
com.aspose.imaging.fileformats.psd.layers.Layer[] allLayers = psdImage.getLayers();
        
for (int i = 0; i < allLayers.length; i++)
{
     // convert and save the layer to PNG file format.
     allLayers[i].save("layer" + i + 1 + ".png" , pngOptions);
}

Export 3D Entities while Converting DXF to PDF

Aspose.Imaging for Java now enables the developers to export 3D entities while converting a DXF file to PDF file format. TypeOfEntities enumeration now has an integer value Entities3D. Setting TypeOfEntities property of the CadRasterizationOptions class will export the 3D entities to PDF.
Following is the code demonstration of the said functionality.

// Create an instance of CadImage class and load the DXF file.
CadImage cadImage = (CadImage)Image.Load(fileName);

// 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);

// Set Layouts
String[] sModelName = { "Model" };

rasterizationOptions.setLayouts(sModelName);

// Create an instance of PDF options class
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setVectorRasterizationOptions(rasterizationOptions);

// Export to PDF by calling the Save method.                    
string outPath = fileName + ".pdf";
cadImage.Save(outPath, pdfOptions);

Enhancements

Conversion of DWG to PDF and exception handling were already supported, however, conversion and exception handling processes have been improved further.

  • EMF to PNG conversion functionality has been improved.
  • Converting color space from RGB to CMYK has been improved for JPEG images.
  • DWG to PDF functionality has been improved.
  • DWG to raster images functionality has been improved.
  • Maintaining image quality while resizing has been improved.
  • The functionality of HorizontalResolution & VerticalResolution properties have been improved.

Please refer to the release notes of Aspose.Imaging for Java 3.1.0 for a full view of improvements along with sample code snippets for newly added features. If you are planning to upgrade the API to the latest revision, we strongly suggest you to check the Public API Changes section to know what has been changed in the public API since your current version.

Aspose.Imaging for Java Resources

The resources, you may need to accomplish your tasks:

As always we appreciate your feedback so if you ever have anything to tell us about this release or anything else, please head to the Aspose.Imaging forum for a chat.