home
demo
- examples -
reference
limitations
F.A.Q.
licenses
contacts
terms of use

evaluation



MrLink

 Aggiungi un sito nella directory

SEO Directory



Scambio Directory Pubblicitaonline.it

Realizzazione siti

Googlerank, pagerank di Google



remotePDF > Examples


Here are some examples made in PHP (any other script languages can be used) to help you to create a test page into your site.

Reads a local HTML file and sends it to remotePDF
<form action="http://www.remotepdf.com/print.php" method="POST">
<?
    $filename
="C:\\your\\local\\path\\yourfile.html";
    
$FP=fopen($filename"rb");
    
$cont=fread($FP,filesize($filename));
    
fclose($FP);
?>
    <input type="hidden" name="license" value="your-license">
    <input type="hidden" name="data" value="<?=base64_encode($cont)?>">
    <input type="hidden" name="title" value="myTitle">
    <input type="hidden" name="author" value="myAuthor">
    <input type="hidden" name="subject" value="mySubject">
    <input type="hidden" name="keywords" value="myKeywords">
    <input type="hidden" name="papersize" value="A4">
    <input type="hidden" name="resolution" value="100">
    <input type="hidden" name="inputtype" value="htm">
    <input type="hidden" name="output" value="1">
    <input type="hidden" name="outputfilename" value="out.pdf">
    <input type="submit" value="HTML->PDF">
</form>
Be ware that to have a nice rendered HTML file read from your local location you need:
- the <base url=””> directive in the html page
OR
- all the links in the page as a full links and NOT relative.

Also full links (images and CSS) should be reachable from the web.
This depends on how the web page has been created. Do some tests with an evaluation license before to spend your regular license. Take a look also to ‘basehref’ option.

If the result is still not good, then let remotePDF read the page itself like this:
<form action="http://www.remotepdf.com/print.php" method="POST">
<?
    $cont 
="http://www.google.it/";
?>
    <input type="hidden" name="license" value="your-license">
    <input type="hidden" name="data" value="<?=base64_encode($cont)?>">
    <input type="hidden" name="title" value="myTitle">
    <input type="hidden" name="author" value="myAuthor">
    <input type="hidden" name="subject" value="mySubject">
    <input type="hidden" name="keywords" value="myKeywords">
    <input type="hidden" name="papersize" value="A4">
    <input type="hidden" name="resolution" value="100">
    <input type="hidden" name="inputtype" value="htm">
    <input type="hidden" name="output" value="1">
    <input type="hidden" name="outputfilename" value="out.pdf">
    <input type="submit" value="HTML ->PDF">
</form>



Reads a local DOC file and sends it to remotePDF
Also this example demonstrates how is possible to make your own site capable to generate PDF with just some lines of code. You can render other filetypes (see F.A.Q. for more filetypes).
<form action="http://www.remotepdf.com/print.php" method="POST">
<?
    $filename
="C:\\your\\local\\path\\yourfile.doc";
    
$FP=fopen($filename"rb");
    
$cont=fread($FP,filesize($filename));
    
fclose($FP);
?>
    <input type="hidden" name="license" value="your-license">
    <input type="hidden" name="data" value="<?=base64_encode($cont)?>">
    <input type="hidden" name="title" value="myTitle">
    <input type="hidden" name="author" value="myAuthor">
    <input type="hidden" name="subject" value="mySubject">
    <input type="hidden" name="keywords" value="myKeywords">
    <input type="hidden" name="papersize" value="A4">
    <input type="hidden" name="resolution" value="100">
    <input type="hidden" name="inputtype" value="doc">
    <input type="hidden" name="output" value="1">
    <input type="hidden" name="outputfilename" value="out.pdf">
    <input type="submit" value="DOC->PDF">
</form>

Now let's suppose you want to render a XLS file instead, so change this line as follow:
<input type="hidden" name="inputtype" value="xls">

and of course in the PHP code:
$filename="C:\\your\\local\\path\\yourfile.xls";

You can also choose a different method to get the PDF file with this option:
<input type="hidden" name="output" value="0">
where:
value=”0” means that the PDF file will be shown into your browser;
value=”1” means that a file download will be started for the PDF;
value=”2” means that a raw content of the PDF will be sent back to your client without headers, so you will be able to grab it and do whatever you want with that content (saving locally, insert into a database, ...).
To do this you need to make your script able to send POST request directly to remotePDF without having to use HTML forms. This is done by this example:
<?
function postrequest($url$data$optional_headers null) {
    
$params = array("http" => array(
                    
"method" => "POST",
                    
"content" => $data
                   
));

    if (
$optional_headers !== null$params["http"]["header"] = $optional_headers;

    
$ctx stream_context_create($params);
    
$fp = @fopen($url,"rb"false$ctx);
    if (!
$fp
        throw new 
Exception("Problem with $url, $php_errormsg");
    
    
$response = @stream_get_contents($fp);
    if (
$response === false
        throw new 
Exception("Problem reading data from $url,
                            $php_errormsg"
);

    return 
$response;
}

    
//read the content of the file I need to convert
    
$filename="C:\\your\\local\\path\\yourfile.doc";
    
$FP=fopen($filename"rb");
    
$cont=fread($FP,filesize($filename));
    
fclose($FP);

    
//send the content to remotePDF
    
$my_generated_pdf_file=
        
base64_decode(
            
postrequest("http://www.remotePDF.com/print.php",
            
"license=your_license_here&output=2&inputtype=doc&
            data="
.base64_encode($cont))
        );

    
//now do whatever you want with your generated PDF file:
    // display it, save to disk or into a database...

    // we choose to simply display it…
    
header("Content-type: application/pdf");
    echo 
$my_generated_pdf_file;
?>


Of course all of above examples also works with an evaluation license: request one and do all tests you need !!!

your account




System status:
online


© 2008-2010, remotePDF.com   |   contacts   |   terms of use   |   made by   |   IT02174750188