Loading...


Ask A Question?

 
 
 
 
 
 
Posted in General Discussion / Computer Talk
Author: sandeep Total-Replies: 15


Hi friends,

I have learnt that one can host own website using apache web server. Does that mean that I will have to keep my computer ON all the time. What about browsing? How will people visit my website. I mean what address will they have to put in the address bar of browser where currently I am putting the address of my website.
And what all security policies will I need to apply to prevent my computer being hacked. I was just browsing internet when I came to know that a windows based machine gets hacked in 2 days and a Linux based machine in 4 days on average. If that's true, isn't it quite difficult to be connected to internet for a long time and hosting website. I curious to know more about how to host my website on my web server. I have plans to host my website on the LAN I have in my hostel.

Do supply your comments.
Regards.

Fri May 12, 2006    Reply    New Discussion   
 

Posted in Astahost / Asta ANSWERS!
Author: (G)Daniel Adrienne Total-Replies: 0


Apache htdocs in ramApache Query: Requirements To Run Own Web-Server?

Does anyone out there know whether it is possible to have htdocs completely in RAM so that access lags cause by disk I/O on your server is reduced? My htdocs isless than 500MB and I have 4GB RAM, with more upgrade options.

-question by Daniel Adrienne

Fri Mar 6, 2009    Reply    New Discussion   
 
Posted in Computers & Tech / Databases
Author: Houdini Total-Replies: 6


Iwouldnt say your friend was lying...just misinformed. He probalby got hosted on a server that offered MySQL. Forums like Invision (this one) require a database to work, it is possible to run a foum using PERL and a file system but it eats up a lot of disk space and they are more of anovelty than a practical system. The MySQL is a database server, it merely manipulates, stores and retrieves data, I doesn't understand HTML or HTTP at all only PHP or its own query language, so you can't take an SQL server and make a web site with one, it is used with a webserver. Hope that helps.

Sun Jun 19, 2005    Reply    New Discussion   
 

Posted in Computers & Tech / Programming / Scripting / PHP
Author: khalilov Total-Replies: 5


I am creating a game and for simplicity i am making every possible query a function, ex instead of

CODE

$result=mysql_query("SELECT* FROM tablename WHERE columnname=$variable");
if($result=mysql_fetch_array($result))
{ commands }
else { commands }


i make a function and it becomes

CODE

$x=getinfo($variable)
if($x)
{ commands }
else {commands}


A lot easier to debug for errors and more eye friendly.
However the way it is going there are going to be many functions, 50~100 functions. All will be stored in a file named functions.php, this file will hit ~1000 lines. So including this file in every page on my web would be annoying since i only need 1 or 2 functions tops (about 50 lines of predefined syntax) and i end up adding 1000 lines and prolonging the execution time of a fairly simple script. I'd be defining functions i wont use at the time.
Dividing functions.php into functions1.php, functions2.php.... and including one/some of them depending on the current script in execution might be a solution but i rather not.

My question is that is there a way i can integrate these functions into the server so that they become like standard predefined functions (like echo ,mysql_fetch_array....)?
That way i can call these functions without including anything or worrying about wasted CPU.

thanks in advance :unsure:

Mon Sep 26, 2011    Reply    New Discussion   
 
Posted in Computers & Tech / Software / Content Management Systems (CM.. / Drupal
Author: seec77 Total-Replies: 14


Well, you can easily create a new Drupal installation inside a new folder of your site's web server. If you really want you can actually get multiple instances of Drupal to run from the same codebase, but that's overkill for an action such as testing out your theme.
Running it on your main site isn't as bad either if you don't have any visitors, because it's actually very easy to change back to the old theme (just disable your new theme and set the default to the old theme).
But anyways, I think the best long-term approach would be to just easily set up a complete webserver using XAMPP.

Tue Jul 18, 2006    Reply    New Discussion   
 
Posted in Computers & Tech / Programming / Programming General
Author: FirefoxRocks Total-Replies: 3


Ok, I would like to start learning programming but I do not know where to start.
For web designing, I used to use Microsoft FrontPage 2000, that generated somewhat usable pages, but my first experiences with HTML was learning from a book that I got from the library, then I ended up at W3Schools, where I finished learning HTML and started other stuff, like CSS and PHP.

For programming however, my first experience was using Microsoft Visual Basic 2005 Express edition, creating a "Hello World!" program (the simplest thing), and then trying to use some free tutorial books from Microsoft. It included video tutorials as well as an eBook that (supposedly) taught you to create 2 programs, a weather watcher sort of thing and a RSS reader. Both didn't work properly once I was done, even the downloaded sample files didn't run properly :blink:

So then I tried something simpler, QBasic. It was very simple actually, and I followed a tutorial for kids, which was located at http://tedfelix.com/qbasic/index.html. It was well-written, and simple to do. But the programs that were created needed QBasic to run, which was fine as long as I'm the only one using them. But that wasn't my intent.

I would like to know if there is something for Visual Basic Express that is as simple to follow and as extensive as W3Schools. Otherwise, I need some ideas to start programming. It seems to be interesting!

Mon Aug 27, 2007    Reply    New Discussion   
 

Posted in Astahost / Hosted Members Support
Author: Mordent Total-Replies: 9


Looking through the Fantastico section of the cPanel, I realised that MediaWiki wasn't included in the Wiki section, and I wondered why. When the most famous wiki of the current time is WikiPedia (which uses MediaWiki), I figured that it would be the one that the majority of people know how to use (not to mention the one I'm personally most familiar with).

It's free to use, and I believe that all of the requirements required to run it are met by the servers:

  1. Web Server such as Apache or IIS
  2. PHP version 5.0 or later (5.1.x recommended)
  3. Database Server
MySQL 4.0 or later
or PostgreSQL 8.1 or later (also requires plpgsql and tsearch2)
or Ingres 2006 or later (SVN-Download)

  • Some users find it helpful to install an additional software package such as phpMyAdmin (MySQL) or phpPgAdmin (Postgres) to help administer the database server.
  • For image thumbnailing and TeX-support, additional programs are required.
    Assuming that it's not going to be on the Fantastico list for whatever reason, would it be possible to install it myself, or have I done what I normally do and missed some basic flaw in my cunning plan? :D

    Any help would be appreciated. :blink:

  • Sat Aug 25, 2007    Reply    New Discussion   
     
    Posted in Computers & Tech / Databases
    Author: abhiram Total-Replies: 48


    Hi,

    I agree with the others that MySQL is the best database. MySQL is actually made so that it can be integrated with web applications using PHP very easily. There is very good support for MySQL in PHP. That is why people always use LAMP (Linux Apache MySQL PHP). Since you need to use foxpro tables, try these following links:

    A program to export tables to different formats:
    http://www.softpedia.com/get/Programming/P...ta-Wizard.shtml

    Here is another link for different applications to convert from one format to another. There is one for foxpro as well:

    http://sunsite.mff.cuni.cz/MIRRORS/ftp.mys...converters.html

    There are plenty of tutorials on the net for MySQL. If you want a hassle-free installation of a webserver in your windows PC with PHP and MySQL, I would suggest WAMP:

    www.wampserver.com/en/index.php

    I hope these help.
    One reason why MySQL is so popular is that it can be used in both windows AND linux.

    Thu Aug 4, 2005    Reply    New Discussion   
     
    Posted in Computers & Tech / Networking
    Author: nightfox Total-Replies: 6


    Ah, I am starting to get it! So like I have hosting here (with a cjb.net domain because I don't have enough money for a TLD :lol:) and I have the DNS set to ns2.astahost.com. I am a little confused by what spacewaste said. If what spacewaste said was true, wouldn't there be THOUSANDS of AstaHost.com name servers?

    And also, if you do a whois lookup on AstaHost.com, it's name servers are also pointed to ns1.astahost.com and ns2.astahost.com. If you have to wait about 24 hours for the DNS to update for a domain, how could AstaHost.com ever get updated??? All I can say is that I get everything else on web hosting. It is just the name server part that gets me lost!

    Wed Jun 29, 2005    Reply    New Discussion   
     
    Posted in Computers & Tech / How-To's and Tutorials / Programming / PHP
    Author: signatureimage Total-Replies: 44


    In this tutorial, we will explore the possibilities
    of generating a PDF file - on-the-fly - with PHP.

    The samples that are presented can be run on astahost.com.


    Why would we want to generate a PDF on-the-fly ?

    Well, we might want to include in the PDF some data that
    must be entered by our surfer, by means of a html form.
    Or we might want to include in the PDF some data that comes
    from a database that is updated by another process.
    Or some other reason. You invent one. All reasons are legit!


    (1)
    The first thing to do, when we want to generate a PDF file
    with PHP, is to check that the PHP libraries, that support the
    creation of PDF files, are present and available to PHP.
    When you install a PHP distribution on your own home test-machine,
    you have to make shure that these PHP PDF libraries are available.
    On the astahost.com server, they are available and active.
    Here is how to check this:
    - Create a new text file, let's name it phpinfo.php.
    - Insert the following code:

    CODE

    <?phpinfo();?>

    - Upload it to your web site.
    - Browse to your phpinfo.php file on your web site.
    - Check the results.

    The phpinfo() function generates a html page with all the information
    about the PHP installation, including the information about the Apache
    web server, the version and settings of the PHP compiler, and the
    supplemental PHP libraries that are installed and activated.

    We have to check the pdf libraries.
    The results should look something like this:

    PDF Support: enabled
    PDFlib Gmbh Version: 5.0.3
    Revision: $Revision: 1.112.2.11 $

    (This is the result of astahost.com - your own home test-machine may show
    a different result, depending on your PHP distribution.)

    Now that we have confirmation that the PDF libraries for PHP are OK,
    let's go on with our first PHP application:


    (2)
    A simple test.

    The creation of a PDF with PHP takes place a the web server, in memory.
    The first thing to do is to create a PHP PDF object,
    and the last thing to do is to destroy it.
    Here is that bit of code:

    CODE

    <?php
    $mypdf = PDF_new();

    PDF_delete($mypdf);
    ?>

    In between these two instructions, we will insert the rest of the PHP code.

    With this PHP PDF object, let's create a PDF file. In memory, not on the
    file-system of the web-server.
    The first thing to do is to open a PHP PDF file,
    and the last thing to do is to close it.
    Here is that bit of code:

    CODE

    <?php
    $mypdf = PDF_new();
    PDF_open_file($mypdf, "");

    PDF_close($mypdf);
    PDF_delete($mypdf);
    ?>

    In between these instructions, we will insert the rest of the PHP code.

    Once the PHP PDF file is open, we can start writing PDF pages to it.
    The first thing to do is to start a PHP PDF page,
    and the last thing to do is to end it.
    Here is that bit of code:

    CODE

    <?php
    $mypdf = PDF_new();
    PDF_open_file($mypdf, "");
    PDF_begin_page($mypdf, 595, 842);

    PDF_end_page($mypdf);
    PDF_close($mypdf);
    PDF_delete($mypdf);
    ?>

    In between these instructions, we will insert the rest of the PHP code.

    What do these two numbers (595 and 842) mean?
    They are the size of the page, measured in 1/72 inch.
    Our example specifies a width of 595 points = 595 x 1/72 inch = A4 paper
    Our example specifies a height of 842 points = 842 x 1/72 inch = A4 paper
    Your needs may vary...

    Once the PHP PDF page has been started, we can start writing dots to it.
    Let's write some text.
    First we have to choose a text font, and a text font size, in points.
    Here is that bit of code:

    CODE

    <?php
    $mypdf = PDF_new();
    PDF_open_file($mypdf, "");
    PDF_begin_page($mypdf, 595, 842);
    $myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
    PDF_setfont($mypdf, $myfont, 10);

    PDF_end_page($mypdf);
    PDF_close($mypdf);
    PDF_delete($mypdf);
    ?>

    The PHP PDF function PDF_findfont() looks for the Times-Roman font,
    and sets the $myfont PHP variable.
    Then the PHP PDF function PDF_setfont() uses the PHP PDF object,
    and the $myfont PHP variable to select a font text size of 10 points.

    Our example can now start to show some text on the page.
    Here is that bit of code:

    CODE

    <?php
    $mypdf = PDF_new();
    PDF_open_file($mypdf, "");
    PDF_begin_page($mypdf, 595, 842);
    $myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Sample PDF, constructed by PHP in real-time.", 50, 750);
    PDF_show_xy($mypdf, "Made with the PDF libraries for PHP.", 50, 730);
    PDF_end_page($mypdf);
    PDF_close($mypdf);
    PDF_delete($mypdf);
    ?>

    The PHP PDF function PDF_show_xy() prints the text at the specified positions.
    X=50 and Y=750 for the first text line, and
    X=50 and Y=730 for the second text line.
    Again, the values are in 1/72 inch.
    The origin (0,0) is in the BOTTOM-lefthand corner!
    So: Y=750 is ABOVE Y=730!

    Now the PHP PDF file - in memory is complete.
    How do we get it into the browser of our surfer?
    We will use the PHP PDF function PDF_get_buffer() to obtain a copy of the PHP PDF object
    in our own memory buffer, determine the length of it, create the http headers that are required
    for a PDF file, and let the web server send everything to the browser of the surfer:
    Here is that bit of code:

    CODE

    <?php
    $mypdf = PDF_new();
    PDF_open_file($mypdf, "");
    PDF_begin_page($mypdf, 595, 842);
    $myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Sample PDF, constructed by PHP in real-time.", 50, 750);
    PDF_show_xy($mypdf, "Made with the PDF libraries for PHP.", 50, 730);
    PDF_end_page($mypdf);
    PDF_close($mypdf);

    $mybuf = PDF_get_buffer($mypdf);
    $mylen = strlen($mybuf);
    header("Content-type: application/pdf");
    header("Content-Length: $mylen");
    header("Content-Disposition: inline; filename=gen01.pdf");
    print $mybuf;

    PDF_delete($mypdf);
    ?>

    - Save this code as a new text file, let's name it gen01.php.
    - Upload it to your web site.
    - Browse to your gen01.php file on your web site.
    - Check the results.
    - Your first PDF, generated by PHP, will show on your machine ! Congratulations !


    So, where do we go from here?
    Let's add some graphics to our PDF page.

    CODE

    $myimage = PDF_open_image_file($mypdf, "jpeg", "training_bground.jpg");
    PDF_place_image($mypdf, $myimage, 50, 650, 0.6);

    The PHP PDF function PDF_open_image_file() looks for the specified image file on the web server,
    and sets the $myimage PHP variable.
    Then the PHP PDF function PDF_place_image() uses the PHP PDF object,
    and the $myimage PHP variable to place a copy of the image onto the PDF page.
    Here is the complete code:

    CODE

    <?php
    $mypdf = PDF_new();
    PDF_open_file($mypdf, "");
    PDF_begin_page($mypdf, 595, 842);
    $myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Sample PDF, constructed by PHP in real-time.", 50, 750);
    PDF_show_xy($mypdf, "Made with the PDF libraries for PHP.", 50, 730);
    PDF_show_xy($mypdf, "A JPEG image, on 60 % of its original size.", 50, 710);
    $myimage = PDF_open_image_file($mypdf, "jpeg", "training_bground.jpg");
    PDF_place_image($mypdf, $myimage, 50, 650, 0.6);
    PDF_end_page($mypdf);
    PDF_close($mypdf);
    $mybuf = PDF_get_buffer($mypdf);
    $mylen = strlen($mybuf);
    header("Content-type: application/pdf");
    header("Content-Length: $mylen");
    header("Content-Disposition: inline; filename=gen02.pdf");
    print $mybuf;
    PDF_delete($mypdf);
    ?>

    - Save this code as a new text file, let's name it gen02.php.
    - Upload it to your web site.
    - Browse to your gen02.php file on your web site.
    - Check the results.

    Of course you will have to upload the jpeg image also !!!!!


    And we can add line-drawing functions too.
    The PHP PDF function PDF_setcolor() takes several parameters.

    CODE

    PDF_setcolor($mypdf, "stroke", "rgb", 1, 0, 0);

    The first parameter is the PHP PDF object.
    The second parameter instructs that the color is used for drawing lines.
    The third parameter indicates that the color definition will be in RGB (Red-Green-Blue).
    The following parameters are the values for the Red, Green, and Blue components of the color.
    Our example specifies 100% Red (1) - 0% Green (0) - 0% Blue (0).
    Look, another PDF quirck: 1 means 100%.

    The actual drawing is a three-stage process:
    - Determine the first point. PDF_moveto()
    - Determine the second pont. PDF_lineto()
    - Draw. PDF_stroke()

    CODE

    PDF_moveto($mypdf, 20, 735);
    PDF_lineto($mypdf, 575, 735);
    PDF_stroke($mypdf);

    Here is the complete code:

    CODE

    <?php
    $mypdf = PDF_new();
    PDF_open_file($mypdf, "");
    PDF_begin_page($mypdf, 595, 842);
    $myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
    PDF_setfont($mypdf, $myfont, 12);
    $myimage = PDF_open_image_file($mypdf, "jpeg", "training_bground.jpg");
    PDF_place_image($mypdf, $myimage, 30, 750, 0.6);
    // RGB colors: 1 = 100 % (255)
    PDF_setcolor($mypdf, "stroke", "rgb", 1, 0, 0);
    PDF_moveto($mypdf, 20, 735);
    PDF_lineto($mypdf, 575, 735);
    PDF_stroke($mypdf);
    PDF_moveto($mypdf, 20, 55);
    PDF_lineto($mypdf, 575, 55);
    PDF_stroke($mypdf);
    PDF_show_xy($mypdf, "A sample document.", 50, 40);
    PDF_end_page($mypdf);
    PDF_close($mypdf);
    $mybuf = PDF_get_buffer($mypdf);
    $mylen = strlen($mybuf);
    header("Content-type: application/pdf");
    header("Content-Length: $mylen");
    header("Content-Disposition: inline; filename=gen03.pdf");
    print $mybuf;
    PDF_delete($mypdf);
    ?>

    - Save this code as a new text file, let's name it gen03.php.
    - Upload it to your web site.
    - Browse to your gen03.php file on your web site.
    - Check the results.



    Besides lines, we can also draw rectangles and circles. And fill them with a color.
    The sample PHP PDF function PDF_setcolor($mypdf, "fill", "rgb", 1, 1, 0);
    prepares the fill color as yellow (Red = 100% - Green = 100% - Blue = 0%)
    The sample PHP PDF function PDF_setcolor($mypdf, "stroke", "rgb", 0, 0, 0);
    prepares the draw color as black (Red = 0% - Green = 0% - Blue = 0%)

    The actual drawing is a two-stage process:
    - Determine the area. PDF_rect() or PDF_circle()
    - Draw. PDF_fill_stroke()

    Here is the complete code:

    CODE

    <?php
    $mypdf = PDF_new();
    PDF_open_file($mypdf, "");
    PDF_begin_page($mypdf, 595, 842);
    $myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Drawings in PDF.", 450, 765);
    // RGB colors: 1 = 100 % (255)
    PDF_setcolor($mypdf, "fill", "rgb", 1, 1, 0);
    PDF_setcolor($mypdf, "stroke", "rgb", 0, 0, 0);
    PDF_rect($mypdf, 50, 500, 200, 300);
    PDF_fill_stroke($mypdf);
    PDF_setcolor($mypdf, "fill", "rgb", 0, 1, 0);
    PDF_setcolor($mypdf, "stroke", "rgb", 0, 0, 1);
    PDF_circle($mypdf, 400, 600, 100);
    PDF_fill_stroke($mypdf);
    PDF_end_page($mypdf);
    PDF_close($mypdf);
    $mybuf = PDF_get_buffer($mypdf);
    $mylen = strlen($mybuf);
    header("Content-type: application/pdf");
    header("Content-Length: $mylen");
    header("Content-Disposition: inline; filename=gen04.pdf");
    print $mybuf;
    PDF_delete($mypdf);
    ?>

    - Save this code as a new text file, let's name it gen04.php.
    - Upload it to your web site.
    - Browse to your gen04.php file on your web site.
    - Check the results.



    With the PHP instruction for () {} to do some repetitive things,
    we can easily create a page that contains a matrix of small squares:
    First the vertical lines, left to right:

    CODE

    for ($x=0; $x<=595; $x+=20)
    {
    PDF_moveto($mypdf, $x, 0);
    PDF_lineto($mypdf, $x, 842);
    PDF_stroke($mypdf);
    }

    Then the horizontal lines, bottom to top:

    CODE

    for ($y=0; $y<=842; $y+=20)
    {
    PDF_moveto($mypdf, 0, $y);
    PDF_lineto($mypdf, 595, $y);
    PDF_stroke($mypdf);
    }


    Moreover, let's make two pages, slightly different.
    Here is the complete code:

    CODE

    <?php
    $mypdf = PDF_new();
    PDF_open_file($mypdf, "");
    PDF_set_parameter($mypdf, "openaction", "fitpage");
    PDF_begin_page($mypdf, 595, 842);
    PDF_setcolor($mypdf, "stroke", "rgb", 0.90, 0.90, 0.90);
    for ($x=0; $x<=595; $x+=20)
    {
    PDF_moveto($mypdf, $x, 0);
    PDF_lineto($mypdf, $x, 842);
    PDF_stroke($mypdf);
    }
    for ($y=0; $y<=842; $y+=20)
    {
    PDF_moveto($mypdf, 0, $y);
    PDF_lineto($mypdf, 595, $y);
    PDF_stroke($mypdf);
    }
    $myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Drawingpaper.", 450, 765);
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setcolor($mypdf, "stroke", "rgb", 0.725, 0.725, 0.725);
    for ($x=0; $x<=595; $x+=50)
    {
    PDF_moveto($mypdf, $x, 0);
    PDF_lineto($mypdf, $x, 842);
    PDF_stroke($mypdf);
    }
    for ($y=0; $y<=842; $y+=50)
    {
    PDF_moveto($mypdf, 0, $y);
    PDF_lineto($mypdf, 595, $y);
    PDF_stroke($mypdf);
    }
    PDF_end_page($mypdf);
    PDF_close($mypdf);
    $mybuf = PDF_get_buffer($mypdf);
    $mylen = strlen($mybuf);
    header("Content-type: application/pdf");
    header("Content-Length: $mylen");
    header("Content-Disposition: inline; filename=gen05.pdf");
    print $mybuf;
    PDF_delete($mypdf);
    ?>

    - Save this code as a new text file, let's name it gen05.php.
    - Upload it to your web site.
    - Browse to your gen05.php file on your web site.
    - Check the results.

    Those of you who were very eager to learn, will have noticed one new PHP PDF function.
    Read the previous code again and try to find it. (It's in the begining of the code.)
    Or cheat and read the next paragraph.







    The PHP PDF function PDF_set_parameter($mypdf, "openaction", "fitpage"); allows you
    to have some influence over the behaviour of the Adobe Acrobat Reader,
    when the PDF is shown to your surfer.
    The setting of PDF parameters will be elaborated upon later in this post.
    But now is the time to add some PDF properties to our PDF file:
    The PHP PDF function PDF_set_info(); allows you to add meta information
    to the PDF file. Meta information is information about information. The information we will
    add will be visible with the full version of the Adobe Acrobat Reader, as document properties.

    Here is the complete code:

    CODE

    <?php
    $mypdf = PDF_new();
    PDF_open_file($mypdf, "");
    PDF_set_info($mypdf, "Creator", "gen06.php");
    PDF_set_info($mypdf, "Author", "John");
    PDF_set_info($mypdf, "Title", "Prototype (PHP)");
    PDF_set_info($mypdf, "Subject", "Sample");
    PDF_set_info($mypdf, "Keywords", "PHP PDF PDFlib");
    PDF_begin_page($mypdf, 595, 842);
    $myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Sample with the Document Properties. Can be observed in the full Acrobat Reader.", 50, 750);
    PDF_end_page($mypdf);
    PDF_close($mypdf);
    $mybuf = PDF_get_buffer($mypdf);
    $mylen = strlen($mybuf);
    header("Content-type: application/pdf");
    header("Content-Length: $mylen");
    header("Content-Disposition: inline; filename=gen06.pdf");
    print $mybuf;
    PDF_delete($mypdf);
    ?>

    - Save this code as a new text file, let's name it gen06.php.
    - Upload it to your web site.
    - Browse to your gen06.php file on your web site.
    - Check the results.



    So, what have we learned so far?
    - We create and destroy a PHP PDF object.
    - We open and close a PHP PDF file - in memory.
    - We start and end a PDF page.
    - We select a text-font and a text-font-size.
    - We draw text at a specified place on the page.
    - We select a fill color and a stroke color.
    - We draw lines, filled rectangles and circles.
    - We have influence on the behaviour of the Adobe Acrobat Reader.
    - We add meta data to the PDF file.
    - We copy the PDF file into a PHP buffer and send this - via http - to the browser of the surfer.

    Neat. What now?

    Let's find out how many lines of text we can put on one page, shall we?
    First approach: we use the PHP PDF function PDF_show_xy(); to draw the text,
    and with the PHP instruction for () {} we determine the vertical position of the line.

    Here is the complete code:

    CODE

    <?php
    $mypdf = PDF_new();
    PDF_open_file($mypdf, "");
    PDF_set_info($mypdf, "Creator", "gen07.php");
    PDF_set_info($mypdf, "Author", "John");
    PDF_set_info($mypdf, "Title", "Prototype (PHP)");
    PDF_set_info($mypdf, "Subject", "Sample");
    PDF_set_info($mypdf, "Keywords", "PHP PDF PDFlib");
    PDF_begin_page($mypdf, 595, 842);
    $myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
    PDF_setfont($mypdf, $myfont, 10);
    for ($y=820; $y>=00; $y-=15) {
    PDF_show_xy($mypdf, $y, 50, $y);
    PDF_show_xy($mypdf, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 70, $y);
    }
    PDF_end_page($mypdf);
    PDF_close($mypdf);
    $mybuf = PDF_get_buffer($mypdf);
    $mylen = strlen($mybuf);
    header("Content-type: application/pdf");
    header("Content-Length: $mylen");
    header("Content-Disposition: inline; filename=gen07.pdf");
    print $mybuf;
    PDF_delete($mypdf);
    ?>

    - Save this code as a new text file, let's name it gen07.php.
    - Upload it to your web site.
    - Browse to your gen07.php file on your web site.
    - Check the results.


    But why bother with calculating the vertical position ourselves?
    What if we change the text font size?
    Let's have the PHP PDF library do the hard work for us.
    Second approach: we use the PHP PDF function PDF_continue_text(); to draw the text,
    and we let the PHP PDF library calculate the exact vertical position of the line, according to
    the selected text font size...

    Here is the complete code:

    CODE

    <?php
    $mypdf = PDF_new();
    PDF_open_file($mypdf, "");
    PDF_set_info($mypdf, "Creator", "gen08.php");
    PDF_set_info($mypdf, "Author", "John");
    PDF_set_info($mypdf, "Title", "Prototype (PHP)");
    PDF_set_info($mypdf, "Subject", "Sample");
    PDF_set_info($mypdf, "Keywords", "PHP PDF PDFlib");
    PDF_set_parameter($mypdf, "openaction", "fitpage");
    PDF_begin_page($mypdf, 595, 842);
    $myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Times-Roman; 10 points. First line on: x = 30; y = 830", 30, 830);
    for ($y=0; $y<=80; $y++) {
    PDF_continue_text($mypdf, "80 Lines. ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
    }
    PDF_continue_text($mypdf, "Last line. (Line 82)");
    PDF_end_page($mypdf);
    PDF_close($mypdf);
    $mybuf = PDF_get_buffer($mypdf);
    $mylen = strlen($mybuf);
    header("Content-type: application/pdf");
    header("Content-Length: $mylen");
    header("Content-Disposition: inline; filename=gen08.pdf");
    print $mybuf;
    PDF_delete($mypdf);
    ?>

    - Save this code as a new text file, let's name it gen08.php.
    - Upload it to your web site.
    - Browse to your gen08.php file on your web site.
    - Check the results.

    So, now we know that Times-Roman 10 point text fits 82 lines on a A4 page.
    How about Times Roman 12 point?

    Here is the complete code:

    CODE

    <?php
    $mypdf = PDF_new();
    PDF_open_file($mypdf, "");
    PDF_set_info($mypdf, "Creator", "gen09.php");
    PDF_set_info($mypdf, "Author", "John");
    PDF_set_info($mypdf, "Title", "Prototype (PHP)");
    PDF_set_info($mypdf, "Subject", "Sample");
    PDF_set_info($mypdf, "Keywords", "PHP PDF PDFlib");
    PDF_set_parameter($mypdf, "openaction", "fitpage");
    PDF_begin_page($mypdf, 595, 842);
    $myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
    PDF_setfont($mypdf, $myfont, 12);
    PDF_show_xy($mypdf, "Times-Roman; 12 points. First line on: x = 30; y = 830", 30, 830);
    for ($y=0; $y<=66; $y++) {
    PDF_continue_text($mypdf, "66 Lines. ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
    }
    PDF_continue_text($mypdf, "Last line. (Line 68)");
    PDF_end_page($mypdf);
    PDF_close($mypdf);
    $mybuf = PDF_get_buffer($mypdf);
    $mylen = strlen($mybuf);
    header("Content-type: application/pdf");
    header("Content-Length: $mylen");
    header("Content-Disposition: inline; filename=gen09.pdf");
    print $mybuf;
    PDF_delete($mypdf);
    ?>

    - Save this code as a new text file, let's name it gen09.php.
    - Upload it to your web site.
    - Browse to your gen09.php file on your web site.
    - Check the results.

    Yes, now we know that Times Roman 12 point text fits only 68 lines on a A4 page.


    Let's compare three different text font sizes in one single PDF file, on three PDF pages.

    Here is the complete code:

    CODE

    <?php
    $mypdf = PDF_new();
    PDF_open_file($mypdf, "");
    PDF_set_info($mypdf, "Creator", "gen10.php");
    PDF_set_info($mypdf, "Author", "John");
    PDF_set_info($mypdf, "Title", "Prototype (PHP)");
    PDF_set_info($mypdf, "Subject", "Sample");
    PDF_set_info($mypdf, "Keywords", "PHP PDF PDFlib");
    PDF_begin_page($mypdf, 595, 842);
    $myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_setcolor($mypdf, "stroke", "rgb", 1, 0, 0);
    PDF_show_xy($mypdf, "Times-Roman; Page one", 50, 800);
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    $myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
    PDF_setfont($mypdf, $myfont, 12);
    PDF_setcolor($mypdf, "stroke", "rgb", 1, 0, 0);
    PDF_show_xy($mypdf, "Times-Roman; Page two", 50, 800);
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    $myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
    PDF_setfont($mypdf, $myfont, 14);
    PDF_setcolor($mypdf, "stroke", "rgb", 1, 0, 0);
    PDF_show_xy($mypdf, "Times-Roman; Page three", 50, 800);
    PDF_end_page($mypdf);
    PDF_close($mypdf);
    $mybuf = PDF_get_buffer($mypdf);
    $mylen = strlen($mybuf);
    header("Content-type: application/pdf");
    header("Content-Length: $mylen");
    header("Content-Disposition: inline; filename=gen10.pdf");
    print $mybuf;
    PDF_delete($mypdf);
    ?>

    - Save this code as a new text file, let's name it gen10.php.
    - Upload it to your web site.
    - Browse to your gen10.php file on your web site.
    - Check the results.


    Enough simple text PDF pages.



    Ever wondered how they create these left-side "Bookmarks" and "Thumbnails" in PDF?
    Well we can create that with PHP too !

    Let's create the "Thumbnails" first.
    The PHP PDF function PDF_add_thumbnail(); will create one "Thumnail" image
    for the PDF page that we are creating. So, this function must be called for every PDF page.
    When the Adobe Acrobat Reader presents the PDF file, your surfer will be able to click on one
    of the "Thumbnail" images, and the Adobe Acrobat Reader will then jump to the appropriate PDF page.
    Furthermore, we will use the PHP PDF function PDF_set_parameter($mypdf, "openmode", "thumbnails");
    to instruct the Adobe Acrobat Reader to show the "Thumbnail" tab when the PDF file is opened.


    Here is the complete code:

    CODE

    <?php
    $mypdf = PDF_new();
    PDF_open_file($mypdf, "");
    PDF_set_info($mypdf, "Creator", "gen11.php");
    PDF_set_info($mypdf, "Author", "John");
    PDF_set_info($mypdf, "Title", "Prototype (PHP)");
    PDF_set_info($mypdf, "Subject", "Sample");
    PDF_set_info($mypdf, "Keywords", "PHP PDF PDFlib");
    PDF_set_parameter($mypdf, "openmode", "thumbnails");
    PDF_set_parameter($mypdf, "openaction", "fitpage");
    $myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page one", 50, 800);
    $myimage = PDF_open_image_file($mypdf, "jpeg", "board1.jpg");
    PDF_place_image($mypdf, $myimage, 90, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 250, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 250, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 250, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 250, 0.5);
    PDF_add_thumbnail($mypdf,$myimage);
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page two", 50, 800);
    $myimage = PDF_open_image_file($mypdf, "jpeg", "board2.jpg");
    PDF_place_image($mypdf, $myimage, 90, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 250, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 250, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 250, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 250, 0.5);
    PDF_add_thumbnail($mypdf,$myimage);
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page three", 50, 800);
    $myimage = PDF_open_image_file($mypdf, "jpeg", "board3.jpg");
    PDF_place_image($mypdf, $myimage, 90, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 250, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 250, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 250, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 250, 0.5);
    PDF_add_thumbnail($mypdf,$myimage);
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page four", 50, 800);
    $myimage = PDF_open_image_file($mypdf, "jpeg", "board4.jpg");
    PDF_place_image($mypdf, $myimage, 90, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 250, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 250, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 250, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 250, 0.5);
    PDF_add_thumbnail($mypdf,$myimage);
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page five", 50, 800);
    $myimage = PDF_open_image_file($mypdf, "jpeg", "board5.jpg");
    PDF_place_image($mypdf, $myimage, 90, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 250, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 250, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 250, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 250, 0.5);
    PDF_add_thumbnail($mypdf,$myimage);
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page six", 50, 800);
    $myimage = PDF_open_image_file($mypdf, "jpeg", "board6.jpg");
    PDF_place_image($mypdf, $myimage, 90, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 250, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 250, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 250, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 250, 0.5);
    PDF_add_thumbnail($mypdf,$myimage);
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page seven", 50, 800);
    $myimage = PDF_open_image_file($mypdf, "jpeg", "board7.jpg");
    PDF_place_image($mypdf, $myimage, 90, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 90, 250, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 190, 250, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 290, 250, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 750, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 650, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 550, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 450, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 350, 0.5);
    PDF_place_image($mypdf, $myimage, 390, 250, 0.5);
    PDF_add_thumbnail($mypdf,$myimage);
    PDF_end_page($mypdf);
    PDF_close($mypdf);
    $mybuf = PDF_get_buffer($mypdf);
    $mylen = strlen($mybuf);
    header("Content-type: application/pdf");
    header("Content-Length: $mylen");
    header("Content-Disposition: inline; filename=gen11.pdf");
    print $mybuf;
    PDF_delete($mypdf);
    ?>

    - Save this code as a new text file, let's name it gen11.php.
    - Upload it to your web site.
    - Browse to your gen11.php file on your web site.
    - Check the results.

    Of course you will have to upload the jpeg images also !!!!!



    And now is the time to create PDF bookmarks.
    The PHP PDF function PDF_add_bookmark(); will create one "Bookmark"
    for the PDF page that we are creating. So, this function must be called for every PDF page.
    When the Adobe Acrobat Reader presents the PDF file, your surfer will be able to click on one
    of the "Bookmark" lines, and the Adobe Acrobat Reader will then jump to the appropriate PDF page.
    Furthermore, we will use the PHP PDF function PDF_set_parameter($mypdf, "openmode", "bookmarks");
    to instruct the Adobe Acrobat Reader to show the "Bookmarks" tab when the PDF file is opened.

    What is so special about the PDF bookmarks implementation, is the fact that the PDF bookmarks
    are "hierarchical". This means that the PDF bookmarks view is like a tree view, with different levels.
    Furthermore, some of these levels are visible, while other levels are invisible, or "collapsed".
    The PHP PDF function PDF_add_bookmark(); takes the required parameters to
    obtain these results.
    - The first parameter is the PHP PDF object.
    - The second parameter is the text of the bookmark.
    - The third parameter is the level (0 for the highest level)
    - The fourth parameter is 1 for children-are-visible, and 0 for children-are-invisible (collapsed).
    Sample:

    CODE

    $mytopparent = PDF_add_bookmark($mypdf, "First page", 0, 1);
    $mychild = PDF_add_bookmark($mypdf, "Second page", $mytopparent, 1);
    $mytopparent = PDF_add_bookmark($mypdf, "Third page", 0, 1);
    $mychild = PDF_add_bookmark($mypdf, "Fourth page", $mytopparent, 0);
    $mygrandchild = PDF_add_bookmark($mypdf, "Fifth page", $mychild, 1);
    $mygrandchild = PDF_add_bookmark($mypdf, "Sixth page", $mychild, 1);
    $mytopparent = PDF_add_bookmark($mypdf, "Seventh page", 0, 1);



    Here is the complete code:

    CODE

    <?php
    $mypdf = PDF_new();
    PDF_open_file($mypdf, "");
    PDF_set_info($mypdf, "Creator", "gen12.php");
    PDF_set_info($mypdf, "Author", "John");
    PDF_set_info($mypdf, "Title", "Prototype (PHP)");
    PDF_set_info($mypdf, "Subject", "Sample");
    PDF_set_info($mypdf, "Keywords", "PHP PDF PDFlib");
    PDF_set_parameter($mypdf, "openmode", "bookmarks");
    $myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page one", 50, 800);
    $mytopparent = PDF_add_bookmark($mypdf, "First page", 0, 1);
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page two", 50, 800);
    $mychild = PDF_add_bookmark($mypdf, "Second page", $mytopparent, 1);
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page three", 50, 800);
    $mytopparent = PDF_add_bookmark($mypdf, "Third page", 0, 1);
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page four", 50, 800);
    $mychild = PDF_add_bookmark($mypdf, "Fourth page", $mytopparent, 0);
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page five", 50, 800);
    $mygrandchild = PDF_add_bookmark($mypdf, "Fifth page", $mychild, 1);
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page six", 50, 800);
    $mygrandchild = PDF_add_bookmark($mypdf, "Sixth page", $mychild, 1);
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page seven", 50, 800);
    $mytopparent = PDF_add_bookmark($mypdf, "Seventh page", 0, 1);
    PDF_end_page($mypdf);
    PDF_close($mypdf);
    $mybuf = PDF_get_buffer($mypdf);
    $mylen = strlen($mybuf);
    header("Content-type: application/pdf");
    header("Content-Length: $mylen");
    header("Content-Disposition: inline; filename=gen12.pdf");
    print $mybuf;
    PDF_delete($mypdf);
    ?>

    - Save this code as a new text file, let's name it gen12.php.
    - Upload it to your web site.
    - Browse to your gen12.php file on your web site.
    - Check the results.



    How about some Powerpoint Presentation Effects ?
    The Adobe Acrobat Reader is capable of showing some nifty page-transition effects.
    We will use PHP to add the instructions required for these effects into our PDF file.
    The PHP PDF function PDF_set_parameter($mypdf, "transition", $effect); will be used.

    Here is the complete code:

    CODE

    <?php
    $mypdf = PDF_new();
    PDF_open_file($mypdf, "");
    PDF_set_info($mypdf, "Creator", "gen13.php");
    PDF_set_info($mypdf, "Author", "John");
    PDF_set_info($mypdf, "Title", "Prototype (PHP)");
    PDF_set_info($mypdf, "Subject", "Sample");
    PDF_set_info($mypdf, "Keywords", "PHP PDF PDFlib");
    $myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Demonstration of PDF effects. Please Paginate.", 50, 800);
    PDF_set_parameter($mypdf, "openaction", "fitpage");
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page one", 50, 800);
    for ($y=0; $y<=66; $y++) { PDF_continue_text($mypdf, "66 lines. ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");}
    PDF_set_parameter($mypdf, "transition", "split");
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page two", 50, 800);
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page three", 50, 800);
    for ($y=0; $y<=66; $y++) { PDF_continue_text($mypdf, "66 lines. ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");}
    PDF_set_parameter($mypdf, "transition", "blinds");
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page four", 50, 800);
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page five", 50, 800);
    for ($y=0; $y<=66; $y++) { PDF_continue_text($mypdf, "66 lines. ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");}
    PDF_set_parameter($mypdf, "transition", "box");
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page six", 50, 800);
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page seven", 50, 800);
    for ($y=0; $y<=66; $y++) { PDF_continue_text($mypdf, "66 lines. ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");}
    PDF_set_parameter($mypdf, "transition", "wipe");
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page eight", 50, 800);
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page nine", 50, 800);
    for ($y=0; $y<=66; $y++) { PDF_continue_text($mypdf, "66 lines. ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");}
    PDF_set_parameter($mypdf, "transition", "dissolve");
    PDF_set_value($mypdf, "duration", 3);
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page ten", 50, 800);
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page eleven", 50, 800);
    for ($y=0; $y<=66; $y++) { PDF_continue_text($mypdf, "66 lines. ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");}
    PDF_set_parameter($mypdf, "transition", "glitter");
    PDF_set_value($mypdf, "duration", 3);
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page twelve", 50, 800);
    PDF_end_page($mypdf);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "Page thirteen", 50, 800);
    for ($y=0; $y<=66; $y++) { PDF_continue_text($mypdf, "66 lines. ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");}
    PDF_set_parameter($mypdf, "transition", "replace");
    PDF_end_page($mypdf);
    PDF_close($mypdf);
    $mybuf = PDF_get_buffer($mypdf);
    $mylen = strlen($mybuf);
    header("Content-type: application/pdf");
    header("Content-Length: $mylen");
    header("Content-Disposition: inline; filename=gen13.pdf");
    print $mybuf;
    PDF_delete($mypdf);
    ?>

    - Save this code as a new text file, let's name it gen13.php.
    - Upload it to your web site.
    - Browse to your gen13.php file on your web site.
    - Check the results.



    And one more particularity of the PDF file, is the possibility to add "notes".
    The PHP PDF function PDF_add_note(); will be used.
    When the Adobe Acrobat Reader presents the PDF file to your surfer, he/she will
    have the possibility to open the note by double-clicking on the little note icon,
    placed somewhere in the text of the PDF page.

    Here is the complete code:

    CODE

    <?php
    $mypdf = PDF_new();
    PDF_open_file($mypdf, "");
    PDF_set_info($mypdf, "Creator", "gen14.php");
    PDF_set_info($mypdf, "Author", "John");
    PDF_set_info($mypdf, "Title", "Prototype (PHP)");
    PDF_set_info($mypdf, "Subject", "Sample");
    PDF_set_info($mypdf, "Keywords", "PHP PDF PDFlib");
    $myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
    PDF_begin_page($mypdf, 595, 842);
    PDF_setfont($mypdf, $myfont, 10);
    PDF_show_xy($mypdf, "When we look more closely at this way of working,", 50, 750);
    PDF_add_note($mypdf, 245, 660, 550, 770, "Yes, what is going to happen here? We are not used to work that way, and now this statement stares at us ! ", "What do you mean, WORK ?", "note", 0);
    PDF_show_xy($mypdf, "we can clearly see the more open side of this project.", 50, 730);
    PDF_end_page($mypdf);
    PDF_close($mypdf);
    $mybuf = PDF_get_buffer($mypdf);
    $mylen = s

    Wed May 4, 2005    Reply    New Discussion   
     
    Posted in Computers & Tech / Programming / Scripting / PHP
    Author: mastercomputers Total-Replies: 12


    If you're looking for a Windows All-in-One Web Server (Windows Apache MySQL PHP). I highly recommend Uniform Server which is configured in a ready to use state in live production and is usually ahead of all the other All-in-One packages when it comes to updating their software.

    If you're looking at competing with Facebook, be sure to check out the OpenSocial API which will help in creating your social network quicker, as well as being capable of interacting with other social networks that use the API too.


    Cheers,


    MC

    Sun Feb 14, 2010    Reply    New Discussion   
     
    Posted in Computers & Tech / Networking
    Author: sitekeen Total-Replies: 12


    Have you ever wanted to setup a domain which will directly point to your local webserver?
    Here's how:

    Step 1. Set up your DynDNS.com account.

    Register for a free account at DynDNS. Agree to the site's terms, and use a legitimate email address to complete registration. Once in awhile, DynDNS will email you at that address asking you to confirm that it continue your service.

    Log into your new account. Go to the "My Services" area on the left side. Under "Host Level Services" click "Add Host Services." There, click "Add Dynamic DNS Host." DynDNS will autofill your IP address (if you're doing this from your home computer). Choose a domain and type in a custom subdomain, which can be anything from lifehacker.kicks-ass.org or john.is-a-geek.com or gtrapani.dyndns.org, like below: dyndns.jpg



    Step 2. Set up your computer to update DynDNS.

    Now that your computer is registered with DynDNS, each time your computer's IP address changes, it has to let DynDNS know. This can be done either with free updater client software or through your router.

    If your computer is connected directly to the Internet, download the DynDNS updater client for Mac or Windows here. Install and enter your DynDNS information so that your computer can update DynDNS's database regularly.

    If you are behind a router, you're in luck. Most modern routers support dynamic DNS services. Here's a screenshot from my router's interface (yours will look different) for with DynDNS settings: dyndnsrouter.jpg



    Step 3. You're done. Give your new domain a spin!

    Type your new domain name by entering it in your web browser's address bar. It should resolve to your home server. From here you can publicize or bookmark your server's new domain name no matter how often your IP address changes.

    Hope this helped you all out there!
    cya

    Wed Oct 11, 2006    Reply    New Discussion   
     
    Posted in Astahost / Hosted Members Support / Misc. Issues with no other for..
    Author: XIII Total-Replies: 17


    I know that what will i type now may be strange, even me i feel strange to say that while i could get my account suspended by that, but i feel that we should protect our lovely free hosting provider ASTAHOST, that what makes me type this.
    i was travelling for a while "as always :P " and when i got back, as useual, i found my hosting credits in negative :( ofcourse didn't feel strange, i used to that, anyway, i went to my site, i found it working and that's strange, i'm not even -1.xx or something like that, it's more than 8 points negative, i think there is a bug in the hosting credits system or something wrong which made it like that, i think most of people may use that not to post here and at the same time have thier accounts working already.
    we need an admin to fix that please, we need astahost to go on.
    Viva la ASTAHOST

    My domain name is www.karlokazo.net, it's not spamming or advertising, it nearly has nothing already ;) just to let admin know it for more easier work.

    this is a copy for my credits before this post if it's still counting:

    QUOTE

    HOSTING CREDITS : (-)8.32 (Negative)
    Your Hosting Credits have Expired. You will need atleast 4 credits to UN-SUSPENDED your hosting Account. Account is UN-suspended only when a user has more than 3 hosting credits. You get credits by making forum posts. After you make the required posts, your hosting account will be active automatically within a few hours.
    The Hosting Credits determine the amount of days you can remain inactive. We recommend that you maintain a sufficient amount of hosting credits (more than 10). This will give you enough time, incase you cannot stay active due to any consequences.
    PS : Hosting credits depend upon the size and content of the post. The number of posts you make, has no effect on hosting credits you earn. Know more..
    ATTENTION : All posts are strictly reviewed. Any member accused of spamming may be banned with an immediate termination of web hosting account (if hosted). Also Check out, Hottest Paid Web Hosting Offer at Computing Host ( partner site ) [ 50mb space @ $10 / YEAR! ]
    PS: Paid Accounts are hosted on separate dedicated servers for unmatched performance and uptime!


    I'm sure admins will fix it :(

    Fri Jun 16, 2006    Reply    New Discussion   
     
    Posted in Computers & Tech / Databases
    Author: mapuana Total-Replies: 16


    QUOTE (sPyfReEsTyLe)

    Hi i would like to create a database but i do not know how. Could some one please show me how.
    [post="50825"]<{POST_SNAPBACK}>[/post]

    Very nice script...I say the same thing...

    MySql is a free and very easy to use, easy to understand web-based database. The latest version is very user friendly, and you can even export your data as excel, edit it, and reinsert it into the database very easily, if you are more comfortable using that format. It is very well documented and I believe it has a support forum community as well. However, you'd need to know how to code it, write queries.

    My overall suggestion to you is this. Search tHotscripts.com, sourceforge.net, etc. for a free script that does what you need your database to do (like drive an address book, website, customer database, blah blah). Basically, search for a PHP script and download it. And if you can spend a few bucks (between 20USD and up), you can find commercial scripts which tend to be much better written, efficient and visually appealing. This will give you a front-end to display your data and work with the database, possibly even an admin side so that even the most inexperienced computer user can use the software.

    Mon Aug 29, 2005    Reply    New Discussion   
     
    Posted in Computers & Tech / How-To's and Tutorials / Websites and Web Designing
    Author: Habble Total-Replies: 16


    While browsing the internet, you've most likely heard people mention different web scripting languages? What are they? What do they do? What do they stand for? You'll find all the answers here! I've tried to list some of the most common languages for your benefit

    HTML
    Probably one of the languages you will hear about the most, HTML stands for Hyper-Text Markup Language. HTML is the main language used to code websites. Without HTML, there would be no websites! If you opened up the source code for this page, and looked throuugh it, you'd find little bits of code that look <b>like</b> <i>this</i>. The things like <this> are called tags. Tags can either affect what's on the page at that spot, e.g. <img src="hello.gif"> would place an image with the filename "happy.gif" in that spot on the page. Or they can affect what comes between them, e.g. <u>Hello!</u> would show up as Hello!. Note the ending tag (</u>) that tells the browser when to stop underlining the text.
    File extensions: .html, .htm
    Find out more: http://www.w3.org/html/

    XHTML
    XHTML stands for Extensible Hyper-Text Markup Language. It is designed to show as both XML (See below) and HTML, allowing a wider variety of browsers to view it properly. XHTML users must conform to certain rules, such as tags must be written in lowercase, and elements cannot overlap.
    File extensions: .xhtml, .html, .htm
    Find out more: http://www.w3.org/MarkUp/

    XML
    XML stands for Extensible Markup Language. It is similar to HTML, except it's designed to be used not only in web browsers, but a wide variety of other programs. XML offers an easy way to lay things out in an application. XML is also designed to be clear and concise, and easy readable by people. XML allows you to create tags that will appear differently in a program, and therefore making an extremely flexible language.
    File extension: .xml
    Find out more: http://www.w3.org/XML/

    CSS
    CSS stands for Cascading Style Sheets. CSS is used to style a website, setting colours, backgrounds, fonts etc. Without excessive use of tags surrounfing the whole page. A typical CSS Sheet would look like this:
    body { background-color: #DDDDDD; font-family: Verdana; font-size: 10px; color: #000000; }
    a:link { text-decoration: none; color: #FF0000; }
    a:active { text-decoration: none; color: #FF0000; }
    a:visited { text-decoration: none; color: #FF0000; }
    a:hover { text-decoration: underline; color: #00FF00; }

    As you can see, we declare what element we're setting the style of (e.g. body), then inside { } brackets, we define the style attributes in the form attribute: value;. Style sheets can be placed within <style> tags in the head of the document, called from an external style sheet using the <link> tag, or the style for a particular element can be set using the style="" attribute.
    File extension: .css
    Find out more: http://www.w3.org/Style/CSS/

    PHP
    PHP stands for Hypertext Preprocessor (Don't ask me how!) It's a server-side scripting language, which means it's interpreted and converted to HTML before the browser recieves it. PHP is placed within <?php ?> tags in a document. To interpret PHP, you must be accessing the document through a server that can interpret PHP, rather than just locally. PHP is used for many things, connecting to databases, creating cookies, performing calculations and more. It's one of the most used scripting languages, and can be extremely powerful.
    File extension: .php (Although you can set other extensions to allow PHP functionality with)
    Find out more: http://www.php.net

    JavaScript
    JavaScript, not to be confused with Java, is a clientside scripting language, this means that the users browser does all the processing. Disadvantages with this are that you're relying on the fact that the user has an up-to-date browser for the scripts to work. JavaScript is placed withing &lt;script> tags, or a source code is defined using &lt;script src="">. JavaScript works like many other scripting languages. It is object-oriented, and is designed to interact with HTML elements.
    File extension: .js
    Find out more: http://www.javascript.com

    SQL
    SQL stands for Structured Query Language. It's the language used by SQL Database managers, such as MySQL, to carry out requests. Although it isn't a very large language, it's important for every webmaster using Databases to know. To get all results from a table using SQL, we would call "select * from tablename;", or if we wanted to select a specific column and a specific row, we could call "select lastname from tablename where firstname = 'John';"
    All commands in SQL require a semicolon at the end, except for when using PHP's SQL functions, or when using the "use" function, to switch databases. SQL can be either called directly, or SQL commands can be read from a file.
    File extensions: .sql
    Find out more: http://www.sql.org/

    AJAX
    AJAX isn't really an entirely different language, but people use it to refer to the funtions in JavaScript used to remotely access a webpage. This is extremely useful for Webmasters who don't like the idea of reloading pages all the time to refresh information.
    Find out more: http://en.wikipedia.org/wiki/Ajax_(programming)

    Thu Sep 6, 2007    Reply    New Discussion   
     

    Ask a Question (w/o registration) to get Quick Answers!


    astaHost