Hide layers from printing to pdf

Hello,

My dxf drawing has multiple layers eg: (L1, L2, L3…L10).
While printing to pdf I need following
Hide Layer L1 and L3 (means all entityies in Layer L1 and L3 would not be shown)
How can I achieve the same

Thanks Pranav

@velotech

Can you please share the requirements in the form of source DXF and desired output.

Find attached source dxf file
here while printing to pdf,

  1. I want to hide layer “DYNAMIC TEXT” from the java program.
  2. Also the layers which are in hidden state in dxf should also be not printed

I have attached output pdfMISO-GA-BP-CW with hidden layers.pdf (22.3 KB)
MISO-GA-BP-CW for layers.zip (112.9 KB)

@velotech

I have created an issue with ID CADJAVA-864 in our issue tracking system as investigation to further explore the requirements shared by you. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

@velotech

You can filter out the layers by selecting the ones that you require to render in PDF. However, you have filter out the layers based on some criteria that you will devise. Please consider following example on your end.
List requiredLayers = new ArrayList();

CadLayersList cadLayersList = cadImage.getLayers();
for (int i = 0; i < cadLayersList.size(); i++)
{
CadLayerTable layer = (CadLayerTable)cadLayersList.get_Item(i);

// negative color id means layer is hidden
// plot flag set up to false means the layer is not for printing
if (layer.getColorId() >= 0 && layer.getName().compareTo("DYNAMIC TEXT") != 0 
        && !(layer.getPlotFlag().isSet() && !layer.getPlotFlag().getValue()))
{
    requiredLayers.add(layer.getName());
}
}
rasterizationOptions.setLayers(requiredLayers);