Knowledge Base

Include content from a PDF file on a page

Last Modified:
14 Jan 2019
User Level:
Power User

Description

This tag, type="pdfdoc" is added to a Content Layout. It takes a given file element, checks to see if it is a PDF document and uses the "output" attribute to determine how the PDF should appear on the published page.

Potential usage scenarios

  1. Display a PDF within an iframe on a Content Item.
  2. Allow the content of the PDF to be extracted and published on a page so that it can be used for search indexing.

Content Type

Create a content type with a file element (not a media element). Add the tag to a Content Layout. Create content using the Content Type and publish. There are three options for the tag.

Embed

The "embed" option will upload the file in the normal way, output code pointing at the uploaded file, embedding the file on the published page. The PDF file can be viewed in a PDF reader like Adobe reader. If no reader is installed in the browser, a link to the PDF will be provided instead. This publishes the PDF document in the same directory as the published page.

<t4 type="pdfdoc" output="embed" name="file-element-name" />

<iframe height="100%" width="98%" frameborder="0" src="/include-content-from-a-pdf-file/sample.pdf" align="center"><a href="/include-content-from-a-pdf-file/sample.pdf">sample.pdf</a></iframe>

Hidden - with the file

The "hidden-file" option will read the contents of the PDF document and then output it inside a hidden div on the published page. This publishes the PDF document in the same directory as the published page.

<t4 type="pdfdoc" output="hidden-file" name="file-element-name" />

<div class="hidden-div" style="display:none;">Content from PDF Document</div>

Hidden - without the file

The "hidden-no-file" option will read the contents of the PDF document and then output it inside a hidden div on the published page. This does not publish the PDF document.

<t4 type="pdfdoc" output="hidden-no-file" name="file-element-name" />

<div class="hidden-div" style="display:none;">Content from PDF Document</div>

Notes

  1. If the file is not a PDF document nothing will be output.
  2. The element referenced must be a file content element.
  3. The tag can only be used in Content Layout.
  4. If hidden-no-file is used in conjunction with either embed or hidden-file then the option will be overridden and the PDF document will be published in same directory as the published page.
  5. If both embed and either hidden-file or hidden-no-file are specified, the PDF will be both embedded on the page and added to a hidden div.
  6. If both hidden-file and hidden-no-file are specified, the PDF will be both embedded on the page and added to a hidden div.
  7. The iFrame created is a set width and can't be changed.
  8. The div created can't be changed unless css is used to set it to be displayed.
  9. The line breaks from PDF file are ignored when published on the page.