Home > Mobile >  how can I embed a pdf in a wordpress.com post? why do <iframe>,<embed>, <object> n
how can I embed a pdf in a wordpress.com post? why do <iframe>,<embed>, <object> n

Time:11-02

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?

CodePudding user response:

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.

CodePudding user response:

According to this official wordpress.com documentation there should be an oembed feature enabled for any plan.
Embedding a PDF File

So embedding would be done by simply pasting your file url to your content.
(similar to the auto embed feature for youtube urls).
Not sure, you're restricted to pdf files uploaded to your own library.

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.

Can somebody confirm, this feature is working as described in the doc?

  • Related