I am using the Entity PDF plugin in Drupal 8, that does a good job in exporting to PDF nodes, but seems to exclude other scenarios such as Search Result list.

Anyone can provide some hints how would a PDF export be implemented for search results?

1 Answer 1


You can use hook_entity_view_alter() to hidden PDF export link. Sample


use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;

function examples_entity_view_alter(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
  $type = $entity->getType();
  $mode = $display->getMode();
  //Replace node type with text **page**
  if ($type == 'page' && $mode == 'search_result') {
  • Actually I did not want to hide, but create a HTML template that would later be pushed to the PDF generator. THe hooks helps in locating a section to place a link...
    – Al-Punk
    Aug 30, 2016 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.