8 Jun 2015

Php Code to generate word document in print view from html

Use the following code as a html attribute with the html starting tag
xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"

6 Jun 2015

Create a Word Document from html using Php

Method-1:
header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename=filename.doc");




.........Complete Html........



Method-2: Download File from Github Read More

5 Jun 2015

Excel file Uploading & data import code from excel(Xlsx) file-

Please Use Excel in Xlsx file format for uploading with SimpleXlsx Class library for data Reading

Php function to resize and crop images

function resize_with_crop($max_width, $max_height, $source_file, $dst_dir, $quality = 80){
    $imgsize = getimagesize($source_file);
    $width = $imgsize[0];
    $height = $imgsize[1];
    $mime = $imgsize['mime'];
 
    switch($mime){
        case 'image/gif':
            $image_create = "imagecreatefromgif";
            $image = "imagegif";
            break;
 
        case 'image/png':
            $image_create = "imagecreatefrompng";
            $image = "imagepng";
            $quality = 7;
            break;
 
        case 'image/jpeg':
            $image_create = "imagecreatefromjpeg";
            $image = "imagejpeg";
            $quality = 80;
            break;
 
        default:
            return false;
            break;
    }
     
    $dst_img = imagecreatetruecolor($max_width, $max_height);
    $src_img = $image_create($source_file);
     
    $width_new = $height * $max_width / $max_height;
    $height_new = $width * $max_height / $max_width;
    
    if($width_new > $width){
        //cut point by height
        $h_point = (($height - $height_new) / 2);
        //copy image
        imagecopyresampled($dst_img, $src_img, 0, 0, 0, $h_point, $max_width, $max_height, $width, $height_new);
    }else{
        //cut point by width
        $w_point = (($width - $width_new) / 2);
        imagecopyresampled($dst_img, $src_img, 0, 0, $w_point, 0, $max_width, $max_height, $width_new, $height);
    }
     
    $image($dst_img, $dst_dir, $quality);
 
    if($dst_img) imagedestroy($dst_img);
    if($src_img) imagedestroy($src_img);
}

resize_with_crop(100, 100, "demo.jpg", "demo.jpg");

Php Function to print array values in level structure

function pr($data) { print('
'.print_r($data, true).'
'); }

Image Resizing and Cropping Code Through GD Library

Provided link describes how a thumbnail can be cropped using GD jQuery Library Url- Read More