Monday, January 12, 2009

Creating PDF using PHP

Portable Document Format (PDF) is an open file format created and controlled by Adobe Systems.
PDF files are very useful for data reporting. bcoz now every system having a pdf file reader.

The PDF functions in PHP can create PDF files using the PDFlib library created by Thomas Merz.
All of the functions in PDFlib and the PHP module have identical function names and parameters.


Using HTML2PDF we can convert html page to pdf.

HTML2PDF is a simple HTML to PDF tool which can quickly and easily convert thousands of HTML pages into PDF reports.

HTML2PDF (include PDFcamp + DocConverter COM) is the easiest way to convert your web pages and DOC, RTF, TXT, PPT, XLS files into PDF documents, HTML2PDF quickly and accurately transforms well-formed HTML, DOC, RTF, TXT, PPT, XLS files into PDF files, the HTML2PDF supports both server and client sides, the end-user doesn't need any software (Adobe Acrobat and Reader NOT required).

HTML2PDF (include PDFcamp + DocConverter COM) offers you the flexibility and speed you need to convert multiple HTML, DOC, RTF, TXT, PPT, XLS files into PDF format. Whatever the reason, pdf files can be created directly from MS Internet Explorer (or at background) and even emailed to a recipient/recipients simultaneously.

HTML2PDF Features:

* HTML2PDF can create page headers, footers and page numbers
* HTML2PDF can convert HTML, DOC, RTF, TXT, PPT, XLS files to PDF files on the fly
* HTML2PDF supports adjust paper orientation and size to accommodate HTML documents
* HTML2PDF supports nested tables
* HTML2PDF supports all elements in HTML document, include asp, cgi, css, Java Applets, flash, cookie etc.
* HTML2PDF supports dynamic page breaks with headers and footers
* HTML2PDF supports convert a URL or local file to PDF file
* HTML2PDF can convert .doc/.html/.rtf/.txt/.xls etc files to PDF files from a Command Line Tool, this Tool without any user intervention
* HTML2PDF supports command line operation (for manual use or inclusion in scripts)

How convert a HTML, DOC, RTF, TXT, PPT, XLS files to PDF files with DocConverter COM?

Step 1:
Please download and install the PDFcamp (PDF Writer) software,
http://www.verypdf.com/pdfcamp/pdfcamp_setup.exe

Step 2:
Please download and register the DocConverter COM software,
http://www.toppdf.com/pdfcamp/doc2pdf_com_trial.zip
Please register the pdfout.dll file in your system, for example,
~~~~~~~~~~~
regsvr32 pdfout.dll
~~~~~~~~~~~

Step 3:
Please run the html2pdf.exe software from the Command Line Window to try, the html2pdf.exe software is included in the DocConverter COM package,

For example:
html2pdf.exe "http://www.yahoo.com" "c:\yahoo.pdf"
html2pdf.exe "http://www.google.com/search?sourceid=navclient&ie=UTF-8&oe=UTF-8&q=pdf" "c:\google.pdf"
html2pdf.exe "C:\example.doc" "C:\example.pdf"
html2pdf.exe "C:\example.xls" "C:\example.pdf"


Now You have converted HTML, DOC, RTF, TXT, PPT, XLS files to PDF documents.

Step 5:
Now, you can call the html2pdf.exe software from your Delphi, C++, VB, BCB etc. applications.

HTML2PDF - Converting your HTML, DOC, RTF, TXT, PPT, XLS files to PDFs has never been easier! Combine several of your HTML, DOC, RTF, TXT, PPT, XLS files into a single PDF file. Convert a HTML file into a PDF file, or convert ANY file format to PDF file!

But f you want a simplier method to create PDF file without doing the above installations on your server to use PDF function in your scripts, then use FPDF.

FPDF is a PHP class which allows to generate PDF files with pure PHP, that is to say without using the PDFlib library. F from FPDF stands for Free: you may use it for any kind of usage and modify it to suit your needs.

Advantages: high level functions. Here is a list of its main features:

* Choice of measure unit, page format and margins
* Page header and footer management
* Automatic page break
* Automatic line break and text justification
* Image support (JPEG and PNG)
* Colors
* Links
* TrueType, Type1 and encoding support
* Page compression

FPDF requires no extension (except zlib to activate compression) and works with PHP4 and PHP5.

What languages can I use?
The class can produce documents in many languages other than the Western European ones: Central European, Cyrillic, Greek, Baltic and Thai, provided you own TrueType or Type1 fonts with the desired character set. Chinese, Japanese and Korean are supported too.

What about performance?
Of course, the generation speed of the document is less than with PDFlib. However, the performance penalty keeps very reasonable and suits in most cases, unless your documents are particularly complex or heavy.

Here, we are going to see on converting HTML 2 PDF using PHP. we would be seeing how to use some free open source PHP scripts to accomplish this file conversion.

FPDF: The PDF Generator

The first and the main base for this file conversion is FPDF library. FPDF is a pure PHP class to generate PDF files on the fly. Let us start the PDF generation with a simple Hello world display.

PHP Code:

AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
?>


To generate a pdf file, first we need to include library file fpdf.php. Then we need to create an FPDF object using the default constructor FPDF(). This constructor can be passed three values namely page orientation (portrait or landscape), measure unit, and page size (A4, A5, etc.,). By default pages are in A4 portrait and the measure unit is millimeter. It could have been specified explicitly with:

PHP Code:
$pdf=new FPDF('P','mm','A4');

It is possible to use landscape (L), other page formats (such as Letter and Legal) and measure units (pt, cm, in).

Then we have added a page to our pdf document with AddPage(). The origin is at the upper-left corner and the current position is by default placed at 1 cm from the borders; the margins can be changed with the function SetMargins().

To print a text, we need to first select a font with SetFont(). Let us select Arial bold 16:

PHP Code:
$pdf->SetFont('Arial','B',16);

We use Cell() function to output a text. A cell is a rectangular area, possibly framed, which contains some text. It is output at the current position. We specify its dimensions, its text (centered or aligned), if borders should be drawn, and where the current position moves after it (to the right, below or to the beginning of the next line). To add a frame, we would do this:

PHP Code:
$pdf->Cell(40,10,'Hello World !',1);

Finally, the document is closed and sent to the browser with Output(). We could have saved it in a file by passing the desired file name.

There are lot more functions in FPDF.

Need more info? click
here.


HTML2FPDF: The Converter

HTML2FPDF is a PHP Class library that uses the FPDF class library to convert HTML files to PDF files. This library consist of three classes namely PDF, HTML2FPDF and FPDF (modified FPDF class). The class PDF extends the class HTML2FPDF that extends the class FPDF.

Now let us see, how to convert a sample html page into a PDF file using HTML2FPDF Library. The html page contains a table that lists a few nations with their corresponding national flags. Below is the code for the conversion.

PHP Code:
AddPage();
$fp = fopen("sample.html","r");
$strContent = fread($fp, filesize("sample.html"));
fclose($fp);
$pdf->WriteHTML($strContent);
$pdf->Output("sample.pdf");
echo "PDF file is generated successfully!";
?>



First, we need to include the html2fpdf.php file that contains the HTML2FPDF class and an object is created using the constructor HTML2FPDF(). Then a new page is added to the pdf document using the function AddPage(). The html contents are read from the sample.html file using file functions. Then the html contents are written in to the pdf format using WriteHTML() function. The above sample code with the sample html file and images and the html2fpdf class libraries can be downloaded
here.

The HTML2FPDF class library will be working best with the XHTML 1.0. Also the class does not support all the features available with HTML. To know the supported HTML tags and other features, Please refer
HTML 2 (F)PDF Project.
Business From Wikipedia, the free encyclopedia Jump to: navigation, search This article or section has multiple issues. Please help improve the article or discuss these issues on the talk page. * It may be confusing or unclear for some readers. Tagged since February 2009. * It may need to be wikified to meet Wikipedia's quality standards.Tagged since February 2009. * It may require general cleanup to meet Wikipedia's quality standards. Tagged since February 2009. For other uses, see Business (disambiguation). This article needs additional citations for verification. Please help improve this article by adding reliable references. Unsourced material may be challenged and removed. (September 2008) Scales of justice Companies law Company · Business Sole proprietorship Partnership (General · Limited · LLP) Corporation Cooperative United States S corporation · C corporation LLC · LLLP · Series LLC Delaware corporation Nevada corporation Massachusetts business trust UK / Ireland / Commonwealth Limited company (by shares · by guarantee Public · Proprietary) Community interest company European Union / EEA SE · SCE · SPE · EEIG Elsewhere AB · AG · ANS · A/S · AS · GmbH K.K. · N.V. · OY · S.A. · more Doctrines Corporate governance Limited liability · Ultra vires Business judgment rule Internal affairs doctrine De facto corporation and corporation by estoppel Piercing the corporate veil Rochdale Principles Related areas Contract · Civil procedure v • d • e A business (also called a firm or an enterprise) is a legally recognized organization designed to provide goods and/or services to consumers.A firm is an organization that uses resources to produce a product, which it then sells. [1]Businesses are predominant in capitalist economies, most being privately owned and formed to earn profit to increase the wealth of owners. The owners and operators of a business have as one of their main objectives the receipt or generation of a financial return in exchange for work and acceptance of risk. Notable exceptions include cooperative businesses and state-owned enterprises. Socialist systems involve either government agencies, public, or worker ownership of most sizable businesses. The etymology of "business" relates to the state of being busy either as an individual or society as a whole, doing commercially viable and profitable work. The term "business" has at least three usages, depending on the scope — the singular usage (above) to mean a particular company or corporation, the generalized usage to refer to a particular market sector, such as "the music business" and compound forms such as agribusiness, or the broadest meaning to include all activity by the community of suppliers of goods and services. However, the exact definition of business, like much else in the philosophy of business, is a matter of debate. Business Studies, the study of the management of individuals to maintain collective productivity in order to accomplish particular creative and productive goals (usually to generate profit), is taught as an academic subject in many schools. Contents [hide] * 1 Basic forms of ownership * 2 Classifications * 3 Organization * 4 Management * 5 Government regulation o 5.1 Organizing o 5.2 Commercial law o 5.3 Capital o 5.4 Intellectual property o 5.5 Exit plans * 6 See also * 7 External links * 8 Notes and references [edit] Basic forms of ownership Although forms of business ownership vary by jurisdiction, there are several common forms: * Sole proprietorship: A sole proprietorship is a business owned by one person. The owner may operate on his or her own or may employ others. The owner of the business has total and unlimited personal liability of the debts incurred by the business. * Partnership: A partnership is a form of business in which two or more people operate for the common goal of making profit. Each partner has total and unlimited personal liability of the debts incurred by the partnership. There are three typical classifications of partnerships: general partnerships, limited partnerships, and limited liability partnerships. * Corporation: A business corporation is a for-profit, limited liability entity that has a separate legal personality from its members. A corporation is owned by multiple shareholders and is overseen by a board of directors, which hires the business's managerial staff. * Cooperative: Often referred to as a "co-op business" or "co-op", a cooperative is a for-profit, limited liability entity that differs from a corporation in that it has members, as opposed to shareholders, who share decision-making authority. Cooperatives are typically classified as either consumer cooperatives or worker cooperatives. Cooperatives are fundamental to the ideology of economic democracy. For a country-by-country listing of legally recognized business forms, see Types of business entity. [edit] Classifications Wall Street, Manhattan is the location of the New York Stock Exchange and is often used as a symbol for the world of business.[citation needed] There are many types of businesses, and, as a result, businesses are classified in many ways. One of the most common focuses on the primary profit-generating activities of a business: * Agriculture and mining businesses are concerned with the production of raw material, such as plants or minerals. * Financial businesses include banks and other companies that generate profit through investment and management of capital. * Information businesses generate profits primarily from the resale of intellectual property and include movie studios, publishers and packaged software companies. * Manufacturers produce products, from raw materials or component parts, which they then sell at a profit. Companies that make physical goods, such as cars or pipes, are considered manufacturers. * Real estate businesses generate profit from the selling, renting, and development of properties, homes, and buildings. * Retailers and Distributors act as middle-men in getting goods produced by manufacturers to the intended consumer, generating a profit as a result of providing sales or distribution services. Most consumer-oriented stores and catalogue companies are distributors or retailers. See also: Franchising * Service businesses offer intangible goods or services and typically generate a profit by charging for labor or other services provided to government, other businesses or consumers. Organizations ranging from house decorators to consulting firms to restaurants and even to entertainers are types of service businesses. * Transportation businesses deliver goods and individuals from location to location, generating a profit on the transportation costs * Utilities produce public services, such as heat, electricity, or sewage treatment, and are usually government chartered. There are many other divisions and subdivisions of businesses. The authoritative list of business types for North America is generally considered to be the North American Industry Classification System, or NAICS. The equivalent European Union list is the NACE. [edit] Organization This section does not cite any references or sources. Please help improve this section by adding citations to reliable sources. Unverifiable material may be challenged and removed. (March 2008) An organization is defined as an economic and social entity composed of a group of people who interact with each other for the purpose of achieving a common goal. Most businesses must accomplish similar functions regardless of size, legal structure or industry. These functions are often organized into departments. Common departments include (but are not limited to): Human Resources Typically responsible for hiring, firing, payroll, benefits, etc. Finance responsible for managing the enterprises financial resources[2] Budgeting and forecasting planning how the enterprise wants things to happen Cash and treasury management ensuring the enterprise has money when it's needed Accounts payable and receivable ensuring the enterprise receives what it's owed and pay what it owes Tax planning/filing and reporting meeting obligations to the government Risk management ensuring the enterprise doesn't get surprised by something unfavorable External and internal (management) reporting providing visibility into the enterprise for those who need it through financial reporting and other types of reporting Marketing and sales responsible for selling the business' goods or services to the customer and for managing the relationships with the customer Marketing Typically responsible for promoting interest in, and generating demand for, the business' products or services, and positioning them within the market Sales finding likely purchasers and obtaining their agreement (known as a contract) to buy the business' products or services Operations makes the product or delivers the service Production produces the raw materials into the delivered goods, if they require processing Customer service supports customers who need help with the goods or services Procurement responsible for acquiring the goods and services necessary for the business. Sometimes organized as: Strategic sourcing determines the business' needs and plans for acquiring the necessary raw materials and services for the business Purchasing processes the purchase orders and related transactions Research and Development tests to create new products and to determine their viability (e.g. pilot plants) Information Technology manages the business' computer and data assets Communications/Public Relations responsible for communicating to the outside world Administration provides administrative support to the other departments (such as typing, filing, etc.) Internal Audit an independent control function typically accountable to the Board of Directors for reporting on the proper functioning of the other departments Management is sometimes listed as a "department" but typically refers to the top level of leadership within the business regardless of their functional role. [edit] Management Please help improve this section by expanding it. Further information might be found on the talk page. (August 2007) The study of the efficient and effective operation of a business is called management. The main branches of management are financial management, marketing management, human resource management, strategic management, production management, service management, information technology management, and business intelligence. [edit] Government regulation This section may require cleanup to meet Wikipedia's quality standards. Please improve this article if you can. (August 2007) The examples and perspective in this article may not represent a worldwide view of the subject. Please improve this article or discuss the issue on the talk page. The Bank of England in Threadneedle Street, London, England. Most legal jurisdictions specify the forms of ownership that a business can take, creating a body of commercial law for each type. [edit] Organizing The major factors affecting how a business is organized are usually: * The size and scope of the business, and its anticipated management and ownership. Generally a smaller business is more flexible, while larger businesses, or those with wider ownership or more formal structures, will usually tend to be organized as partnerships or (more commonly) corporations. In addition a business which wishes to raise money on a stock market or to be owned by a wide range of people will often be required to adopt a specific legal form to do so. * The sector and country. Private profit making businesses are different from government owned bodies. In some countries, certain businesses are legally obliged to be organized certain ways. * Limited liability. Corporations, limited liability partnerships, and other specific types of business organizations protect their owners from business failure by doing business under a separate legal entity with certain legal protections. In contrast, unincorporated businesses or persons working on their own are usually not so protected. * Tax advantages. Different structures are treated differently in tax law, and may have advantages for this reason. * Disclosure and compliance requirements. Different business structures may be required to make more or less information public (or reported to relevant authorities), and may be bound to comply with different rules and regulations. Many businesses are operated through a separate entity such as a corporation, limited partnership or limited liability company. Most legal jurisdictions allow people to organize such an entity by filing certain charter documents with the relevant Secretary of State or equivalent and complying with certain other ongoing obligations. The relationships and legal rights of shareholders, limited partners, or members are governed partly by the charter documents and partly by the law of the jurisdiction where the entity is organized. Generally speaking, shareholders in a corporation, limited partners in a limited partnership, and members in a limited liability company are shielded from personal liability for the debts and obligations of the entity, which is legally treated as a separate "person." This means that unless there is misconduct, the owner's own possessions are strongly protected in law, if the business does not succeed. Where two or more individuals own a business together but have failed to organize a more specialized form of vehicle, they will be treated as a general partnership. The terms of a partnership are partly governed by a partnership agreement if one is created, and partly by the law of the jurisdiction where the partnership is located. No paperwork or filing is necessary to create a partnership, and without an agreement, the relationships and legal rights of the partners will be entirely governed by the law of the jurisdiction where the partnership is located. A single person who owns and runs a business is commonly known as a sole proprietor, whether he or she owns it directly or through a formally organized entity. A few relevant factors to consider in deciding how to operate a business include: 1. General partners in a partnership (other than a limited liability partnership), plus anyone who personally owns and operates a business without creating a separate legal entity, are personally liable for the debts and obligations of the business. 2. Generally, corporations are required to pay tax just like "real" people. In some tax systems, this can give rise to so-called double taxation, because first the corporation pays tax on the profit, and then when the corporation distributes its profits to its owners, individuals have to include dividends in their income when they complete their personal tax returns, at which point a second layer of income tax is imposed. 3. In most countries, there are laws which treat small corporations differently than large ones. They may be exempt from certain legal filing requirements or labor laws, have simplified procedures in specialized areas, and have simplified, advantageous, or slightly different tax treatment. 4. In order to "go public" (sometimes called IPO) -- which basically means to allow a part of the business to be owned by a wider range of investors or the public in general -- you must organize a separate entity, which is usually required to comply with a tighter set of laws and procedures. Most public entities are corporations that have sold shares, but increasingly there are also public LLCs that sell units (sometimes also called shares), and other more exotic entities as well (for example, REITs in the USA, Unit Trusts in the UK). However, you cannot take a general partnership "public." [edit] Commercial law Most commercial transactions are governed by a very detailed and well-established body of rules that have evolved over a very long period of time, it being the case that governing trade and commerce was a strong driving force in the creation of law and courts in Western civilization. As for other laws that regulate or impact businesses, in many countries it is all but impossible to chronicle them all in a single reference source. There are laws governing treatment of labor and generally relations with employees, safety and protection issues (OSHA or Health and Safety), anti-discrimination laws (age, gender, disabilities, race, and in some jurisdictions, sexual orientation), minimum wage laws, union laws, workers compensation laws, and annual vacation or working hours time. In some specialized businesses, there may also be licenses required, either due to special laws that govern entry into certain trades, occupations or professions, which may require special education, or by local governments. Professions that require special licenses range from law and medicine to flying airplanes to selling liquor to radio broadcasting to selling investment securities to selling used cars to roofing. Local jurisdictions may also require special licenses and taxes just to operate a business without regard to the type of business involved. Some businesses are subject to ongoing special regulation. These industries include, for example, public utilities, investment securities, banking, insurance, broadcasting, aviation, and health care providers. Environmental regulations are also very complex and can impact many kinds of businesses in unexpected ways. [edit] Capital When businesses need to raise money (called 'capital'), more laws come into play. A highly complex set of laws and regulations govern the offer and sale of investment securities (the means of raising money) in most Western countries. These regulations can require disclosure of a lot of specific financial and other information about the business and give buyers certain remedies. Because "securities" is a very broad term, most investment transactions will be potentially subject to these laws, unless a special exemption is available. Capital may be raised through private means, by public offer (IPO) on a stock exchange, or in many other ways. Major stock exchanges include the New York Stock Exchange and Nasdaq (USA), the London Stock Exchange (UK), the Tokyo Stock Exchange (Japan), and so on. Most countries with capital markets have at least one. Business that have gone "public" are subject to extremely detailed and complicated regulation about their internal governance (such as how executive officers' compensation is determined) and when and how information is disclosed to the public and their shareholders. In the United States, these regulations are primarily implemented and enforced by the United States Securities and Exchange Commission (SEC). Other Western nations have comparable regulatory bodies. As noted at the beginning, it is impossible to enumerate all of the types of laws and regulations that impact on business today. In fact, these laws have become so numerous and complex, that no business lawyer can learn them all, forcing increasing specialization among corporate attorneys. It is not unheard of for teams of 5 to 10 attorneys to be required to handle certain kinds of corporate transactions, due to the sprawling nature of modern regulation. Commercial law spans general corporate law, employment and labor law, healthcare law, securities law, M&A law (who specialize in acquisitions), tax law, ERISA law (ERISA in the United States governs employee benefit plans), food and drug regulatory law, intellectual property law (specializing in copyrights, patents, trademarks and such), telecommunications law, and more. In Thailand, for example, it is necessary to register a particular amount of capital for each employee, and pay a fee to the government for the amount of capital registered. There is no legal requirement to prove that this capital actually exists, the only requirement is to pay the fee. Overall, processes like this are detrimental to the development and GDP of a country, but often exist in "feudal" developing countries. [edit] Intellectual property Businesses often have important "intellectual property" that needs protection from competitors in order for the company to stay profitable. This could require patents or copyrights or preservation of trade secrets. Most businesses have names, logos and similar branding techniques that could benefit from trademarking. Patents and copyrights in the United States are largely governed by federal law, while trade secrets and trademarking are mostly a matter of state law. Because of the nature of intellectual property, a business needs protection in every jurisdiction in which they are concerned about competitors. Many countries are signatories to international treaties concerning intellectual property, and thus companies registered in these countries are subject to national laws bound by these treaties. [edit] Exit plans Businesses can be bought and sold. Business owners often refer to their plan of disposing of the business as an "exit plan." Common exit plans include IPOs, MBOs and mergers with other businesses. [edit] See also Main list: List of business topics Business and economics portal This encyclopedia includes over 1600 business and economics articles, so not all appear listed here. This lists some of the main business-related concepts. For more specific topics, look at the various sublists. * Accounting o List of accounting topics * Advertising * Banking * Big business * Business acumen * Business broker * Business ethics o List of business ethics, political economy, and philosophy of business topics o Social responsibility * Business hours * Business mediator * Business schools * Business trip * Capitalism * Commerce * Commercial law o List of business law topics * Commerciality * Company * Cooperative * Corporate law * Corporation * Cost overrun * Economics o Economic democracy o Financial economics o List of economics topics * Electronic commerce o E-business * Entrepreneurship * Finance o List of finance topics * Franchising * Government ownership * Human Resources o List of human resource management topics * Industry * Insurance * Intellectual property * International trade o List of international trade topics * Investment * Limited liability * Management o List of management topics * Management information systems o List of information technology management topics * Manufacturing o List of production topics * Marketing o List of marketing topics * Organizational studies * Partnership * Real Estate * Renewable Energy o List of real estate topics * Revenue shortfall * Small business * Sole proprietorship * Strategic Management * Strategic Planning * Types of business entity [edit] External links Find more about Business on Wikipedia's sister projects: Definitions from Wiktionary Textbooks from Wikibooks Quotations from Wikiquote Source texts from Wikisource Images and media from Commons News stories from Wikinews Learning resources from Wikiversity * Better Business Bureau US & Canada * Business Current Events Open Directory * Doing Business project