shinu . 2 minutes
November 4, 2019

Converting Doc to PDF without breaking style.

Converting a word file to PDF with proper formatting is not easy. I tried many packages in Laravel but they all gave me broken PDFs with messed up styles.
I found an API called CloudConvert(https://cloudconvert.com/) that supports the conversion between more than 200 different audio, video, document, ebook, archive, image, spreadsheet and presentation formats. This helped me to convert the doc file to PDF format very easily without breaking any style.

It’s very easy to install and use in Laravel via composer.js

"require": {"robbiep/cloudconvert-laravel": "2.*"}

Run the composer install to download the required files.

You need to publish the config PHP artisan vendor:publish

Just enter your API key in config/cloudconvert.php
Note: You will get an API key from your CloudConvert registered profile (Dashboard -> Authorization).

Usage

There are many ways to use CloudConvert. I’ll cover a few of them here.

This will do the trick. Here, the invoice_template.docx file will get converted as invoice.pdf file.

It will also work with converting remote files (just make sure you provide a path to save it to).

Merge the PDFs

CloudConvert also helps to merge multiple files to a specific format. Right now, merging only works with remotely hosted files

Website screenshot

CloudConvert will also take a screenshot of a website and convert it into an image or pdf for you.

CloudConvert (including API) can be used absolutely free! However, free accounts have 25 only conversion minutes per day.

What is a conversion minute?

The longer a conversion takes, the more resources it consumes and the more expensive it is. Our prepaid packages are based on conversion minutes.

Every conversion takes at least one conversion minute. Normally, document or image conversions consume only one conversion minute. Video/Audio re-encodings or huge files consume more conversion minutes, depending on quality and codecs. Of course, only successful conversions are counted.

For more info and all the converter options, I suggest checking out the API docs, https://github.com/robbiepaul/cloudconvert-laravel. If you require any further support, partner up with Laravel Development Services or Hire Laravel developer to get expert solutions.

blog
Greetings! I'm Aneesh Sreedharan, CEO of 2Hats Logic Solutions. At 2Hats Logic Solutions, we are dedicated to providing technical expertise and resolving your concerns in the world of technology. Our blog page serves as a resource where we share insights and experiences, offering valuable perspectives on your queries.
Aneesh ceo
Aneesh Sreedharan
Founder & CEO, 2Hats Logic Solutions
Subscribe to our Newsletter
Arsha Contact

    Stay In The Loop!

    Subscribe to our newsletter and learn about the latest digital trends.