Nov 25, 2015

Dynamic PDF creation using DOCX templates

When creating PDF files from DOCX or PPTX files CloudConvert can now dynamically change the content. This feature makes it more convenient to create invoices or mass letters dynamically. Technically you set up a DOCX template with placeholders (for example ${name}). While converting the DOCX file to PDF CloudConvert can replace these placeholders with custom values. This even works for tables with a variable amount of rows as the following example shows.

undefined


The shown PDF was created using the DOCX template file and these few lines of PHP code:

$api->convert([
    "input" => "upload",
    "inputformat" => "docx",
    "outputformat" => "pdf",
    "converteroptions" => [
       "templating" => [
          "name" => "John Smith",
          "address" => "Smithstreet 1",
          "city" => "Smithtown",
          "zip" => "10101",
          "country" => "US",
          "comment" => "Thanks for your business!",
          "date" => "2015-11-24",
          "total" => "160",
          "items" => [
            ["description" => "Nameless product", "price" => "10", "quantity" => "2", "total" => "20"],
            ["description" => "Other product", "price" => "100", "quantity" => "1", "total" => "100"],
            ["description" => "Stuff", "price" => "2", "quantity" => "20", "total" => "40"],
            ],
        ],
    ],
    "file" => fopen('template.docx', 'r'),
])

Checkout the full Syntax for the placeholders of the new templating feature.

We think this feature is a great step to make CloudConvert even more powerful and we hope you like it!


Nov 25, 2015

Syntax for the DOCX / PPTX templating feature

The syntax is highly inspired by Mustache. The template is created in Microsoft Word/PowerPoint or any equivalent that saves to DOCX/PPTX. Also checkout this example of using the templating feature.

Synopsis

A typical DOCX template:

Hello {name} !

Given the following value for the templating JSON dictionary:

{ name:'Edgar'}

Will produce:

Hello Edgar !

Tag types

Like Mustache, it has the loopopening {#} and loopclosing {/} brackets

Loop syntax

The following template:

{#products}
    {name}, {price} €
{/products}

Given the following JSON dictionary:

{
    "products":
        [
         {name:"Windows",price:100},
         {name:"Mac OSX",price:200},
         {name:"Ubuntu",price:0}
        ]
}

will result in :

Windows, 100 €
Mac OSX, 200 €
Ubuntu, 0 €

The loop behaves in the following way:

  • If the value is an array, it will loop over all the elements of that array.
  • If the value is a boolean, it will loop once if the value is true, keeping the same scope, and not loop at all if the value is false

Note: Because the loops work also with boolean values, you can also use them for conditions.


Raw XML syntax

Sometimes, you would like to insert your custom XML (a complex table, a formula, ...)

With the RawXML syntax the variable is interpreted as XML and replaced in the formula

{@rawXML}

with this data:

{rawXml:'<w:p><w:pPr><w:rPr><w:color w:val="FF0000"/></w:rPr></w:pPr><w:r><w:rPr><w:color w:val="FF0000"/></w:rPr><w:t>My custom</w:t></w:r><w:r><w:rPr><w:color w:val="00FF00"/></w:rPr><w:t>XML</w:t></w:r></w:p>'}

This will loop over the first parent tag

Inverted Selections

An inverted section begins with a caret (hat) and ends with a slash. That is {^person} begins a "person" inverted section while {/person} ends it.

While sections can be used to render text one or more times based on the value of the key, inverted sections may render text once based on the inverse value of the key. That is, they will be rendered if the key doesn't exist, is false, or is an empty list.

Template:

{#repo}
  <b>{name}</b>
{/repo}
{^repo}
  No repos 🙁
{/repo}

Value for the templating JSON dictionary:

{
  "repo": []
}

Output:

No repos :(

Oct 8, 2015

Even more flexible payment models

We think in times of cloud computing you cannot categorize payments in fixed packages. We do not want to force our customers in buying or subscribing for 1000, 5000, or 10000 conversion minutes. From now on our customers can completely customize their prepaid packages and subscriptions and scale them according to their needs. If you want to subscribe for monthly 2222 conversion minutes, you can do so! Checkout our pricing site with the new sliders for your personal customization.


Aug 24, 2015

Folder Monitoring for Google Drive and Dropbox

We are happy to announce another awesome CloudConvert enhancement! CloudConvert Folder Monitoring is a powerful feature to make your workflow even more efficient. You can set up special folders in your Google Drive or Dropbox account as Triggers. Every time you add a file to this folder it is automatically converted to a chosen output format with your customized options.

There are uncountable cool use cases for this feature:

  • Convert any added file type in a folder to PDF
  • Automatically encode added videos with a specific codec and settings
  • Automatically resize added JPGs to a fixed size
  • Automatically encrypt added PDFs with a password
  • ...

Folder Monitoring is available as Beta feature for our paying users (prepaid package or subscription), starting today!

undefined



Aug 6, 2015

Billing enhancement: Auto refill packages

There is a great simplification for our long-term customers, especially our API users: By buying a prepaid package, you can now select the new "Auto Refill" option. This option makes sure the package is automatically refilled, if your quota of conversion minutes is used up to 95%.

If you have set up this once, you won't need to worry any more about your account is running out of quota and your API implementations might stop working.  We hope you like it!

 


May 26, 2015

CloudConvert on the command line

Wouldn't it be awesome if you could do

cloudconvert -f pdf *.docx

to convert all DOCX files in the current folder to PDF?

Now you can do so! We just released the official CloudConvert CLI. Checkout the full documentation for more examples and how to install it on your machine.