Free Support Forum -

Raster Image size in dxf


We have a dxf file with raster image inserted.
We change the image dynamically as per the requirement and then convert dxf to pdf using our java application.

The image size will change when we create it. The current dxf to pdf prints the image to actual size
We need that the image should be fitted to its original length and width. How can we achieve the same

dxf with (612.8 KB)


Can you please provide the used sample code that you have used to reproduce the issue. Please also first try using latest Aspose.CAD for .NET 20.6 on your end as well.

I have saved all the files from the zip file provided earlier in WebContent/DXFDrawings folder
Please find code below

public class ExportDXFDrawingToPDF {

public static void main(String[] args) {
	System.out.println("start time:"+new Date());
	// The path to the resource directory.
	String dataDir = Utils.getDataDir(ExportDXFDrawingToPDF.class) + "DXFDrawings/";
            String srcFile = dataDir + "with logo.dxf";
	Image image = Image.load(srcFile);
    // Create an instance of CadRasterizationOptions and set its various properties
    CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();

    // Create an instance of PdfOptions
    PdfOptions pdfOptions = new PdfOptions();
    // Set the VectorRasterizationOptions property

    // Export the DXF to PDF + "with logo.pdf", pdfOptions);    
    System.out.println("end time:"+new Date());


I can observe the issue in generated PDF and ticket with ID CADJAVA-751 has been created to further investigate and resolve the issue. We will share notification with you once issue will be fixed.


Thanks for your feedback
This feature is very much important to us. We are looking to purchase the library, provided this feature is resolved

Thanks & Regards,
Pranav C Lunavat


The issue has just been added in our issue tracking system. We request for your patience and will share feedback with you as soon as the issue will be fixed.


We have verified the requirements w.r.t AutoCad 2019 behavior. It seems that the attached sample is has some incorrect internal data as different Autocad applications display it differently. Some even don’t display the image at all as well as rendering that. Therefore, we have the identical result as AutoCad 2019.

There is no dynamic option to achieve this. You will have to explicitly set bounds.


Thanks for your reply.
Could you please give some example of setting bounds using aspose code in java


You may consider using following sample code on your end to serve the purpose.

using (CadImage cadImage = (CadImage)Image.Load(fileName))
//get rasterimage entity for which we want to change export
CadRasterImage entity = (CadRasterImage) cadImage.Entities[cadImage.Entities.Length - 1];

   //set clipping and boundaries
   entity.ClippingState = 1;
   entity.ClipBoundaryVertexList = new List<Cad2DPoint>() { new Cad2DPoint((double) 0,0), new Cad2DPoint(300,0), new Cad2DPoint(300,500), new Cad2DPoint(0,500) };

   //now export
   // cadImage.Save() ....