Random Post: Congratulations Polin...
RSS .92| RSS 2.0| ATOM 0.3
  • Home
  • About Me
  • My Publications
  • My Work Domain
  • phpResource Feeds
  •  

    PDF Service : Url2Pdf at services.phpresgroup.org

    June 10th, 2006

    Here’s the code of my Url2PdfReport PDF service at services.phpresgroup.org:

    ————————Url2PdfReport.class.php———————

    < ?php
    /**
    * URL2PDFReport Generator Class
    *
    * @author : MA Razzaque Rupom ,
    * Moderator, phpResource (http://groups.yahoo.com/group/phpresource/)
    * URL: http://www.rupom.info
    * @version : 1.0
    * @date 06/05/2006
    * Purpose : Generating Pdf Report from a Given URL
    */
    class Url2PdfReport
    {
    private $url;
    private $pdfWidth = 850;
    private $remoteApp = “http://services.phpresgroup.org/pdf/url2pdf/html2ps.php”;

    /**
    * Sets URL that will be converted to PDF
    * @param URL of the HTML file
    * @return none
    */
    function setUrl($url)
    {
    $this->url = $url;
    }

    /**
    * Sets width of the PDF
    * @param Integer pdf width
    * @return none
    */
    function setPdfWidth($pdfWidth)
    {
    if(is_numeric($pdfWidth))
    {
    $this->pdfWidth = $pdfWidth;
    }
    }

    /**
    * Gets PDF report
    * @param none
    * @return none
    */
    function getPdfReport()
    {

    $htmlUrl = $this->url;
    $pdfFileName = basename($htmlUrl).’.pdf’;

    // Outputting PDF Report
    header(”Content-type: application/pdf”);

    // It will be called basename($this->htmlUrl).pdf
    header(”Content-Disposition: attachment; filename=”.$pdfFileName);

    // The PDF source is the returned value of method generatePdfReport()
    echo $this->generatePdfReport();

    }//EO Method

    /**
    * Generates PDF report from remote application
    * @param none
    * @return report data on PDF mode
    */
    function generatePdfReport()
    {
    $remoteApp = $this->remoteApp;
    $waterMarkHtml = “phpresgroup.org”;//change it according to your need
    $htmlUrl = urlencode($this->url);
    $pdfWidth = $this->pdfWidth;

    $requestString = “process_mode=single&URL=$htmlUrl&pixels=$pdfWidth
    &scalepoints=1&renderimages=1&renderlinks=1&renderfields=1&media=Letter
    &cssmedia=screen&leftmargin=10&rightmargin=10&topmargin=15
    &bottommargin=15&encoding=&headerhtml=&footerhtml=
    &watermarkhtml=$waterMarkHtml&method=fpdf&pdfversion=1.3
    &output=0&convert=Convert+File”;

    //Init the curl session
    $ch = curl_init();
    // set the post-to url (do not include the ?query+string here!)
    curl_setopt ($ch, CURLOPT_URL, $remoteApp);
    // Header control
    curl_setopt ($ch, CURLOPT_HEADER, 0);
    //Tell it to make a POST, not a GET
    curl_setopt ($ch, CURLOPT_POST, 1);
    // Put the query string here starting without “?”
    curl_setopt ($ch, CURLOPT_POSTFIELDS, $requestString);
    // This allows the output to be set into a variable
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    // execute the curl session and return the output to a variable $response
    $response = curl_exec ($ch);
    // Close the curl session
    curl_close ($ch);

    return $response;
    }//EO Method

    /**
    * Debugs dump/data
    * @param $dump
    * @return none
    */
    function dBug($dump)
    {
    echo ‘

    ';
       	  print_r($dump);
       	  echo '
    ‘;
    }

    }//EO Class
    ?>
    ——————————————————————-

    Here’s the usage.php code:

    ——————–usage.php———————————-

    < ?php

    //usage of Url2PdfReport Generator Class

    require_once('Url2PdfReport.class.php');

    $obj = new Url2PdfReport();

    //sets URL of the HTML file which will be converted to PDF
    $obj->setUrl(”http://localhost/xampp/phpClasses/url2pdfreport/test.html”);//change this according to your URL

    //gets the pdf report of the URL data
    $obj->getPdfReport();
    ?>
    ————————————————————————

    Also you can download it now from WeberDev:

    Download Url2PdfReport Generator Class

    Hope you will enjoy it.

    Regards,

    $Rupom


    My Gmail Addressbook Grabber Class

    June 9th, 2006

    Hello All,
    Many ones wanted my “Gmail Addressbook Grabber” code. I was expecting to finalize a class of that code. At last I completed that and today got approved at “planet source code”.

    Please follow this link to get the “Gmail Addressbook Grabber” code:

    Source Code Here

    Please let me know if anything is problematic with the code. Any comments and suggestions will be highly appreciated.

    Also rate this class if you like.

    Regards,
    $Rupom


    Services at phpResource

    June 7th, 2006

    We started our services at phpResource Group. A subdomain has been fixed for this phpResource Services. From now on, http://services.phpresgroup.org will contain phpResource services. For the first time, we deployed the HTML2PDF and HTML2PS service. You can access these services from http://services.phpresgroup.org/pdf/url2pdf/ OR by using cURL. I have put a cURL based class in the phpResource Files Section. Download and see the url2pdfreport.zip file if you want to use this service. This service gives a exact PDF output of an HTML.

    Regards,
    $Rupom


    PHP Session Security Issues

    June 3rd, 2006

    There are many security issues for session in PHP. I got two good links. Both stated about thess security issues. You can read these:

    http://www.webkreator.com/php/configuration/php-session-security.html
    http://www.sitepoint.com/blogs/2004/03/03/notes-on-php-session-security/

    Since security is the topmost important thing in web, we need to know a bit more about security.

    Enjoy PHPing !!

    Regards,
    $Rupom


    My Class “Graph Coloring” Got Innovation Award Nomination

    June 1st, 2006

    I just got my class “Graph Coloring” nominated at phpclasses.org for the month of May, 2006. I am enjoying the times very much after getting this good news from PHP Classes authority.

    Please see this class and vote me. This class implements a completely new graph coloring algorithm designed by me.

    ========== Read Me ===================================

    What’s graph coloring:

    In a connected graph (where vertices are connected e.g. no isolated vertex exists), graph coloring is the process that ensures proper marker (/color) has (/have) been assigned to a vertex so that no adjacent (connected) vertices hold the same marker (/color).

    How this class works:
    This class implemented a new algorithm of graph coloring. The present class works as follow:

    1. Gets graph from source (file OR DB)
    1. Represents the graph (connections as well) as an array
    2. Traverses the array to color vertices according to the algorithm
    3. Displays the color result

    The New Graph Coloring Algorithm:

    The new approach of graph coloring works as follow:
    ======================================
    graph = graph array
    i=1
    j=1
    while(i<=no_of_vertices)
    while(j<=no_of_vertices)
    if (graph[i][j]==1)
    i. color vertex i, push it into the colored array
    ii. process(i)
    else
    graph[i][j]:= 0;
    endif
    6. j++
    End of while
    7. i++
    End of while

    —————————————–
    function process(j)
    i=1
    while(i<=no_of_vertices)
    if(graph[j][i]==1)
    (i). graph[j][i]:=0 //Disconnects the colered vertex j from its connected ones — duplex disconnection
    (ii).Disconnects vertex i(which is connected to the newly colored vertex j)from its connected ones–simplex disconnection
    endif
    End of while

    end of function
    ====================================

    I am not giving the complexity analysis of this algorithm here. Future versions will come with so.

    Best Regards,
    [Rupom ]