Printable Search Results

From CollectiveAccess Documentation
Jump to: navigation, search

[Valid for v1.4]

Printable Search Results Setup

CollectiveAccess can download or print search results based on configurable templates. You can create templates by editing a configuration file: find_results_download.conf and writing the corresponding PHP template.

PDF back-end: html2pdf

As a backend, CA is using the library of html2pdf

The configuration file find_results_download.conf

The configuration offers the possibility to create definitions for all objects or specifically for several object types like ca_objects.

A typical configuration definition looks like this:

all_tables = {
	"_pdf" =
		{
			"name" = "PDF (Chart)",
			"script_to_render" = "<tablename>_pdf_results_html.php",
			"filename" = "export_results.pdf",
			"orientation" = "L",
			"page_format" = "letter",
			"language" = "en",
			"font" = "dejavusans"
		},
	"_pdfthumb" = 
		{
			"name" = "PDF (Thumbnails)",
			"script_to_render" = "<tablename>_pdf_results_thumb_html.php",
			"filename" = "thumb_results.pdf",
			"orientation" = "L",
			"page_format" = "letter",
			"language" = "en",
			"font" = "dejavusans"
		},
	"_pdf_artform" =
		{
			"name" = "PDF (ArtForm)",
			"script_to_render" = "<tablename>_pdf_results_artform_html.php",
			"filename" = "artform_results.pdf",
			"orientation" = "P",
			"page_format" = "letter",
			"language" = "en",
			"font" = "dejavusans"
		},
	"_pdf_condition" =
		{
			"name" = "PDF (Condition Report)",
			"script_to_render" = "<tablename>_pdf_results_condition_html.php",
			"filename" = "condition_report.pdf",
			"orientation" = "L",
			"page_format" = "letter",
			"language" = "en",
			"font" = "dejavusans"
		}
	}
ca_objects = {
}

For each template the following parameters are defined:

Parameter Description
key The key is used for internal identification and must be unique. Every key identifies one print layout.

Each key can have following sub-values:

Parameter Description Example values
name Name of template; is displayed in the print list in CA. test_template
script_to_render The path to the PHP script to render the results. The base path to the script is views/find/Results in the current themes folder, e.g. providence/themes/default/views/find/Results. The path can use the wildcard <tablename> to choose different templates based on the table.

<tablename>_test.php (could result in ca_objects_test.php)

filename The name of the downloaded file. result.pdf
orientation The orientation of the downloaded document L or P
page_format The format of the downloaded document letter, A4
language The format of the downloaded document en
font The default font of the downloaded document. The font can be changed within the document by using CSS styling dejavusans

html2pdf introduction

A detailed description of the HTML2PDF lib can be found in the developers wiki.

   <?PHP
      // get the list of results from CA
      $vo_result = $this->getVar('result');
      //jump to the first result
      $vo_result->seek(0);

      //iterate through all results
      while($vo_result->nextHit()) 
      {
         //load current result
         $vn_object_id = $vo_result->get('object_id');
         $t_object = new ca_objects($vn_object_id);

         //start new page
         echo "<page>";
         //print preferred label
         echo $t_object->get("ca_objects.preferred_labels");
         //finish page
         echo "</page>";
      }

sphinx

Namespaces

Variants
Actions
Navigation
Tools
User
Personal tools