PDF for GravityView Hooks – gfpdf_gv_static_map_max_height
Description
Use this filter to change or remove the maximum printed height of a map. You can set a different limit for the Multiple Entries Map widget and for maps in Multiple Entries PDF rows.
A map prints as wide as its column, and its height follows from the PDF Map Layout setting (Square, Landscape or Portrait). A Portrait map in a full-width column would be taller than the content area of an A4 page. It would get a page to itself, and the rest of the entry would move to the next page.
To prevent this, every map is limited to 120mm tall. A full-width Landscape map is already shorter than that, so the limit only affects Square and Portrait maps.
Version
This hook was introduced in PDF for GravityView 2.0.
Arguments
The following arguments are passed to functions that use this hook:
$mm | int
- The maximum height of the map, in millimeters.
- Return
0to remove the limit. Negative values are treated as0. - The default value is
120
$view | \GV\View
- The View being rendered.
$context | string
- Which PDF the map is in:
single(Single Entry PDF) ordirectory(Multiple Entries PDF).
$shape | string
- Which kind of map it is within that PDF.
row: an Entry Map field repeated down a Multiple Entries PDF.document: a map drawn once, such as an Entry Map field in a Single Entry PDF or the Multiple Entries Map widget.
Usage
Keep maps in Multiple Entries PDF rows small, so more entries fit on each page:
add_filter( 'gfpdf_gv_static_map_max_height', function( $mm, $view, $context, $shape ) {
return $shape === 'row' ? 60 : $mm;
}, 10, 4 );
Remove the limit for one View's PDFs:
add_filter( 'gfpdf_gv_static_map_max_height', function( $mm, $view ) {
return $view->ID === 885 ? 0 : $mm;
}, 10, 2 );
Source Code
This filter is located in src/Pdf/Maps/StaticMapRenderer.php of the PDF for GravityView extension.