Linux: convertir PNG a PDF con Tesseract

Convierte capturas PNG a PDF en Linux con OCR usando Tesseract y Pandoc: guía de instalación, comandos básicos y un script rápido para extraer texto y generar PDFs.

18 sept 2025 • 3 min read • Q2BSTUDIO Team

Inteligencia-Artificial-

Convertir capturas PNG a PDF en Linux con OCR es sencillo y útil cuando se necesita extraer texto de imágenes. Este artículo explica los pasos básicos usando tesseract para OCR y pandoc para generar el PDF. Nota importante: las pruebas se han realizado con archivos png.

Qué necesitas instalar En la máquina deben estar instalados los programas tesseract y pandoc. Para salida en PDF puede ser necesario instalar pandoc-pdf o weasyprint. El paquete pandoc-pdf incluye la colección TeXLive necesaria para que pandoc genere PDF con pdflatex. Si prefieres usar xelatex o lualatex instala texlive-collection-xetex o texlive-collection-luatex respectivamente.

Qué es tesseract Tesseract es un motor OCR de calidad comercial desarrollado originalmente por HP entre 1985 y 1995 y liberado como código abierto en 2005. Soporta muchos idiomas y permite convertir imágenes en texto legible.

Qué es pandoc Pandoc es una herramienta de línea de comandos que convierte entre formatos de marcado. Con pandoc y los paquetes adecuados puedes pasar de texto plano a PDF sin esfuerzo.

Comprobaciones y comandos básicos Verifica si están instalados con which tesseract y which pandoc. En Fedora ambos están en los repositorios. Para instalar en Fedora usa sudo dnf install tesseract pandoc y, si quieres generar PDF directamente, instala pandoc-pdf o weasyprint. Ejemplos de uso sencillo tesseract imagen.png stdout -l deu > texto.txt pandoc texto.txt -o salida.pdf rm texto.txt Si prefieres encadenar: tesseract imagen.png stdout -l deu | pandoc -o salida.pdf Ten en cuenta que pandoc para PDF requiere las dependencias de TeX o los convertidores que hayas instalado.

Consejos sobre repositorios en Fedora Para comprobar el repositorio de actualizaciones revisa el contenido de /etc/yum.repos.d y busca el archivo fedora-updates.repo. Normalmente ese repositorio se configura durante la instalación del sistema.

Ejemplo de script sencillo en bash para automatizar el proceso Un script breve que solicita la ruta y el nombre del archivo y genera el PDF en la misma carpeta puede escribirse en una sola línea con sentencias separadas por punto y coma. Ejemplo simple de uso en una sola línea que puedes adaptar: #!/bin/bash; clear; echo Bienvenido al proceso de extraer texto de una captura y generar pdf; echo Introduce la ruta del archivo; read pfad; if [ -d $pfad ]; then cd $pfad; else echo Directorio no existe; exit 1; fi; echo Introduce el nombre del archivo png; read filename; if [ -f $filename ]; then tesseract $filename stdout -l deu > texto_extraido.txt; pandoc texto_extraido.txt -o resultado.pdf; rm texto_extraido.txt; echo PDF generado como resultado.pdf; else echo Archivo no existe; fi

Limitaciones y recomendaciones Tesseract funciona mejor con imágenes nítidas y texto claro. Si la imagen tiene mucho ruido o rotación, considera preprocesarla con herramientas de edición o usar filtros para mejorar contraste y limpieza. Para documentos más complejos revisa el resultado de OCR antes de generar el PDF final.

Sobre Q2BSTUDIO En Q2BSTUDIO somos una empresa de desarrollo de software y aplicaciones a medida especializada en soluciones tecnológicas integrales. Ofrecemos servicios que incluyen aplicaciones a medida y software a medida, soluciones de inteligencia artificial y proyectos de ciberseguridad y pentesting. Si buscas un socio para crear soluciones personalizadas visita nuestra página de desarrollo de aplicaciones y software a medida o explora nuestros servicios de inteligencia artificial para empresas donde trabajamos con agentes IA, IA para empresas y soluciones de automatización.

Palabras clave y servicios relacionados Para mejorar el posicionamiento este artículo incorpora conceptos relevantes como aplicaciones a medida, software a medida, inteligencia artificial, ciberseguridad, servicios cloud aws y azure, servicios inteligencia de negocio, ia para empresas, agentes IA y power bi. En Q2BSTUDIO también ofrecemos servicios en la nube para AWS y Azure, soluciones de inteligencia de negocio con Power BI y proyectos de automatización de procesos.

Si necesitas ayuda para integrar OCR en un flujo de trabajo, desarrollar una herramienta a medida que procese imágenes o desplegar una solución en la nube, contacta con Q2BSTUDIO y te ayudamos a diseñar la solución adecuada a tus necesidades.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Artificial intelligence

AI agents, chatbots, and intelligent assistants that automate tasks and serve your customers 24/7 to improve the efficiency of your business.

More info

Software Development

Web, mobile, and desktop applications, intranets, e-commerce, SaaS, and management platforms designed for your company's specific needs.

More info

Cloud services

Migration, infrastructure, managed hosting, high availability, and security on Microsoft Azure and Amazon Web Services to help your business scale without limits.

More info

Cybersecurity and pentesting

Security audits, penetration testing and protection of applications, data and infrastructure on-premise and cloud, with ethical hacking and regulatory compliance.

More info

Business Intelligence

Dashboards and data analysis with Power BI: we integrate your sources, design dashboards and KPIs and turn your data into decisions.

More info

Process automation

We automate repetitive tasks and connect your applications with n8n, Power Automate, Make, and RPA, eliminating manual work and increasing productivity.

More info

Training for Companies

We train your teams in technology with criteria: web development, databases, Git, best practices and security, automation with n8n, artificial intelligence for companies and creation of AI solutions with Azure AI Foundry.

More info

Code Auditing

We audit the code that you, your team or an AI create: we tell you what is good and what to improve, we secure it and make it ready for production, web or app.

More info

AI Image Generation

We create for you the images that your business needs with artificial intelligence: product, networks, advertising, illustration and avatars. You tell us what you want and we deliver it ready to use.

More info

AI Video Generation

We create videos with artificial intelligence for you: promotional, networking, virtual presenters, dubbing and animations. You tell us the idea and we will deliver it assembled and ready to publish.

More info

AI Conversational Avatars

We create conversational avatars with AI – digital humans with a face and voice – that serve your customers and teams with the knowledge of your company, on your website, interactive monitors, WhatsApp or Teams.

More info

Online Marketing and AI

Google Ads, Meta Ads, LinkedIn Ads and AI Engine Positioning (GEO/AEO): we attract customers and make your brand appear where they search for you, also on ChatGPT, Gemini and Perplexity.

More info

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.

Live Chat