I’m trying to embed a pdf document in a wordpress post using
<iframe src="https://path.to/my.pdf" height="900" width="1200"></iframe>
The embedded document shows up in the preview while editing when using the visual editor, but it doesn’t show up when I publish the post.
Also, when I open the post for re-editing, the <iframe>
block is missing.
Following the answers here I also tried using <embed>
and <object>
, the result is the same.
Am I doing something wrong?
2
Answers
Your code would normally work, but there are code restrictions on wordpress.com for security reasons:
There are plugins that you can use to embed (see e.g. pdf embedder), but you need the Business plan to be able to install plugins.
I'm not sure there are free workarounds.
According to this official wordpress.com documentation there is a oembed feature enabled for any plan.
Embedding a PDF File
So embedding is done by simply pasting your file url to your content.
(similar to the auto embed feature for youtube urls).
As Brad noted
(Even though integrated pdf support is really decent – pretty much any chromium, webkit or Firefox)
You should also provide a simple file link opening/downloading your pdf in a new tab. This way, you will also get a better reading experience as your pdf viewport isn’t reduced by any layout margins.
Edit:
I can confirm, this embedding method is working as described – also on a free wordpress.com plan.