How to Use Doctron for Document Conversions

Feb 27, 2024 | Programming

Welcome to the world of Doctron, a powerful and versatile document conversion tool. In this article, we will guide you through the ins and outs of using Doctron effectively.

Doctron Description

Doctron is a Docker-powered, serverless, sample, fast, and high-quality document conversion tool. It enables you to convert HTML to PDF and images using the Chromium kernel, add watermarks to PDFs, and more!

Online Experience

For a quick test drive, visit the Doctron Live Demo. Note that performance may vary based on the server configuration.

Features

  • Seamless HTML to PDF/image conversion using the Chrome kernel.
  • Easy deployment with Docker or Kubernetes.
  • Customizable page size for generated PDFs and images.
  • Support for a rich set of transformation parameters.

Installing Doctron

To install Doctron on your system, follow these steps:

  • Using Docker
    • Default Configuration:
      docker run -p 8080:8080 --rm --name doctron-alpine lampnick/doctron
    • Custom Configuration:
      docker run -p 8080:8080 --rm --name doctron-alpine -v pathtodoctronconf/doctron.yaml:doctron.yaml lampnick/doctron
  • Using Kubernetes:
    kubectl apply -f https://raw.githubusercontent.com/lampnick/doctron/master/manifests/k8s-doctron.yaml
  • From Source Code:
    1. Download Google Chrome and add its path to your system PATH.
    2. Clone the repository and run the main file:
      git clone https://github.com/lampnick/doctron.git
      cd doctrons
      go run main.go --config=.conf.default.yaml

Quick Start with Doctron

Once installed, you can start using it for various conversions!

HTML to PDF Conversion

To convert an HTML page to a PDF, you can use the following requests:

  • Basic:
    http://127.0.0.1:8080/converthtml2pdf?u=doctron&p=lampnick&url=url
  • Custom Size:
    http://127.0.0.1:8080/converthtml2pdf?u=doctron&p=lampnick&url=url&marginTop=0&marginLeft=0&marginRight=0&marginBottom=0&paperWidth=4.1

HTML to Image Conversion

Similarly, you can convert HTML to images:

  • Basic:
    http://127.0.0.1:8080/converthtml2image?u=doctron&p=lampnick&url=url
  • Custom Size:
    http://127.0.0.1:8080/converthtml2image?u=doctron&p=lampnick&url=url&customClip=true&clipX=0&clipY=0&clipWidth=400&clipHeight=1500&clipScale=2&format=jpeg&quality=80

PDF Watermark Addition

You can also add watermarks to your PDFs:

  • Add Image Watermark:
    http://127.0.0.1:8080/convertpdfAddWatermark?u=doctron&p=lampnick&url=pdf_url&imageUrl=image_url

Troubleshooting

If you encounter any issues while using Doctron, consider the following troubleshooting tips:

  • Always ensure the Docker service is running smoothly.
  • Check your internet connection if working with online demos.
  • Verify that the provided URLs for HTML and images are accurate and publicly accessible.
  • Seamless integration may require adjusting firewall settings for network communications.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Final Thoughts

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox