If someone's likely to be challanged with the necessity to have the attached PDF document displayed on the content view page, this article will stand you in good stead. In fact, you don't need to be a cool website developer to fulfill this task. All you need to do is to insert a fragment of the code into the spot best suited for the output:
<object width="100%" height="500px" type="application/pdf" data="path_to_pdf_file" ></object>
The width and height areas should be set up in accordance to the page parameters.
<object width="100%" height="800px" type="application/pdf" data="path_to_pdf_file"> <a href="path_to_pdf_file">Download PDF file</a></object>
If PDF view plugin is not installed in the browser, display function will not be available. In order to let the user see the attached file, it's necessary to add a link to the file in the middle of the object tag and the link will only get displayed when the view is not possible.
For the output of such a region be performed it takes to write a simple module on the basis of Field API which will create new format of display for the field data type. The format choice is made in Manage Display of content type section.
We'll need 4 hooks for that:
- hook_field_formatter_info() - identifies the new format;
- hook_field_formatter_settings_form() - creates the form for setting to be done;
- hook_field_formatter_settings_summary() - the indicated settings' display;
- hook_field_formatter_view() - the field output on the content page.