Topics

InDesignTag


In This Guide

Subclasses of InDesignTag map Brightspot field values to the corresponding tag in an InDesign file. The map is a JSON file that InDesign can read. The tag field’s value corresponds to the name of a tagged object on the InDesign file, typically a text frame or a rectangle.

In the following snippet, featuredHeadline corresponds to the name of a tagged container in InDesign, and headline corresponds to the internal name of a Brightspot field.

tags.add(new FieldDocumentTag("featuredHeadline", featuredArticle, "headline"));

Warning
Multiple InDesign objects with the same tag may cause the import from Brightspot to fail. Ensure the InDesign file’s objects have unique tags.

For additional information about how InDesign uses tags and the corresponding XML structure, see Tag content for XML.

Brightspot includes several InDesignTag subclasses, and you can create your own custom subclasses. Below is an example of extending InDesignTag to map an image with custom values.

import com.psddev.indesign.InDesignTag;

public class ImageInDesignTag extends InDesignTag {

    @Required
    private Image image;
    private String style;

    public ImageTag(String tag, Image image) {
        this.tag = tag;
        this.image = image;
    }

    @Override
    public String getType() {
        return "image";
    }

    @Override
    protected Map<String, String> getTagValues() { 
        Map<String, String> values = new HashMap<>();
        if (image != null) {
            StorageItem file = image.getFile();
            if (file != null) {
                values.put("contents", file.getPublicUrl());
                values.put("imageSizes", image.getSizes());
                values.put("caption", image.getCaption());
                if (style != null) {
                    values.put("imageStyle", style);
                }
            }
        }
        return values;
    }
}
  • Implements the getTagValues method. Values of the Brightspot Image object are retrieved and set on InDesign values, such as imageSizes.

In This Guide