Example #1
0
File: home.php Project: elshafey/ir
 function generate()
 {
     $url = site_url() . 'home/preview' . '?' . http_build_query($this->users->get_user_by_id(get_user_id()));
     $name = md5(date('ymdHis'));
     if ($_SERVER['REMOTE_ADDR'] == '127.0.0.1') {
         $dir = $this->config->item('static_path');
         if (shell_exec('xvfb-run -a wkhtmltopdf "' . $url . '"   "' . $dir . 'uploads/business-cards/' . $name . '.pdf"')) {
             header('Location: ' . site_url() . 'uploads/business-cards/' . $name . '.pdf');
         }
         exit;
     }
     require 'application/libraries/pdfcrowd.php';
     try {
         // create an API client instance
         $client = new Pdfcrowd("elshafey", "1386e8072e4b1bc2b82e6f3a8a166205");
         // convert a web page and store the generated PDF into a $pdf variable
         $pdf = $client->convertURI($url);
         // set HTTP response headers
         header("Content-Type: application/pdf");
         header("Cache-Control: max-age=0");
         header("Accept-Ranges: none");
         header("Content-Disposition: attachment; filename=\"{$name}.pdf\"");
         // send the generated PDF
         echo $pdf;
     } catch (PdfcrowdException $why) {
         echo "Pdfcrowd Error: " . $why;
     }
 }
Example #2
0
function generatePDF()
{
    if (!$_GET["action"]) {
        return False;
    }
    try {
        // build the url and remove the pdf field from the query string
        $url = "http://" . $_SERVER["SERVER_NAME"] . $_SERVER["PHP_SELF"];
        if (count($_GET) > 1) {
            unset($_GET["action"]);
            $url = $url . "?" . http_build_query($_GET, '', '&');
        }
        // call the API enter your username, and API key
        //you must register at pdf crowd.com to get this key
        $client = new Pdfcrowd("smartydev", "01f5bfdbb955b853765d52b22ff00bba");
        $pdf = $client->convertURI($url);
        /*
        send the generated pdf to the browser
        you will see a save as option because of this headers.
        Alternatively, if you prefer to open for viewing,
        copy to your server ie copy($pdf, $destination), and use header("Location: pdf_link.php") to open
        */
        header("Content-Type: application/pdf");
        header("Cache-Control: no-cache");
        header("Accept-Ranges: none");
        header("Content-Disposition: attachment; filename=\"createdFile.pdf\"");
        echo $pdf;
    } catch (PdfcrowdException $why) {
        echo "PDF creation failed: " . $why . "\n";
    }
    return true;
}
Example #3
0
 public function generate($content)
 {
     $instance = new \Pdfcrowd($this->username, $this->apiKey);
     $instance->setHeaderHtml($this->header);
     $instance->setFooterHtml($this->footer);
     $instance->setPageMargins($this->options['margin-top'] * 2, $this->options['margin-right'], $this->options['margin-bottom'] * 2, $this->options['margin-left']);
     return $instance->convertHtml($content);
 }
                    setupPdfConverter();
                    setupRealsizeVaribales();
                    Generate PDF
                }
            }
*/
require 'pdf/pdfcrowd.php';
require_once 'product-customizer/api/api-requests.php';
$apiRequests = new ApiRequests();
$idCus = $_GET['IDcus'];
$type = $_GET['type'];
//[pdf|pdfwb]
$realSize = isset($_GET['realSize']) ? $_GET['realSize'] : false;
//if ( $_GET['IDcli'] === $apiRequests->getIdCliFromBDPedidosCustom($idCus)[0]['ID_cli']) {
try {
    $client = new Pdfcrowd('dani3rs', '6cb8fce0fa072b77c4655a4da2631cb2');
    $productId = $apiRequests->getCustomization($_GET['IDcus'])[0]['ID_pro'];
    $productWidth = $apiRequests->getProduct($productId)[0][W_anchura];
    $productHeight = $apiRequests->getProduct($productId)[0][H_altura];
    $productUnits = $apiRequests->getProduct($productId)[0][Unidad];
    $productDiameter = $apiRequests->getProduct($productId)[0][D_diametro];
    $numPages = count($apiRequests->getViews($_GET['IDcus']));
    $pageWidth = 450;
    // 600 * 72 / 96
    $pageHeight = (int) $apiRequests->getCustomization($_GET['IDcus'])[0]['Height'] * 72 / 96;
    //pixels to points conversion
    if ($realSize == true) {
        if ($productWidth !== null && $productHeight !== null && $productDiameter == null || $productWidth == null && $productHeight == null && $productDiameter !== null) {
            $scaleFactor = floatval($productWidth / 158.75);
            // 600 pixles * 72 / 96 => becomes points then 1 pint is 0.35 mm => therefor 600px are 158.75 mm in 72 pixels per inch
            $pageWidth = str_replace('.00', $productUnits, $productWidth);
#!/usr/bin/php
<?php 
// $argv .. array
// $argc
require 'pdfcrowd.php';
if ($argc < 3) {
    echo "usage: apiserver-test.php username api_key apihost\n";
    exit(1);
}
$c = new Pdfcrowd($argv[1], $argv[2], $argv[3]);
$c->convertURI('http://dl.dropboxusercontent.com/u/9346438/tests/webtopdfcom.html');
$c->convertHtml('raw html');
$c->convertFile('../test_files/in/simple.html');
Example #6
0
<?php

require 'php/pdfcrowd.php';
// check for a listing_id in the URL:
$page_title = NULL;
if (isset($_GET['lid'])) {
    //Typecast it to an integer:
    $lid = (int) $_GET['lid'];
    //An invalid $_GET['lid'] value would be typecast to 0
    try {
        // create an API client instance
        $client = new Pdfcrowd("nelsonwu", "40751625cc38a498200f22e2224f1595");
        if ($_GET['colour'] == 0) {
            // convert a web page and store the generated PDF into a $pdf variable
            $pdf = $client->convertURI('http://gohoody.com/flyer_clean.php?lid=' . $lid . '&colour=0');
        } else {
            // convert a web page and store the generated PDF into a $pdf variable
            $pdf = $client->convertURI('http://gohoody.com/flyer_clean.php?lid=' . $lid . '&colour=1');
        }
        // set HTTP response headers
        header("Content-Type: application/pdf");
        header("Cache-Control: no-cache");
        header("Accept-Ranges: none");
        header("Content-Disposition: inline; filename=\"hoody_service.pdf\"");
        echo $pdf;
    } catch (PdfcrowdException $why) {
        echo "Can't create PDF: " . $why->getMessage() . "\n";
    }
}
<?php

if (isset($_POST['data']) && $_POST['data'] != "") {
    $data = $_POST['data'];
} else {
    $data = "<b> NO DATA PASSED </b>";
}
require 'pdfcrowd.php';
$client = new Pdfcrowd("prashant1232123", "d298da9ac7920f94460f6d8bf8643986");
try {
    $pdf_from_html = $client->convertHtml($data);
    header("Content-Type: application/pdf");
    header("Cache-Control: no-cache");
    header("Accept-Ranges: none");
    header("Content-Disposition: inline; filename=\"salarysheet.pdf\"");
    echo $pdf_from_html;
} catch (PdfcrowdException $why) {
    echo "Pdfcrowd Error: " . $why;
}
Example #8
0
    $chart = $_SESSION['chart'];
} else {
    $chart = '';
}
if (isset($_REQUEST['org'])) {
    $org = $_REQUEST['org'];
    $action = $_REQUEST['action'];
    $_SESSION['org'] = $org;
    $entry = $tc->getEntry($org);
    $results = $tc->getResponses($entry);
    $_SESSION['orgentry'] = $entry;
    $_SESSION['orgdata'] = $results;
    if ($action == 'pdf') {
        try {
            // create an API client instance
            $client = new Pdfcrowd("parkwalker", "96cda0de82cbabba37c86a38f2aaeba0");
            // $client = new Pdfcrowd("redsummit", "9eabc3fd96e21622fb581f8b42575587");
            $client->setPageWidth("11in");
            $client->setPageHeight("8.5in");
            $client->setHorizontalMargin("0.25in");
            $client->setVerticalMargin("0.25in");
            //$client->setHtmlZoom(400)
            $filename = $entry->Account->Name . '-Dashboard';
            // convert a web page and store the generated PDF into a $pdf variable
            $pdf = $client->convertURI("http://www.anitaborg.org/TCTest/dashboards.php?org={$org}&chart=00&action=convert");
            // set HTTP response headers
            header("Content-Type: application/pdf");
            header("Cache-Control: no-cache");
            header("Accept-Ranges: none");
            header("Content-Disposition: attachment; filename=\"{$filename}.pdf\"");
            // send the generated PDF
Example #9
0
<?php

require 'pdfcrowd.php';
try {
    // create an API client instance
    $client = new Pdfcrowd("username", "apikey");
    // convert a web page and store the generated PDF into a $pdf variable
    $pdf = $client->convertURI('http://localhost/sms10/PU/newpo.php?proj=2&&poid=2%20-%201');
    // set HTTP response headers
    header("Content-Type: application/pdf");
    header("Cache-Control: max-age=0");
    header("Accept-Ranges: none");
    header("Content-Disposition: attachment; filename=\"po.pdf\"");
    // send the generated PDF
    echo $pdf;
} catch (PdfcrowdException $why) {
    echo "Pdfcrowd Error: " . $why;
}
Example #10
0
try {
    foreach ($tests as $method => $arg) {
        $client = new Pdfcrowd($argv[1], $argv[2]);
        $client->{$method}($arg);
        $client->setVerticalMargin('1in');
        $client->convertFile($test_dir . '/in/simple.html', out_stream(strtolower($method), False));
    }
} catch (PdfcrowdException $e) {
    echo "EXCEPTION: " . $e->getMessage();
    exit(1);
}
// margins
$client = new Pdfcrowd($argv[1], $argv[2]);
$client->setPageMargins('0.25in', '0.5in', '0.75in', '1.0in');
$client->convertHtml('<div style="background-color:red;height:100%">4 margins</div>', out_stream('4margins', False));
// expected failures
$failures = array(array("convertHtml", "", "must not be empty"), array("convertFile", "does-not-exist.html", "not found"), array("convertFile", "/", "not a directory"), array("convertFile", $test_dir . "/in/empty.html", "must not be empty"), array("convertURI", "domain.com", "must start with"), array("convertURI", "HtTp://s3.pdfcrowd.com/this/url/does/not/exist/", "Received a non-2xx response"));
$client = new Pdfcrowd($argv[1], $argv[2]);
$client->setFailOnNon200(True);
foreach ($failures as $failure) {
    try {
        $client->{$failure}[0]($failure[1]);
        echo "FAILED expected an exception: {$failure}\n";
        exit(1);
    } catch (PdfcrowdException $e) {
        if (!strstr($e->getMessage(), $failure[2])) {
            echo "error message [" . $e->getMessage() . "] is expected to contain [" . $failure[2] . "]\n";
            exit(1);
        }
    }
}
Example #11
0
 public static function makePdf($html)
 {
     require_once 'pdfcrowd.php';
     try {
         // create an API client instance
         $client = new Pdfcrowd("jspdf", "07f4904945bc4e4777716843651b2d2d");
         $pdf = $client->convertHtml($html);
         // convert a web page and store the generated PDF into a $pdf variable
         $pdf = $client->convertURI('http://example.com/');
         // send the generated PDF
         return $pdf;
     } catch (PdfcrowdException $e) {
         echo "Pdfcrowd Error: " . $e->getMessage();
     }
 }
Example #12
0
    include __DIR__ . "/template.php";
}
if (!$is_download) {
    echo '</form>';
}
echo '<script type="text/javascript"></script>';
$buffer = ob_get_contents();
@ob_end_clean();
file_put_contents(FCPATH . '/forpdf.html', $buffer);
if (!$is_download) {
    $link = url('licapp/submit?download=true');
} else {
    require 'pdfcrowd.php';
    try {
        // create an API client instance
        $client = new Pdfcrowd("adminpdf", "74cc49e3c15d17571469238a24ae4739");
        // convert a web page and store the generated PDF into a $pdf variable
        //setPageMargins(5, 0, 0, 0);
        $pdf = $client->convertURI('http://www.vzonlineapplications.com/form/forpdf.html');
        // set HTTP response headers
        header("Content-Type: application/pdf");
        header("Cache-Control: max-age=0");
        header("Accept-Ranges: none");
        header("Content-Disposition: attachment; filename=\"License_Application_Form.pdf\"");
        // send the generated PDF
        echo $pdf;
        exit;
    } catch (PdfcrowdException $why) {
        echo "Pdfcrowd Error: " . $why;
    }
}
Example #13
0
File: index.php Project: flyeven/mu
<?php

require 'pdfcrowd.php';
try {
    // create an API client instance
    $client = new Pdfcrowd('mukesh_kumar', 'fcdecfe831fddbaa0ee60c7b14c99865');
    // convert a web page and store the generated PDF into a $pdf variable
    $pdf = $client->convertURI('http://meetuniv.com/gifted/reportpdf');
    // set HTTP response headers
    header("Content-Type: application/pdf");
    header("Cache-Control: no-cache");
    header("Accept-Ranges: none");
    header("Content-Disposition: attachment; filename=\"created.pdf\"");
    // send the generated PDF
    echo $pdf;
} catch (PdfcrowdException $e) {
    echo "Pdfcrowd Error: " . $e->getMessage();
}