phpapipdfconverterscloudconvert

How to use CloudConvert API with PHP SDK to download a conversion as multiple files?


I'm trying to use the CloudConvert API with PHP to convert PDFs to HTML and it works but so far I can only receive the html file with all the assets (img, css, js, font) embedded within the html file. I'd like to be able to download the assets as separate files, either as a zip, or individual, and their web interface allows this but I'm struggling to get this to work using the API/SDK.
Appreciate any help! My code looks like this:

$process = $api->createProcess([
  "inputformat" => "pdf",
  "outputformat" => "html",
]);

$process->start([
  "input"=>"download",
  "file"=>$pdf_url,
  "outputformat" => "html",
  "converteroptions" => [
        "zoom" => 1,
        "page_width" => 900,
        "page_height" => 1100,
        "embed_css" => [],
        "embed_font" => [],
        "embed_javascript" => [],
        "embed_image" => [],
    ],
])->wait();

$process->downloadAll($download_dir);

Solution

  • The options embed_javascript, embed_css, etc are Boolean values:

    $process->start([
      "input"=>"download",
      "file"=>$pdf_url,
      "outputformat" => "html",
      "converteroptions" => [
            "embed_css" => false,
            "embed_font" => false,
            "embed_javascript" => false,
            "embed_image" => false,
        ],
    ])->wait();