Code with Finding: |
class PdfWriter {
/**
* @param erase true to erase the {@link PdfName#OCGS} and {@link PdfName#D} from the OCProperties first.
* @since 2.1.2
*/
protected void fillOCProperties(final boolean erase) {
if (OCProperties == null)
OCProperties = new PdfOCProperties();
if (erase) {
OCProperties.remove(PdfName.OCGS);
OCProperties.remove(PdfName.D);
}
if (OCProperties.get(PdfName.OCGS) == null) {
PdfArray gr = new PdfArray();
for (Object element : documentOCG) {
PdfLayer layer = (PdfLayer)element;
gr.add(layer.getRef());
}
OCProperties.put(PdfName.OCGS, gr);
}
if (OCProperties.get(PdfName.D) != null)
return;
ArrayList<PdfOCG> docOrder = new ArrayList<PdfOCG>(documentOCGorder);
for (Iterator<PdfOCG> it = docOrder.iterator(); it.hasNext();) {
PdfLayer layer = (PdfLayer)it.next();
if (layer.getParent() != null)
it.remove();
}
PdfArray order = new PdfArray();
for (Object element : docOrder) {
PdfLayer layer = (PdfLayer)element;
getOCGOrder(order, layer);
}
PdfDictionary d = new PdfDictionary();
OCProperties.put(PdfName.D, d);
d.put(PdfName.ORDER, order);
PdfArray gr = new PdfArray();
for (Object element : documentOCG) {
PdfLayer layer = (PdfLayer)element;
if (!layer.isOn())
gr.add(layer.getRef());
}
if (gr.size() > 0)
d.put(PdfName.OFF, gr);
if (OCGRadioGroup.size() > 0)
d.put(PdfName.RBGROUPS, OCGRadioGroup);
if (OCGLocked.size() > 0)
d.put(PdfName.LOCKED, OCGLocked);
addASEvent(PdfName.VIEW, PdfName.ZOOM);
addASEvent(PdfName.VIEW, PdfName.VIEW);
addASEvent(PdfName.PRINT, PdfName.PRINT);
addASEvent(PdfName.EXPORT, PdfName.EXPORT);
d.put(PdfName.LISTMODE, PdfName.VISIBLEPAGES);
}
}
|