skip to Main Content

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


  1. Chosen as BEST ANSWER

    Your code would normally work, but there are code restrictions on wordpress.com for security reasons:

    The following tags are not allowed on sites on our Premium Plan and below for security reasons:

    embed, frame, iframe, form, input, object, textarea, style, link

    These tags may be used with sites on our Business Plan with plugins installed.

    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.


  2. 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

    Keep in mind, not all browsers can even open PDFs.

    (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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search