Implementing template maps
Developers perform this task.
Exporting content from Brightspot to InDesign requires mapping Brightspot fields to InDesign tags. Work with your designer to understand the following:
Which InDesign documents will be importing content
Which Brightspot content types will be imported
Which objects in InDesign documents will be receiving content from which Brightspot fields
Tag names for those objects
With this understanding, you can model the InDesignDocument
and InDesignTag
content types that perform the export from Brightspot.
Brightspot provides sample classes NewspaperInDesignDocument.java
and SmartBriefInDesignDocument.java
that illustrate mapping between Brightspot fields and InDesign tags. You can find these classes in the directory brightspot/express/poc/src/main/java/brightspot/indesign/
. These classes, and any class that maps between Brightspot and InDesign, require understanding the Brightspot classes InDesignDocument and InDesignTag.
InDesignDocument
Classes that extend InDesignDocument
export content from Brightspot to an InDesign document. These classes must implement the getTags()
method. Editors open InDesignDocument
subclasses in Brightspot to synchronize content as described in Using InDesign with Brightspot.
The following snippet is an example of extending InDesignDocument
to export fields from Brightspot articles to a tagged InDesign document.
import com.psddev.indesign.InDesignDocument; public class WeeklyNewsletterCover extends InDesignDocument { private Article featuredArticle; 1 private Article secondaryArticle; private Image mainImage; /* Getters and setters */ public List<InDesignTag> getTags() { 2 List<InDesignTag> tags = new ArrayList<>(); if (featuredArticle != null) { tags.add(new FieldDocumentTag("featuredHeadline", featuredArticle, "headline")); 3 tags.add(new ImageDocumentTag("featuredImage", featuredArticle.getImage())); } if (secondaryArticle != null) { tags.add(new FieldDocumentTag("secondHeadline", secondaryArticle, "headline")); } if (mainImage != null) { tags.add(new ImageDocumentTag("mainImage", mainImage)); } return tags; } }
Declares the | |
Implements the | |
Illustrates the instantiation of InDesign tags within Brightspot. InDesign tag data is represented by a tag class (such as |
InDesignTag
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() { 1 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 |