• Saltar a la navegación principal
  • Saltar al contenido principal
  • Saltar al pie de página
labarta

Labarta

  • Blog
  • Vídeos Docker
  • Vídeos entrevistas
  • Dominios
  • Hosting
  • Quién soy

Cómo mostrar archivos PDF y otros en WordPress

05/11/2019

pdf

 

Cómo mostrar archivos PDF y otros en WordPress

Para mostrar los archivos doc, docx, pdf, pptx, txt, xlxs,  etc... en WordPress el código que hay que poner en HTML es el siguiente:

 

<iframe style="width: 70%; height: 400px; border: none;" src="https://docs.google.com/gview?embedded=true&amp;url=https://labarta.es/wp-content/uploads/2019/08/CSS-3-Cheat-Sheet.pdf"></iframe>

<iframe style="width: 70%; height: 400px; border: none;" src="https://docs.google.com/viewer?embedded=true&amp;url=https://labarta.es/wp-content/uploads/2019/08/CSS-3-Cheat-Sheet.pdf"></iframe>

El texto en rojo es el que debes sustituir por tu URL del documento.

La única diferencia entre estas dos versiones de iframe está en que en la primera se usa "gview" y en la segunda "viewer", las dos de momento funcionan igual.

Puedes usar una de las dos y te sirve para cualquier tipo de documento: doc, docx, pdf, pptx, txt, xlxs,  etc...

También puedes cambiar los valores  "width"  y  "height"  para que se adapten mejor a tu página y si quieres poner un marco cambia "border:none;"  por  "border:solid;". 

 

 

Si no puedes ver los documentos es posible que la carpeta donde los tengas guardados no sea accesible al público en general.

La carpeta "uploads" de WordPress  en algunos casos tiene su acceso protegido.

Puedes crear una nueva carpeta y darle los permisos de lectura necesarios.

 

Pero una muy buena opción es subir tus documentos a "Google Drive" y con el ID del enlace de compartir crear tu propia iframe.

Obtienes la url para compartir en este ejemplo:  https://drive.google.com/open?id=1GEMY4QAUOsGunCKz8eP9fTsor-TIedqS

y copias en esta iframe solo la ID.

Aquí tienes un ejemplo:

 

<iframe src="https://drive.google.com/file/d/....aquí..../preview" width="100%" height="400px"></iframe>

<iframe src="https://drive.google.com/file/d/1GEMY4QAUOsGunCKz8eP9fTsor-TIedqS/preview" width="100%" height="400"></iframe>

 

 

Y lo mejor de hacerlo de esta forma es que te evitas sobrecargar tu sitio web, en este caso el pdf es de 4,29 Mb. (pero imagina un pdf de 500 páginas o más).


Si te ha gustado este artículo, por favor, comparte - Gracias -


Blog,  Código

  • Todas las entradas
  • Github
  • Meetup WordPress
  • Política de cookies

Footer

GINERNET - Servidor VPS

Ginernet

GeneratePress - Tema WordPress

GeneratePress

GINERNET - Hosting WordPress

Ginernet2

OnlyOffice - Online Office

Usamos ONLYOFFICE Online Office

Copyright © 2025 · Labarta - Powered by : Labarta

Usamos cookies en nuestro sitio web para brindarle la experiencia más relevante recordando sus preferencias y visitas repetidas. Al hacer clic en “Aceptar todo”, acepta el uso de todas las cookies. Sin embargo, puede visitar "Configuración cookies" para proporcionar un consentimiento controlado.
Configuración cookiesAceptar todo
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Siempre activado
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDuraciónDescripción
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
GUARDAR Y ACEPTAR