Expand my Community achievements bar.

Native PDF: Cover Page: Cover image: Dynamically pick-up and display

Avatar

Level 2

I've read the help on page templates and can see that we can hardcode a logo, other image, of background image into the design.

 

I know that we can define text variables and display these on the page template.

 

But what do we do if we have images that vary by publication, and we want to display one of those dynamic images on a location on the page?

 

For example, a cover image of the product or additional symbols or logos specific to the publication.

 

Is it possible to define an image variable that can be placed on the page layout design?

 

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

8 Replies

Avatar

Level 6

I am also interested in the answer to this question.

Avatar

Employee

@Mike-E : there could be two possible solutions to this: 

 

Option 1: if you know that all the maps are of type bookmap, then generally the images that should go on front page can be under frontmatter or some xpath under the bookmap xml

In this case, you can create a metadata field and use the xpath to the image and use it in the template page layout - check this document to know more about metadata fields

 

Option 2: if the map can be ditamap or bookmap, and lets say the image cannot be defined in the map xml then you may use User variable - defining the image path as variable in the output preset, steps as given below

  • create user variable on the output preset and 
  • define the img tag with src path as value of the variable (as of today: path should be relative to the map prefixed with "contents/" - this will be handled in future release) 
  • and use that variable in the template layout
  • the language variables sets are selectable on the output preset "Advanced" tab
This approach is also documented - check this page on Experience League (refer section "Use variables in the Native PDF templates")
 
 
I hope this helps.
 

Avatar

Level 4

@Mike-E @sschnelbach 

The img tag you define in the variable has to literally be the tag. I was confused at first about this so I thought I would write a comment.

i.e.

rkody_0-1729863992458.png

Avatar

Administrator

@Mike-E Did you find the suggestion helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!



Kautuk Sahni

Avatar

Level 6

I'm sorry, but these explanations and examples aren't explicit enough for me. The screenshot above looks like it would work for a specific, unchanging image, but not for an image variable that would change for every map. It seems like there should be a way to define a keydef/keyref in the map for a cover_image and use that, but nothing I'm trying is working. I know how to define text as a language variable, but not the specific format for an image that would be defined within either a map or bookmap.

Avatar

Level 4

Hi @sschnelbach ,

 

My solution will work for dynamic images, they just need to be defined. Please note that these are not language variables, but just "Variables". See yellow highlight.

The different images can be defined by clicking on "settings" and naming the variations you need. See green highlight.

After you create the variations, you can switch between them by the drop down. See blue highlight. For each variation, define the different image tags you need. When you first create the variations, the cover variable will display the same value, but by switching between the variations through the blue highlighted dropdown, you can define all the cover images you need.

rkody_1-1740431584277.png

 

Now that these are defined, you can place the variable in a page layout. I have mine in a blank page because our covers images take up the entire page. I believe you can just drag and drop the variable in, but it's coded like this: <span data-keyref="Cover">Cover Image</span>

rkody_2-1740432134933.png

 

The last step is selecting the variation from the output preset on the map.

rkody_3-1740432295659.png

So if I want Cover X to be displayed, the variable set Cover X should be selected and the output pdf will display the image that you defined for it. This way every map can have its own preset with the correct cover image selected.

 

I think this solution will work for you, as the images can be defined differently for each map.

Avatar

Employee

Thanks @rkody 

Adding to it 
I am attaching screenshot with the step-by-step approach and sample variable set and PDF template to get started .

Step 1: Create your variable sets 

Screenshot 2025-02-25 at 10.11.02 AM.png

Step 2: Add desired variable in your page layout ( I used "logo" variable")

Screenshot 2025-02-25 at 10.21.12 AM.png

Screenshot 2025-02-25 at 10.09.36 AM.png

 Step 3 : While publishing select desired variable set in your preset and publish!

Screenshot 2025-02-25 at 10.22.28 AM.png

The attached Sample contains a sample template (where the variable is used ) , a Variable set, and images.

@sschnelbach  Let me know how it goes for you 




Avatar

Level 6

Thank you for the detailed answer. I'm still not getting it to work, but the Variable is selectable in the maps configuration. (It's just not appearing in the Native PDF Publishing PDF output.)

 

Unless I'm doing this incorrectly, which is entirely possible, this type of variable seems to be a global variable and not specific to each map in our system. We have hundreds of maps/product docs that would require different covers. A global cover image variable would work for fewer than a dozen different covers, but not for hundreds. 

 

Please let me know if I completely misunderstood how to define this, but the variable I set up does appear as selectable in any map I opened in the XML Editor.