Why I cannot preview but only download pdf file?
Asked by Nicolas Casel:

In a wiki page, when I click on a link to a PDF file, the preview is not working:

pdf-preview.png

However, **I can download the PDF file** and it is available in the page attachments list.

Any idea about how to restore the preview?  
[](https://community.atlassian.com/t5/Confluence-questions/Why-I-cannot-preview-but-only-download-pdf-file/qaq-p/444983?attachment-id=4209){#link_1186cf66f4b8a9}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/75320/1/image2016-6-6%2018%3A4%3A13.png){#display_1186cf66f4b8a9_0}  
[](https://community.atlassian.com/t5/Confluence-questions/Why-I-cannot-preview-but-only-download-pdf-file/qaq-p/444983?attachment-id=4210){#link_1186cf66f4b8a9_0}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/75320/2/pdf-preview.png){#display_1186cf66f4b8a9_2}  
[](https://community.atlassian.com/t5/Confluence-questions/Why-I-cannot-preview-but-only-download-pdf-file/qaq-p/444983?attachment-id=4211){#link_1186cf66f4b8a9_1}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/75320/3/image2016-6-4%206%3A21%3A37.png){#display_1186cf66f4b8a9_4}  
[](https://community.atlassian.com/t5/Confluence-questions/Why-I-cannot-preview-but-only-download-pdf-file/qaq-p/444983?attachment-id=4212){#link_1186cf66f4b8a9_2}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/75320/4/pdf-text.png){#display_1186cf66f4b8a9_6}  
[](https://community.atlassian.com/t5/Confluence-questions/Why-I-cannot-preview-but-only-download-pdf-file/qaq-p/444983?attachment-id=4213){#link_1186cf66f4b8a9_3}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/75320/5/image2016-6-6%2018%3A3%3A2.png){#display_1186cf66f4b8a9_8}  
[](https://community.atlassian.com/t5/Confluence-questions/Why-I-cannot-preview-but-only-download-pdf-file/qaq-p/444983?attachment-id=4214){#link_1186cf66f4b8a9_4}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/75320/6/image2016-6-4%206%3A23%3A13.png){#display_1186cf66f4b8a9_10}  
[](https://community.atlassian.com/t5/Confluence-questions/Why-I-cannot-preview-but-only-download-pdf-file/qaq-p/444983?attachment-id=4215){#link_1186cf66f4b8a9_5}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/75320/7/image2016-6-4%206%3A22%3A39.png){#display_1186cf66f4b8a9_12}  
[](https://community.atlassian.com/t5/Confluence-questions/Why-I-cannot-preview-but-only-download-pdf-file/qaq-p/444983?attachment-id=4216){#link_1186cf66f4b8a9_6}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/75320/8/image2016-6-4%206%3A16%3A57.png){#display_1186cf66f4b8a9_14}


Answers:
author: Damien Braz
body: Hi Nicolas,

[Here is Confluence Doc:](https://confluence.atlassian.com/confkb/unable-to-preview-attachments-using-the-new-file-preview-in-a-page-after-upgrade-to-5-7-and-later-versions-715132830.html)

Observed issues are with PDF type attachments, JPEG and PNG images

The following appears in the `atlassian-confluence.log`

```
2015-02-17 07:48:56,813 ERROR [conversion-thread-3-internal] [conversion.impl.runnable.ConversionRunnable] doWork Format cannot be converted -- referer: http://testserver:8090/display/TS/Incident+and+Problemmanagement?preview=/17663912/17795772/How%20To%20Code%20In%20Java.pdf | url: /rest/documentConversion/0.1/conversion/convert/17795772/1 | userName: tester
```

Diagnosis {#toc-hId-1705661601}
-------------------------------

1. A newly inserted attachments can be previewed by clicking on its link.
2. The file itself is downloadable

**Diagnostic Steps**

* Try to replicate this in all browsers
  1. Navigate to an existing page that has PDF Attachment link embedded
  2. Click on the PDF link
* [Generate a HAR file](https://confluence.atlassian.com/kb/generating-har-files-and-analysing-web-requests-720420612.html) and check when clicking on the old attachment link. Instead of getting the 'Resource', a 'HEAD' is returned when the command "byAttachmentIds" and "minusAttachmentIds" are sent

<!-- -->

* Run the following SQL query:
  * If there are rows returned, please continue to the Resolution section. If it returns empty result, you are not being affected by the issue in this article. Please contact Atlassian Support to assist you.  

```
SELECT * FROM CONTENTPROPERTIES WHERE PROPERTYNAME = 'MEDIA_TYPE' AND STRINGVAL LIKE '%pdf%';SELECT * FROM CONTENTPROPERTIES WHERE PROPERTYNAME = 'MEDIA_TYPE' AND STRINGVAL LIKE '%pjpeg%';SELECT * FROM CONTENTPROPERTIES WHERE PROPERTYNAME = 'MEDIA_TYPE' AND STRINGVAL LIKE '%x-png%';
```

Cause {#toc-hId--846495360}
---------------------------

The Content Type of the attachments are wrong

* PDF Attachment **is** **not** '`application/pdf`' as how it should be, instead the Content Type is either in one of this format; 'pdf', '`image/pdf`' or '`application/x-pdf`'.
* JPEG images **is** **not** 'image/jpeg' as how it should be, instead the Content Type is either in one of this format; 'image/pjpeg'.
* PNG images **is** **not** 'image/png' as how it should be, instead the Content Type is either in one of this format; 'image/x-png'.

These values are already invalid before performing the upgrade.

For more information please refer to [![](https://jira.atlassian.com/secure/viewavatar?size=xsmall&avatarId=51493&avatarType=issuetype)CONF-36666](https://jira.atlassian.com/browse/CONF-36666?src=confmacro) - Unable to Preview PDF Attachment Link Due to Wrong MEDIA_TYPE After Upgrade RESOLVED .

Resolution {#toc-hId-896314975}
-------------------------------

Run the following SQL query:

* For issues with PDF:

  ```
  UPDATE contentproperties SET STRINGVAL = 'application/pdf' WHERE PROPERTYNAME = 'MEDIA_TYPE' AND STRINGVAL LIKE '%pdf%';
  ```

* For issues with JPEG images:

  ```
  UPDATE contentproperties SET stringval = replace(stringval, 'image/pjpeg', 'image/jpeg') WHERE PROPERTYNAME = 'MEDIA_TYPE';
  ```

* For issues with PNG images:

  ```
  UPDATE contentproperties SET stringval = replace(stringval, 'image/x-png', 'image/png') WHERE PROPERTYNAME = 'MEDIA_TYPE';
  ```

<!-- -->

* Flush your Confluence caches by navigating through **Confluence Administration Panel \>\> Cache Management \>\> Flush All**.

Best Regards, Damien.


author: TimC
body: Hmmm... just ran into this error in the Cloud instance of Confluence for PNG images that were working fine, but after I did an in-place update to one image ("Edit with... Preview (the Mac App). Make a change. Save. Update Confluence. See it on the page. Click PNG to see it larger... and boom. Error.

In fact, now all images on the page are not preview capable and must download. That's crappy.

I'm certainly not able to run SQL to check the DB for Cloud Confluence... and all steps I did were above...nothing crazy.

**My Answer: Atlassian** needs to review the process with us to **find the regression bug** that's causing the problem and **fix Confluence.**

comments: author: genevievecory
body: Same issue, also in a Cloud Confluence. I don't know who changed what but it's everywhere.


author: samuelcenaokediji
body: I experience this same issue myself.


author: Robert Ortner
body: try a different browser

comments: author: Nicolas Casel
body: Same result on IE, FF and Chrome.


author: Rodney Hughes
body: apart from checking the file type itself, I think it is MUCH simpler than all that....

in edit mode of the page, as you hover your mouse over the link text, you will see it gives a pop up that says "show as thumbnail" - that toggles to "show as link"

comments: author: Nicolas Casel
body: I do not want to display the file 'thumbnail' but some text (pdf file name let's say).

By the way, this workaround does not work, the thumbnail is empty and clicking on it displays the same "error" message.


author: Rodney Hughes
body: it should work - contact your system admin?!?!?! - here is a test page on our system with two PDF tests

image2016-6-4 6:16:57.png


author: Rodney Hughes
body: and here is another "interactive" PDF page using "Insert\>Other Macros\> PDF you can click the arrows at the bottom to move through the PDF :smile: or click the download button bottom left

image2016-6-4 6:21:37.png

image2016-6-4 6:23:13.png


author: Nicolas Casel
body: Thanks @Rodney Hughes

However, the PDF macro displays the content of the PDF file (like your 2nd screenshot), and in my case I want to display a link like this:

pdf-text.png


author: Rodney Hughes
body: when you insert a link to a file (not the interactive PDF macro), you can choose whether to display the file as a link or as a thumbnail

In the Edit mode, if it is showing as a thumbnail, just click or hover the mouse over the thumbnail and a pop up box will appear which toggles as below

image2016-6-6 18:3:2.png

image2016-6-6 18:4:13.png


author: Nicolas Casel
body: Ok, but as I've already written above:
> the thumbnail is empty and clicking on it displays the same "error" message.


author: Rodney Hughes
body: try another PDF - you may have a corrupt file format


Tags: attachment

pdf

preview