Пример #1
0
<?php

echo "convert md files to pdf\n";
echo '<pre>';
print_r($_GET);
echo $argv[1];
echo '< /pre>';
function convertToPdf($folder)
{
    echo "converting " . $folder . "\n\n";
    $pd = $folder . ".pd";
    $pdf = $folder . ".pdf";
    $cmd = "cd " . $folder . " && mkdocs2pandoc > " . $pd . " && pwd && pandoc --toc -f markdown+grid_tables+table_captions -o " . $pdf . " " . $pd;
    echo $cmd . "\n";
    shell_exec($cmd . " 2>&1; echo \$?\n");
}
convertToPdf($argv[1]);
?>

Пример #2
0
$html = get_magic_quotes_gpc() ? stripslashes($_POST["html"]) : $_POST["html"];
// quickbook_item_supplements
$sizeKey = "size";
$productTypeKey = "productType";
$query = createSqlQuery("SELECT qbis.size as '{$sizeKey}'", ", qbis.product_type as '{$productTypeKey}'", "FROM quickbooks_item_supplements qbis", "WHERE qbis.id LIKE '{$idBase}-%'");
$result = queryDb($query);
if (mysql_num_rows($result) == 0) {
    // quickbooks_item_supplements with this id doesn't exist
    echo "No information for products with id base: {$idBase}.";
    return;
}
$row = mysql_fetch_assoc($result);
$productType = $row[$productTypeKey];
$size = $row[$sizeKey];
$htmlForPdfPath = getHtmlForPdfPath($productType, $size);
mkFileDirs($htmlForPdfPath);
file_put_contents($htmlForPdfPath, $html);
$htmlForPdfUrl = "http://" . $_SERVER['SERVER_NAME'] . "/" . getDirectoryPathFromRoot(__FILE__) . "/{$htmlForPdfPath}";
$pdfPath = getPdfPath($productType, $size);
$tmpPdfPath = $pdfPath . ".tmp";
if (!convertToPdf($htmlForPdfUrl, $tmpPdfPath, $errorMessage)) {
    echo implode("\n", array("PDF generation failed because: {$errorMessage}", "PDF path: {$tmpPdfPath}", "PDF HTML URL: {$htmlForPdfUrl}", "HTML: {$html}"));
    unlink($tmpPdfPath);
    return;
}
if (file_exists($pdfPath)) {
    $archivedPdfPath = getArchivedPdfPath($productType, $size);
    mkFileDirs($archivedPdfPath);
    rename($pdfPath, $archivedPdfPath);
}
rename($tmpPdfPath, $pdfPath);