Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the CollectiveAccess support forum! Here the developers and community answer questions related to use of the software. Please include the following information in every new issue posted here:

  1. Version of the software that is used, along with browser and version

  2. If the issue pertains to Providence, Pawtucket or both

  3. What steps you’ve taken to try to resolve the issue

  4. Screenshots demonstrating the issue

  5. The relevant sections of your installation profile or configuration including the codes and settings defined for your local elements.

If your question pertains to data import or export, please also include:

  1. Data sample

  2. Your mapping

Answers may be delayed for posts that do not include sufficient information.

PDF Question

edited August 2016 in Pawtucket
I'm in a position where the PDF previewer doesn't occur on my providence installation. Therefore, the PDFs appear as ugly little thumbnails on the main webpage. I've attached a screenshot to show what I mean.

I'd like to find a solution where images are displayed on the left in thumbnail version, but the PDFs are displayed as clickable links since people have to click on them to download anyway. Does anyone have thoughts on this? 

My idea is to alter the media_display.conf file. 



  • Hi msjonesking,

    Does this mean you are not able to install the software components that enable you to display PDF preview thumbnails?

    If you remove the "PDF" entry under detail settings in media_display.conf, it should remove PDF media from the media viewer.  Then you can generate the PDF links separately elsewhere on the page.
  • edited August 2016
    Hi Sophie,

    Thanks, I'll look into building the PDF links.

    I tried to install and run ghostscript, but I kept hitting roadblocks since I'm on a windows environment. See here:

  • edited August 2016
    Actually, how exactly would I create a link for PDFs? I can't find any examples of this being done in the other CollectiveAccess projects I'm aware of from your website. My thought would be to use php similar to that which would produce object thumbnails below the main picture. 

    <?php print caObjectRepresentationThumbnails($this->request, $this->getVar("representation_id"), 
    $t_object, array("returnAs" => "bsCols", "linkTo" => "carousel", "bsColClasses" => "smallpadding col-sm-3 col-md-3 col-xs-4")); 


    But I also wondered if it would be possible to have an attribute field for it. 
  • You can call representationsWithMimeType() to get media of a specific mimetype, or representationsOfClass() to get media of a certain class (ie "image", "audio", "video" and "document").
  • Hi Sophie,

    I definitely appreciate the direction, but could you be a little more specific about where I would cold that in? Would it be in the beginning of the document with the definitions? (with $t_object = $this->getVar("item");
    ) or later in the document under the call for thumbnail representations? The examples I can see of representationsWithMimeType() all seem to appear at the beginning of the code.

  • representationsWithMimeType() will give you an array of representations.  You can then output them anyplace on the page that you wish (I assume on the right side with the rest of the metadata).  Use print_r() to see what information is in the array.
  • edited August 2016
    So if I have the following code in my header:

      $t_pdf = $t_object->representationsWithMimeType(array("document/pdf"), array("versions" => array(), "checkAccess" => $this->getVar("access_values")));

    And follow up with this code in the body of the object description,

    That would do the trick? 

  • Update, I tried that, but I'm just getting a spit out of "array ( )" on my page. 
  • Nevermind, I changed document to application, and now I get the following: 

    Array ( [12888] => Array ( [representation_id] => 12888 [media] => x����r�0�߅�I ����X�Qt�� �B�tD9���t|�n�9�̹�^�f����c7���}-\���|����`���f�ч�5B�v����t���� ��F?�op���` �����3L%[� �(|����U�-��3ט�3/����� �|�Q�þ�0���E�����;F9g�?Z'1���I�=f��s�8  0 [access] => 1 [status] => 0 [name] => English [locale_id] => 1 [media_metadata] => x�K�2���O� [type_id] => 106 [idno] => S10817708004.pdf [idno_sort] => S10817708004pdf [md5] => 97f649282588a2ad522c1fb60a681cdd [mimetype] => application/pdf [original_filename] => S10817708004.pdf [rank] => 12888 [relation_id] => 12866 [tags] => Array ( [preview170] => image ) [urls] => Array ( [preview170] => /support/icons/documentIcon120.jpg ) [info] => Array ( [original_filename] => S10817708004.pdf [preview170] => Array ( [MIMETYPE] => image/jpeg [USE_ICON] => document [WIDTH] => 120 [HEIGHT] => 120 ) ) [paths] => Array ( [preview170] => C:/CollectiveAccessWebsite/paw/support/icons/documentIcon120.jpg ) [dimensions] => Array ( [preview170] => 589.859985p x 786.23999p; 69 pages; 6.52mb ) [num_multifiles] => 0 [label] => [BLANK] ) )
  • You can use that information to construct a link that loads the document viewer, or allows the user to download the file directly, depending on what you want to do.
  • Hi Sophie,

    I'm trying to construct a link that allows the user to download the file directly since my document viewer isn't really operating. How would I go about constructing the link? 
  • You can make a link to the DownloadRepresentation method in the detail control, like this:

    print caNavLink($this->request, 'Download', '', 'Detail', 'DownloadRepresentation', '', array('representation_id' => $representation_id, "object_id" => $object_id, "download" => 1, "version" => "original"));

    Where you substitute in the representation and object id's.  This would download the originally uploaded file, but you can pass whatever version is appropriate.
  • Like so? 

    print caNavLink($this->request, 'Download', '', 'Detail', 'DownloadRepresentation', '', array('application/pdf' => $representation_id, "nrproperty" => $object_id, "download" => 1, "version" => "original"));

    I'm just getting a blank page. 
  • You need to substitute in the appropriate variables for $object_id and $representation_id.
  • edited August 2016
    Hi Maria,

    Just to clarify, should I be defining $representation_id and $object_id? I'm not really too sure what I'm trying to get those variables to represent. I'm not sure how to define representation id or object id. 

    I did try this: 

      $representation_id =  $this->getVar("representation_id");
      $object_id =      "nrproperty";

    but no dice. 
  • The representation id is available in the array you copied into the post you made on the 22nd.  You should be able to get the object id like this:

    $object_id = $t_object->get("ca_objects.object_id");
  • Ok, thanks, for being patient with me, Maria!

      $representation_id =  $t_object->representationsWithMimeType(array("document/pdf"), array("versions" => array(), "checkAccess" => $this->getVar("access_values")));
      $object_id = $t_object->get("ca_objects.object_id");

  • representationsWithMimeType will return an array of values, not the representation_id.  If your objects do not have multiple representations you can do this:

    $representation_id =  $this->getVar("representation_id");

    Otherwise you would need to do something like this to output a link to each pdf.  Hopefully I didn't make any typos :)

    $va_pdfs = $t_object->representationsWithMimeType(array("document/pdf"),
    array("versions" => array(), "checkAccess" =>
    foreach($va_pdfs as $vn_rep_id => $va_pdf){
         print caNavLink($this->request, 'Download', '', 'Detail',
    'DownloadRepresentation', '', array('representation_id' => $vn_rep_id, "object_id" => $t_object->get("ca_objects.object_id"), "download" => 1,
    "version" => "original"));

  • Perfect!!!!!

    Thank you so much. I did change document to application and it seems to work fine. :-) 

    $va_pdfs = $t_object->representationsWithMimeType(array("application/pdf"),
    array("versions" => array(), "checkAccess" => 
    foreach($va_pdfs as $vn_rep_id => $va_pdf){
         print caNavLink($this->request, 'Download', '', 'Detail', 
    'DownloadRepresentation', '', array('representation_id' => $vn_rep_id, "object_id" => $t_object->get("ca_objects.object_id"), "download" => 1, 
    "version" => "original"));

  • oh, good.  Sorry I copied the code from above and must have copied a typo.  Glad it's working now!
  • Yes! All good! Though I am curious about something. I changed download to read "Download the National Register File Here." But I wonder if I could substitute in a variable? I'd like the link to show the pdf caption instead of just a static text. I'm thinking of this since there are a couple cases when there might be two PDFs associated with one file. For example a nomination pdf and an extra documentation pdf. I'd like to be able for visitors to differentiate between the two. So, my thought was to create a variable to reference the field. But how would I then sandwich it in there? 

    Thanks, M
  • Add this in the foreach loop I wrote for you previously:

    $t_rep = new ca_object_representations($vn_rep_id);
    $vs_rep_label = $t_rep->get(;

    and then substitute your text with $vs_rep_label
  • $t_rep = new ca_object_representations($vn_rep_id);
    $vs_rep_label = $t_rep->get(;
    $va_pdfs = $t_object->representationsWithMimeType(array("application/pdf"),
    array("versions" => array(), "checkAccess" => 
    foreach($va_pdfs as $vn_rep_id => $va_pdf){
         print caNavLink($this->request, $vs_rep_label, '', 'Detail', 
    'DownloadRepresentation', '', array('representation_id' => $vn_rep_id, "object_id" => $t_object->get("ca_objects.object_id"), "download" => 1, 
    "version" => "original"));

    Hi Maria,

    I've been playing around with the code you gave me. Unfortunately, when I replaced the download text with the variable, I get no link at all. I've tried writing it as an array instead, but that just spits out "array"

    Any advice? I thought that maybe it could be accounted for representations that don't have captions, but I tried it with some that definitely do. 
  • edited August 2016
    Update: I was able to substitute in the $vn_rep_id, and links with the Representation IDs appeared. So I guess my issue is somehow with the captions themselves. 
    When I change the following code, I get the first object representation's (a photograph, not a pdf) label as the text. I found that interesting. 

    $vs_rep_label = $t_object->get(;

    I'm going to run an update of Pawtucket2 from github today just for general maintenance and then go back to working on this. 

    Additionally, where in the code can I insert a separator between the two pdf links? 
  • Sorry, it's a little hard to write php code blind in a text editor, replace

    $vs_rep_label = $t_rep->get(;


    $vs_rep_label = $t_rep->get("");

    You need quotes.
  • I can't believe it! I thought I'd already tried adding the quotes in! I'm not sure what was different this time, but I did move the text so that it was actually in the "foreach" this time as well. Thank you again, Maria! 

    So, my final question is, how do I add a separator between the two instances? Right now the links back up to each other in such a way that they are somewhat indistinguishable. 

  • Yes, that code has to be in the foreach loop.

    For a separator, just print something out in the foreach loop after you print the link, or wrap the link in a p tag.  For example:

    print "<p>".caNavLink(.......)."</p>";
  • Awesome! Thanks so much, Maria!
  • Hi Maria,

    I'm wondering if I can amend this code temporarily since new PDFs are being recognized by the catalog as binary files.

  • As an update, I've figured out the code to do this, but it's a temporary solution at best since the PDFs produced for download are significantly altered having gone from PDF to binary to PDF.

    <?php $va_octetstreams = $t_object->representationsWithMimeType(array("application/octet-stream"), array("versions" => array(), "checkAccess" => $this->getVar("access_values"))); foreach($va_octetstreams as $vn_rep_id => $va_octetstream){ $t_rep = new ca_object_representations($vn_rep_id); $vs_rep_label = $t_rep->get(""); print "

    ".caNavLink($this->request, $vs_rep_label, '', 'Detail', 'DownloadRepresentation', '', array('representation_id' => $vn_rep_id, "object_id" => $t_object->get("ca_objects.object_id"), "download" => 1, "version" => "original"))."

    "; } ?>
Sign In or Register to comment.