Monthly Archives: July 2009


pdftohtml converters  PDF documents into HTML format, which is more suitable for Internet publishing. The converter produces HTML documents with texts, pictures, graphics and bookmarks.

pdftohtml software does not require Adobe Acrobat, or even Acrobat Reader.

Install pdftohtml on Fedora/Linux:

# yum install pdftohtml
# which pdftohtml

Usage: pdftohtml [Option] <PDF File> [<HTM File>]



Posted by on July 29, 2009 in Fedora, LAMP, Linux, Tips, Tricks, Web Services


Tags: , ,

pdftk – fedora – merge pdf files

Pdftk allows to manipulate PDF easily and freely. It does not require Acrobat, and it runs on Windows, Linux, Mac OS X, FreeBSD and Solaris etc.


  • Merge PDF Documents
  • Split PDF Pages into a New Document
  • Rotate PDF Pages or Documents
  • Decrypt Input as Necessary (Password Required)
  • Encrypt Output as Desired
  • Fill PDF Forms with FDF Data or XFDF Data and/or Flatten Forms
  • Apply a Background Watermark or a Foreground Stamp
  • Report on PDF Metrics such as Metadata, Bookmarks, and Page Labels
  • Update PDF Metadata
  • Attach Files to PDF Pages or the PDF Document
  • Unpack PDF Attachments
  • Burst a PDF Document into Single Pages
  • Uncompress and Re-Compress Page Streams
  • Repair Corrupted PDF (Where Possible)

Install pdftk on fedora/linux:

# yum install pdftk
# which pdftk

Merge Two or More PDFs into a New Document
# pdftk 1.pdf 2.pdf 3.pdf cat output 123.pdf
Leave a comment

Posted by on July 29, 2009 in Fedora, LAMP, Linux, php, Tips, Tricks, Web Services


Tags: , , , , , , ,

Resume Builder pdf2txt, word2txt

Reading PDF Files

XPDF package includes “pdftotext.” You have to install XPDF/pdftotext then run the following PHP statement to get the PDF text:

$txtcontent = exec('/usr/local/bin/pdftotext svnlabs.pdf -');

Reading DOC Files

This package is called Antiword. Here’s the PHP code to grab the Word DOC content:

$txtcontent = exec('/usr/local/bin/antiword svnlabs.doc');
1 Comment

Posted by on July 28, 2009 in Fedora, LAMP, Linux, php, Tips, Tricks, Web Services


Tags: , , , , , ,

Publish HTML2PDF

HTMLDOC converts HTML files and web pages into HTML, PostScript and PDF files suitable for on-line viewing and printing. HTMLDOC is used for anything that needs to be viewed or printed including on-line billing, books, financial statements, automated network configuration guides, mailing lists and labels, marketing flyers, quarterly reports, technical manuals, and users manuals. We can use HTMLDOC for all of documentation and reports, and it is the core of our PDF-o-matic demonstration page.



A limited-use open source version is also available at

# htmldoc --webpage -f output.pdf filename.html ENTER

# htmldoc --book -f 12book.pdf 1book.html 2book.html --titlefile bookcover.jpg ENTER

Leave a comment

Posted by on July 28, 2009 in Fedora, Linux, php, Tips, Tricks, Web Services


Tags: , ,

Configure Amazon EC2

1.Boot 2 linux servers on EC2
2.Assign elastic IP to each of them
3.Register a domain (eg
4.On the domain settings – create 2 host records – and and point each record to each of the elastic IPs.
5.On your 2 nameserver instances – create dns zone for ns1. and ns2 respectively
6.Make ns2 a slave of ns1 – you can if you wish add ns3… ns4.. etc etc but its not necessary unless your site is getting millions of users.
7.Boot another EC instance and install the Scalr application.
8.Create a user on ns1. called “named” that has permissions to update the dns zone records on ns1.
9.The DNS settings of the scalr application will refer to the nameservers ns1. with user “named” and password as set on ns1.
10.Your application for example will have the domain  Register this domain and set its nameservers to your ns1. and ns2 mentioned previously.
11.You need to first create a new zone file on ns1 for
12.In Scalr when asked for the application domain name – simply enter – and scalr will handle the rest.


You will need to register a domain name with a domain registrar.  After registering, you will need to enter your NS records for the domain name.  The NS records should point to a Domain Name Server (DNS).  Most registrars require at least two DNS servers to eliminate a single point of failure.

Some registrars provide free DNS services.  If you choose such a registrar, you would need to add a CNAME record for your sub-domain and ask any DNS application support related questions to your registrar.

Alternatively, you can launch and configure your own DNS servers on Amazon EC2.  A popular choice for Linux based DNS servers is BIND:

Another option is to outsource your DNS servers using a third-party provider, for example



Tags: , , , , ,

Mysql useful queries

Select DATE_FORMAT (NOW(), ‘%Y’) – DATE_FORMAT(BirthDate, ‘%Y’) – (DATE_FORMAT(NOW(), ’00-%m-%d’) < DATE_FORMAT(BirthDate, ’00-%m-%d’)) AS Age From tbl_member where 1;

Change collation:

Alter table `tbl_student` convert to character set utf8 collate utf8_swedish_ci;

Shift mysql column:

ALTER TABLE tableName MODIFY column column_2 int AFTER column_1;

Get video info with user info:
SELECT `video_id` , `video_title` ,
( SELECT userid FROM tbl_members
WHERE `member_id` = v.member_id
) AS owner
FROM `tbl_video` AS v

Select concat(a.Day,’_’,a.Hour) as IDX From tbl_time;

Switch Case:
SELECT, a.group_name ,
WHEN a.is_feature= ‘t’ THEN ‘Featured’
ELSE ‘Unfeatured’
END as Featured
FROM `tbl_member_groups` a;

2 Way Friendship:
SELECT CASE WHEN mf.member_id = ‘”78″
THEN mf.friend_id
ELSE mf.member_id
END AS f_id,
FROM tbl_member
WHERE mid = f_id
) AS uname
FROM tbl_member_friend AS mfWHERE ( member_id = ’78’ OR friend_id = ’78’ ) AND is_accepted = ‘t’;

SELECT b.ID as us_id,c.ID as ctu,c.Nationality,e.Name as cname, b.Username, d.Name FROM user b
LEFT JOIN teacher c ON b.ID = c.UserID
LEFT JOIN teacher_photo d ON c.ID = d.TeacherID
LEFT JOIN country e on e.ID=c.Nationality
IN ( SELECT CASE WHEN tf.user_id = ‘$ID’
THEN tf.friend_id
ELSE tf.user_id
END AS f_id
FROM friend tf
user_id = ‘$ID’
OR friend_id = ‘$ID’
AND tf.`is_accept` = ‘t’ order by tf.date_added desc

SELECT a. * , c.Nationality, e.Name AS cname, b.Username, d.Name
FROM forum_reply a
LEFT JOIN user b ON a.poster_thread_id = b.ID
LEFT JOIN teacher c ON a.poster_thread_id = c.UserID
AND b.ID = c.UserID
LEFT JOIN teacher_photo d ON c.ID = d.TeacherID
LEFT JOIN country e ON e.ID = c.Nationality
WHERE a.thread_id = ‘1’;

Remove duplicate records:
SELECT * FROM old_table WHERE 1 GROUP BY [COLUMN TO remove duplicates BY];

Stored Porcedures:
CREATE PROCEDURE simpleproc (OUT param1 INT)
SELECT * FROM testimonial;
CALL simpleproc(@a);

SQL Injection:
Select * from tbl_user where name = ‘sandeep’ OR ‘1’ = ‘1’;

Insert Duplicate:
INSERT INTO `teacher_photo` SET TeacherID =7, Name = ‘7-teacher.jpeg’,
FileType = ‘image/jpeg’ ON DUPLICATE KEY UPDATE Name = ‘7-teacher.jpeg’, FileType = ‘image/jpeg’;

Reporting month year wise:
Select count(hits), month(add_date) m, year(add_date) y From ‘sales’ where 1 group by m,y;

Interchange columns values:
Update userinfo set sex = case
when sex = ‘f’ then m
when sex = ‘m’ then f

Case sensitive data:
Select * From member where BINARY uname = “sandeep”;

Get third max mark holder:
Select * From ‘marks’ where 1 order by mark desc limit 2,1;

Get duplicate in table:
Select title From ‘books’ group by title having count(*) > 1;

Set Character set to UTF-8:
SET NAMES ‘utf8’;

Check for Online:
FROM tbl_member_groups

Leave a comment

Posted by on July 11, 2009 in LAMP, MySQL, Tips, Tricks


Tags: , , , , , , , ,

Form's array element in javascript

How to access form’s array element in javascript?

Web Post
Mobile Post
Application Post
Open Source Post


<form action=”<?=$_SERVER[‘PHP_SELF’]?>” method=”post”>

<input name=”post[]” type=”checkbox” value=”web” /> Web Post
<input name=”post[]” type=”checkbox” value=”mobile” /> Mobile Post
<input name=”post[]” type=”checkbox” value=”application” />Application Post
<input name=”post[]” type=”checkbox” value=”open” /> Open Source Post


<script type=”text/javascript”>

if([i].type==”checkbox” &&[i].name==”post[]”)




Leave a comment

Posted by on July 11, 2009 in javascript, Tips, Tricks


Tags: , ,