Docverter / docverter

Docverter Server
Other
829 stars 101 forks source link

Using multiple images to convert in a document #54

Closed wisejoy7 closed 7 years ago

wisejoy7 commented 7 years ago

Hi,

I was trying to convert a html to pdf document. To make this conversion I use your api using PHP. I do this by using 'other_files[]' => "@/".realpath('example_files/images.jpg'), and the file conversion is success but I want to convert html to pdf with multiple images in it. How do I assign multiple images in other files[] variable. I tried using array("@/".realpath('example_files/images.jpg'), "@/".realpath('example_files/images.jpg')) but that did not work.

<?php

$filename = $_GET['filesx'];

//set POST variables
$url = 'http://c.docverter.com/convert';
$fields = array('from' => 'html',
    'to' => 'pdf',
    'input_files[]' => "@/".realpath('example_files/'.$filename).";type=text/html; charset=UTF-8",
    'other_files[]' => "@/".realpath('example_files/images.jpg'),
);

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: multipart/form-data"));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);

$finalx = strstr($filename , '.html', true);

$fp = fopen('uploads/'.$finalx.'.pdf', 'w');
fwrite($fp, $result);
fclose($fp);

echo '<script type="text/javascript">
           window.location = "http://docs.google.com/viewer?url=reviewitapp.co/docvert/doc/examples/php/uploads/'.$finalx.'.pdf&embedded=true"
      </script>'; 
wisejoy7 commented 7 years ago

Can you please let me know the solution. I tried many things from array as mentioned above, separated file paths by comma and also tried re writing the same statement with different file path. Nothing works for me. :(

wisejoy7 commented 7 years ago

I need this issue fixed soon brother. Please help me. :(

peterkeen commented 7 years ago

I don't know PHP. You should look into how to assign multiple values to the same param name in the curl docs.

On Thu, Mar 16, 2017 at 6:59 PM Abhishek Singh notifications@github.com wrote:

I need this issue fixed soon brother. Please help me. :(

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Docverter/docverter/issues/54#issuecomment-287217657, or mute the thread https://github.com/notifications/unsubscribe-auth/AAA2mep11F0N662wIN0GIPejjb-3rIX2ks5rmb7bgaJpZM4MagUn .