Stack

Modified on Tue, Nov 21, 2023 at 10:48 AM

!stack paragraph command

 

Syntax:

!stack {H:LogoBlock}{H:TextBlock} stack!

 

The command must be entered as a value to a paragraph command. 

The !stack command is used to repeat multiple blocks a number of times within a block. Any number of blocks can be added not just two. The blocks can be text, image, graphics or pdf. 

When using pdf server directly, any of the following types can be used:

  • image
  • graphics
  • pdf

the supplied file extension will decide which one to use. That is, one can add an image block and send PDF or SVG files to it.

 

The command can be used in an if statement as:

!!if "{Sequence}"="1"%%!stack {H:Title}{H:Logo} stack!%%!stack {H:Logo}{H:Title} stack!!!

The above statement, based on Sequence block value will display Title first then followed by Logo or Logo first followed by Title.

NOTE: The H: is very important here to indicate that this is not a standard block but a block that will be repeated Horizontally.

V: option for vertical stacking is still in the works. (!stack {V:LogoBlock}{V:TextBlock} stack!)

Please note that mixing H: and V: in the same !stack statement is not allowed.

Addition Status command of the block containing the !stack command

Status Command

Description

stackblockspacing

Spacing between the laid-out blocks. Default: 0.0

stackrepeatspacing

Spacing between repeating block groups

stackoption

all: repeat all blocks in a sequence or stop (default)
 any: repeat until space is full even when not all blocks are printed

stackalign

left (default)

center

right

stackrepeat

Number of times to repeat sequence.

0 or yes for automatic

1 or no for once

2 or more – fixed number loops (within area)

stackfontsize

Font size used when printing text (if not supplied, the size is taken from the Text block

stackfontname

Font name used when printing text (if not supplied, the fontname is taken from the Text block

stackfontcolor

Color entry
 1. hex value like #FF0000

2. Pdf color like cmyk 0 1 1 0

stackfontbold

true false

stackfontitalic

true false

stackfontunderline

true false

stackfontposition

Change the starting height of text. Default 0.0

stackfitmethod

Sets the fit method for image, graphics and pdf blocks. Default value is ‘meet’

stackcolorize

Colorize repeating Image to single color

  1. grayscale (or greyscale)
  2. Hex color - #FF0000

stackborder

Border line width – if specified a border will be drawn surrounding the paragraph (debug purposes)

 

 

 

IMPORTANT NOTE:

All fonts must be defined and loaded before running.

For 'Bold' and 'Italic' Font Styles:

While automatic generation is possible, it's better to use separate font files for each style. We will add -bold, -italic, or -bolditalic to the font name provided. All font files are likely needed for uploading to our servers.

Example:

Arial:Arial.ttf;Arial-Bold:Arialbd.ttf;Arial-Italic:Arialit.ttf;

For a large quantity of fonts, it is recommended to use loadfonts attribute in the status command of the repeating Text block:

Loadfonts= " Arial:Arial.ttf;Arial-Bold:Arialbd.ttf;Arial-Italic:Arialit.ttf; "

 

'Colorize' Feature in Repeating Image:

  1. Default (empty) - Uses original image.
  2. ‘grayscale’ - Transforms image into grayscale.
  3. Hex Color - Changes image to a solid color specified by a hex code, e.g., #FF0000 for red. This color can differ from the text color.

 

Repeat Style Adjustment:

A new option, 'stackoption' (currently not public), is added to ensure the print completeness of repeating elements. It has two settings:

  • 'all': Ensures full repetition, e.g., Logo-Text Logo-Text Logo-Text Logo-Text
  • 'any': Allows for partial repetition, e.g., Logo-Text Logo-Text Logo-Text Logo-Text Logo

 

 

 

Other Notes:

Except for stackborder, all other status commands can have {block name} as their value. This will open them for user input.

 

Status line Example ({Stack Option}, {Stack Block Spacing} and {Stack Repeat Spacing} are three text blocks):

stackoption={Stack Option}
stackblockspacing={Stack Block Spacing}
 stackrepeatspacing={Stack Repeat Spacing}

Examples:

stackoption=all stackblockspacing=32 stackrepeatspacing=32

 

stackoption=any stackblockspacing=32 stackrepeatspacing=32

 

stackblockspacing=80 stackrepeatspacing=80

 

 

Stacked Blocks

It is recommended to set the blocks width to as wide as possible (when stacking horizontally, or as tall as possible when stacking vertically). The height (or width for stacking vertically) must be equal or less than the dimension of the bounding (paragraph) block.

A grey and black line

Description automatically generated with medium confidence

 

 

 

‘textline’ and ‘textflow’

PDFLib treats textline and textflow differently. It is recommended to not use text with pdflib <commands> so that it will be treated as ‘textline’.

The type of the block whether textline or textflow does not matter. It will be determined based on text content.

The text blocks are always assumed to be textline unless the text contains a pdflib command that starts with < and ends with >, in which case they are considered as textflow.

 

When using textline, the font size is to be set to a high value; the application will shrink it to a fitting size. The text is not bound by the height of the block (for Horizontal stacking).

 

Textflow blocks will be bound by their own block dimensions and will wrap when necessary. It is recommended, in this case, to set the set size to a value that makes the text fit.

Example: prefix with <fontname={Arial} encoding=winansi fontsize=6>

 

Most of the block settings are not taken into consideration except:
Dimensions
Font
 Font Size

Which can still be overwritten by status command switches.

 

 

Stackfontcolor values:

hex color                               stackfontcolor=#F00000
cmyk                                      stackfontcolor="cmyk 0 1 1 0"

rgb                                          stackfontcolor="rgb 0 1 1"

gray                                        stackfontcolor="gray 0"

block                                      stackfontcolor={Color Block}

 

The value of {Color Block} must be one of the accepted values. Quotes are not required in this case neither the curly braces {} when retrieving the value from the color block.

 

Spacing values:

Spacing values are in pdf points (72 = 1 inch)

Available Spacings:

  1. stackblockspacing
  2. stackrepeatspacing

 

A close up of a ball

Description automatically generated

 

The stackrepeatspacing can be set to ‘auto’ in which case the server will calculate the spacing automatically based on the following:

(Maximum Allowed Width - Actual Width of Blocks (including spacing) * 'Repeat Count') divided by ('Repeat Count' - 1).

Please note that while ‘auto’ can be acceptable for unspecified repeat numbers, it is not as useful when the repeat number is fixed. 


IMPORTANT NOTE: THE SIZE OF THE IMAGE BLOCK IS TAKEN INTO ACCOUNT FOR CALCULATING THE IMAGE SIZE

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article