Can I add a watermark to the stp/step format?

Testing Aspose.CAD for Java 24.6.1, can I add a watermark in stp/step format?
How to achieve it?

@xingyu11

Currently, Aspose.CAD does not provide direct support for adding watermarks to STP/STEP files. However, you can manipulate CAD files (like DWG) to add watermarks and then export them to other formats, such as PDF.

Here’s a general approach to add a watermark to a CAD file using Aspose.CAD for Java:

  1. Load the CAD file: Use the Image.Load method to load your CAD file.
  2. Create a watermark: You can create a text entity (like CadMText or CadText) to serve as your watermark.
  3. Insert the watermark: Add the watermark entity to the model space of the CAD image.
  4. Export the modified file: Save the modified CAD file to a desired format, such as PDF.

Here’s a code snippet to illustrate this process:

import com.aspose.cad.*;
import com.aspose.cad.fileformats.cad.*;
import com.aspose.cad.imageoptions.*;

public class AddWatermark {
    public static void main(String[] args) {
        // Load the CAD file
        String filePath = "path/to/your/file.dwg";
        CadImage cadImage = (CadImage) Image.load(filePath);

        // Create a watermark
        CadMText watermark = new CadMText();
        watermark.setText("Watermark message");
        watermark.setInitialTextHeight(40);
        watermark.setInsertionPoint(new Cad3DPoint(300, 40));
        watermark.setLayerName("0");

        // Add the watermark to the model space
        cadImage.getBlockEntities().get("*Model_Space").addEntity(watermark);

        // Set up rasterization options for exporting
        CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
        rasterizationOptions.setPageWidth(1600);
        rasterizationOptions.setPageHeight(1600);
        rasterizationOptions.setLayouts(new String[] { "Model" });

        // Export to PDF
        PdfOptions pdfOptions = new PdfOptions();
        pdfOptions.setVectorRasterizationOptions(rasterizationOptions);
        cadImage.save("path/to/output/file.pdf", pdfOptions);
    }
}

This code demonstrates how to add a watermark to a CAD file and export it to PDF. Unfortunately, for STP/STEP files, you may need to convert them to a supported format first before applying a watermark.

If you have further questions or need assistance with specific file formats, feel free to ask!

@xingyu11,
Hi,
we don’t have this feature implemented, we have created CADJAVA-11771 to support it.