コード例 #1
0
ファイル: home.php プロジェクト: 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;
     }
 }
コード例 #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;
}
コード例 #3
0
    $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);
            $pageHeight = -1;
            $pdf = $client->setPdfScalingFactor($scaleFactor);
        } else {
            exit;
        }
    }
    $pdf = $client->setPageWidth($pageWidth);
    $pdf = $client->setPageHeight($pageHeight);
    $pdf = $client->setPageMargins(0, 0, 0, 0);
    $pdf = $client->setMaxPages($numPages);
    $pdf = $client->convertURI('http://www.sellosyrotulos.com/pdf_custom.php?IDcus=' . $idCus . '&type=' . $type);
    header('Content-Type: application/pdf');
    header('Cache-Control: no-cache');
    header('Accept-Ranges: none');
    header('Content-Disposition: attachment; filename=\'custom-' . $idCus . '.pdf\'');
    echo $pdf;
} catch (PdfcrowdException $e) {
    echo 'Pdfcrowd Error: ' . $e->getMessage();
}
//}
コード例 #4
0
#!/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');
コード例 #5
0
ファイル: flyer_print.php プロジェクト: nelsonwu/goHoody
<?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";
    }
}
コード例 #6
0
ファイル: dashboards.php プロジェクト: redsummit/anitaborg
 $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
         echo $pdf;
     } catch (PdfcrowdException $e) {
         echo "Pdfcrowd Error: " . $e->getMessage();
     }
 } else {
     if ($action == 'Dashboard' || $action == 'convert') {
         //print('<pre>');print_r($results);print('</pre>');
         $otype = $entry->Is_Hardware__c ? 'Hardware' : 'Software';
         $position = $results['02']->Position;
コード例 #7
0
ファイル: xls1.php プロジェクト: Ghoya101/tryrepo
<?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;
}
コード例 #8
0
ファイル: test.php プロジェクト: ahamed07sajeeb/pdfcrowd-php
$test_dir = './test_files';
function out_stream($name, $use_ssl)
{
    $fname = "./test_files/out/php_client_{$name}";
    if ($use_ssl) {
        $fname .= "_ssl";
    }
    return fopen($fname . '.pdf', 'wb');
}
$html = "<html><body>Uploaded content!</body></html>";
$client = new Pdfcrowd($argv[1], $argv[2]);
foreach (array(False, True) as $i => $use_ssl) {
    $client->useSSL($use_ssl);
    try {
        $ntokens = $client->numTokens();
        $client->convertURI('http://dl.dropboxusercontent.com/u/9346438/tests/webtopdfcom.html', out_stream('uri', $use_ssl));
        $client->convertHtml($html, out_stream('content', $use_ssl));
        $client->convertFile($test_dir . '/in/simple.html', out_stream('upload', $use_ssl));
        $client->convertFile($test_dir . '/in/archive.tar.gz', out_stream('archive', $use_ssl));
        $after_tokens = $client->numTokens();
        echo "remaining tokens: {$after_tokens}\n";
        if ($ntokens - 4 != $after_tokens) {
            throw new Exception("Mismatch in the number of tokens.");
        }
    } catch (PdfcrowdException $e) {
        echo "EXCEPTION: " . $e->getMessage();
        exit(1);
    }
}
$tests = array('setPageWidth' => 500, 'setPageHeight' => -1, 'setHorizontalMargin' => 0, 'setVerticalMargin' => 72, 'setEncrypted' => True, 'setUserPassword' => 'userpwd', 'setOwnerPassword' => 'ownerpwd', 'setNoPrint' => True, 'setNoModify' => True, 'setNoCopy' => True, 'setPageLayout' => Pdfcrowd::CONTINUOUS, 'setPageMode' => Pdfcrowd::FULLSCREEN, 'setFooterText' => '%p/%n | source %u', 'enableImages' => False, 'enableBackgrounds' => False, 'setHtmlZoom' => 300, 'enableJavaScript' => False, 'enableHyperlinks' => False, 'setDefaultTextEncoding' => 'iso-8859-1', 'usePrintMedia' => True, 'setMaxPages' => 1, 'enablePdfcrowdLogo' => True, 'setInitialPdfZoomType' => Pdfcrowd::FIT_PAGE, 'setInitialPdfExactZoom' => 113, 'setPdfScalingFactor' => 0.5, 'setFooterHtml' => '<b>bold</b> and <i>italic</i> <img src="http://s3.pdfcrowd.com/test-resources/logo175x30.png" />', 'setFooterUrl' => 'http://s3.pdfcrowd.com/test-resources/footer.html', 'setHeaderHtml' => 'page %p out of %n', 'setHeaderUrl' => 'http://s3.pdfcrowd.com/test-resources/header.html', 'setAuthor' => 'Custom Author', 'setPageBackgroundColor' => 'ee82EE', 'setTransparentBackground' => True, 'setUserAgent' => "test user agent");
try {
コード例 #9
0
ファイル: Utils.php プロジェクト: alex2stf/phpquick
 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();
     }
 }
コード例 #10
0
ファイル: application.php プロジェクト: shaheeda622/vzapp
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;
    }
}
echo '<div id="download_pdf_link" class="pdf_link" onClick="' . "\$('#final_form').submit();" . '"><i class="fa fa-download"></i> Download as PDF</div>';
echo $buffer;
コード例 #11
0
ファイル: index.php プロジェクト: 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();
}