We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Pdf to html after conversion problem

pdf to html conversion not providing appropriate result. Please see the attached snapshot and below is code of conversions.


function convertfile($fileName, $type, $newFileName)
{
$typePath = $this->typeToPath($type);
$dir = $this->filesDir . $typePath . ‘/’;
AsposeApp::$outPutLocation = $dir;
$doc = new Document("");
$doc->productURI();
$mainDocumentFile = $dir.$newFileName;
$convertFileHtml = $dir. $file_name. ‘.html’;

//create Document object
$result = $doc->convertLocalFile($mainDocumentFile, $convertFileHtml , “html”,1);
}

Hi Waheed,


Thanks for contacting support.

First of all, it is not clear from your code what values you have set and what values you are passing. If you are using PHP SDK, then you should use following example as specified over Convert PDF to other formats without using storage.

[PHP]

use
Aspose\Cloud\Common\AsposeApp;<o:p></o:p>

use Aspose\Cloud\Common\Utils;

use Aspose\Cloud\Common\Product;

use Aspose\Cloud\Pdf\Converter;

//sepcify App SID

AsposeApp::$appSID = "77******-1***-4***-a***-8***********";

//sepcify App Key

AsposeApp::$appKey = "89******************************";

Product::$baseProductUri = "http://api.aspose.com/v1.1";

AsposeApp::$outPutLocation = getcwd() . "/Output/";

echo "Converting PDF to TIFF... ";

//create Converter object

$converter = new Converter("");

$converter->convertLocalFile(getcwd() . "/Input/input.pdf", "Output.zip", "html");

echo "done";


Please note that when converting PDF to HTML, Aspose for Cloud returns output file as a ZIP not as HTML. So if you are passing correct values and doing everything right, even then you should handle output file as a ZIP not as HTML. The convertLocalFile(..) method takes first argument as input file, second argument as output file and third argument as output format. You may consider using following code to extract HTML from .zip file (over windows platform).


[PHP]

Utils::saveFile($responseStream, $outputPath);

$zip = new ZipArchive;

$zip->open($outputPath);

$zip->extractTo(getcwd() . '/Output/OutputHtml');

$zip->close();

echo "File converted";


Whereas the Linux code is specified over this link.


Besides this, if your requirement is to convert PDF file to HTML so that it can be displayed/rendered inside web browser, then I would suggest you to please try using ViewerApp of our sister company named GroupDocs which can be used to display various file formats in cloud applications.