diff options
author | Sashi20 | 2021-03-15 15:55:05 +0530 |
---|---|---|
committer | GitHub | 2021-03-15 15:55:05 +0530 |
commit | 44f5bb01da3bcd87c6fe94b8ee29012338087ccf (patch) | |
tree | 19fd982b557648aa999df551e8eaf354cc7aa3c3 /pdf/fpdf/tutorial | |
parent | e92f4e6edab823292a923c39bb4cce2e46488e6b (diff) | |
parent | dc64743422ea56fc0614940cb17219549999eb0a (diff) | |
download | dwsim_custom_model-44f5bb01da3bcd87c6fe94b8ee29012338087ccf.tar.gz dwsim_custom_model-44f5bb01da3bcd87c6fe94b8ee29012338087ccf.tar.bz2 dwsim_custom_model-44f5bb01da3bcd87c6fe94b8ee29012338087ccf.zip |
Merge pull request #8 from Saketh1499/development
Generating certificates for completed projects
Diffstat (limited to 'pdf/fpdf/tutorial')
25 files changed, 1443 insertions, 0 deletions
diff --git a/pdf/fpdf/tutorial/20k_c1.txt b/pdf/fpdf/tutorial/20k_c1.txt new file mode 100755 index 0000000..0b09f26 --- /dev/null +++ b/pdf/fpdf/tutorial/20k_c1.txt @@ -0,0 +1,10 @@ +The year 1866 was marked by a bizarre development, an unexplained and downright inexplicable phenomenon that surely no one has forgotten. Without getting into those rumors that upset civilians in the seaports and deranged the public mind even far inland, it must be said that professional seamen were especially alarmed. Traders, shipowners, captains of vessels, skippers, and master mariners from Europe and America, naval officers from every country, and at their heels the various national governments on these two continents, were all extremely disturbed by the business.
+In essence, over a period of time several ships had encountered "an enormous thing" at sea, a long spindle-shaped object, sometimes giving off a phosphorescent glow, infinitely bigger and faster than any whale.
+The relevant data on this apparition, as recorded in various logbooks, agreed pretty closely as to the structure of the object or creature in question, its unprecedented speed of movement, its startling locomotive power, and the unique vitality with which it seemed to be gifted. If it was a cetacean, it exceeded in bulk any whale previously classified by science. No naturalist, neither Cuvier nor Lacépède, neither Professor Dumeril nor Professor de Quatrefages, would have accepted the existence of such a monster sight unseen -- specifically, unseen by their own scientific eyes.
+Striking an average of observations taken at different times -- rejecting those timid estimates that gave the object a length of 200 feet, and ignoring those exaggerated views that saw it as a mile wide and three long--you could still assert that this phenomenal creature greatly exceeded the dimensions of anything then known to ichthyologists, if it existed at all.
+Now then, it did exist, this was an undeniable fact; and since the human mind dotes on objects of wonder, you can understand the worldwide excitement caused by this unearthly apparition. As for relegating it to the realm of fiction, that charge had to be dropped.
+In essence, on July 20, 1866, the steamer Governor Higginson, from the Calcutta & Burnach Steam Navigation Co., encountered this moving mass five miles off the eastern shores of Australia. Captain Baker at first thought he was in the presence of an unknown reef; he was even about to fix its exact position when two waterspouts shot out of this inexplicable object and sprang hissing into the air some 150 feet. So, unless this reef was subject to the intermittent eruptions of a geyser, the Governor Higginson had fair and honest dealings with some aquatic mammal, until then unknown, that could spurt from its blowholes waterspouts mixed with air and steam.
+Similar events were likewise observed in Pacific seas, on July 23 of the same year, by the Christopher Columbus from the West India & Pacific Steam Navigation Co. Consequently, this extraordinary cetacean could transfer itself from one locality to another with startling swiftness, since within an interval of just three days, the Governor Higginson and the Christopher Columbus had observed it at two positions on the charts separated by a distance of more than 700 nautical leagues.
+Fifteen days later and 2,000 leagues farther, the Helvetia from the Compagnie Nationale and the Shannon from the Royal Mail line, running on opposite tacks in that part of the Atlantic lying between the United States and Europe, respectively signaled each other that the monster had been sighted in latitude 42 degrees 15' north and longitude 60 degrees 35' west of the meridian of Greenwich. From their simultaneous observations, they were able to estimate the mammal's minimum length at more than 350 English feet; this was because both the Shannon and the Helvetia were of smaller dimensions, although each measured 100 meters stem to stern. Now then, the biggest whales, those rorqual whales that frequent the waterways of the Aleutian Islands, have never exceeded a length of 56 meters--if they reach even that.
+One after another, reports arrived that would profoundly affect public opinion: new observations taken by the transatlantic liner Pereire, the Inman line's Etna running afoul of the monster, an official report drawn up by officers on the French frigate Normandy, dead-earnest reckonings obtained by the general staff of Commodore Fitz-James aboard the Lord Clyde. In lighthearted countries, people joked about this phenomenon, but such serious, practical countries as England, America, and Germany were deeply concerned.
+In every big city the monster was the latest rage; they sang about it in the coffee houses, they ridiculed it in the newspapers, they dramatized it in the theaters. The tabloids found it a fine opportunity for hatching all sorts of hoaxes. In those newspapers short of copy, you saw the reappearance of every gigantic imaginary creature, from "Moby Dick," that dreadful white whale from the High Arctic regions, to the stupendous kraken whose tentacles could entwine a 500-ton craft and drag it into the ocean depths. They even reprinted reports from ancient times: the views of Aristotle and Pliny accepting the existence of such monsters, then the Norwegian stories of Bishop Pontoppidan, the narratives of Paul Egede, and finally the reports of Captain Harrington -- whose good faith is above suspicion--in which he claims he saw, while aboard the Castilian in 1857, one of those enormous serpents that, until then, had frequented only the seas of France's old extremist newspaper, The Constitutionalist.
diff --git a/pdf/fpdf/tutorial/20k_c2.txt b/pdf/fpdf/tutorial/20k_c2.txt new file mode 100755 index 0000000..096dbd1 --- /dev/null +++ b/pdf/fpdf/tutorial/20k_c2.txt @@ -0,0 +1,23 @@ +During the period in which these developments were occurring, I had returned from a scientific undertaking organized to explore the Nebraska badlands in the United States. In my capacity as Assistant Professor at the Paris Museum of Natural History, I had been attached to this expedition by the French government. After spending six months in Nebraska, I arrived in New York laden with valuable collections near the end of March. My departure for France was set for early May. In the meantime, then, I was busy classifying my mineralogical, botanical, and zoological treasures when that incident took place with the Scotia.
+I was perfectly abreast of this question, which was the big news of the day, and how could I not have been? I had read and reread every American and European newspaper without being any farther along. This mystery puzzled me. Finding it impossible to form any views, I drifted from one extreme to the other. Something was out there, that much was certain, and any doubting Thomas was invited to place his finger on the Scotia's wound.
+When I arrived in New York, the question was at the boiling point. The hypothesis of a drifting islet or an elusive reef, put forward by people not quite in their right minds, was completely eliminated. And indeed, unless this reef had an engine in its belly, how could it move about with such prodigious speed?
+Also discredited was the idea of a floating hull or some other enormous wreckage, and again because of this speed of movement.
+So only two possible solutions to the question were left, creating two very distinct groups of supporters: on one side, those favoring a monster of colossal strength; on the other, those favoring an "underwater boat" of tremendous motor power.
+Now then, although the latter hypothesis was completely admissible, it couldn't stand up to inquiries conducted in both the New World and the Old. That a private individual had such a mechanism at his disposal was less than probable. Where and when had he built it, and how could he have built it in secret?
+Only some government could own such an engine of destruction, and in these disaster-filled times, when men tax their ingenuity to build increasingly powerful aggressive weapons, it was possible that, unknown to the rest of the world, some nation could have been testing such a fearsome machine. The Chassepot rifle led to the torpedo, and the torpedo has led to this underwater battering ram, which in turn will lead to the world putting its foot down. At least I hope it will.
+But this hypothesis of a war machine collapsed in the face of formal denials from the various governments. Since the public interest was at stake and transoceanic travel was suffering, the sincerity of these governments could not be doubted. Besides, how could the assembly of this underwater boat have escaped public notice? Keeping a secret under such circumstances would be difficult enough for an individual, and certainly impossible for a nation whose every move is under constant surveillance by rival powers.
+So, after inquiries conducted in England, France, Russia, Prussia, Spain, Italy, America, and even Turkey, the hypothesis of an underwater Monitor was ultimately rejected.
+After I arrived in New York, several people did me the honor of consulting me on the phenomenon in question. In France I had published a two-volume work, in quarto, entitled The Mysteries of the Great Ocean Depths. Well received in scholarly circles, this book had established me as a specialist in this pretty obscure field of natural history. My views were in demand. As long as I could deny the reality of the business, I confined myself to a flat "no comment." But soon, pinned to the wall, I had to explain myself straight out. And in this vein, "the honorable Pierre Aronnax, Professor at the Paris Museum," was summoned by The New York Herald to formulate his views no matter what.
+I complied. Since I could no longer hold my tongue, I let it wag. I discussed the question in its every aspect, both political and scientific, and this is an excerpt from the well-padded article I published in the issue of April 30.
+
+"Therefore," I wrote, "after examining these different hypotheses one by one, we are forced, every other supposition having been refuted, to accept the existence of an extremely powerful marine animal.
+"The deepest parts of the ocean are totally unknown to us. No soundings have been able to reach them. What goes on in those distant depths? What creatures inhabit, or could inhabit, those regions twelve or fifteen miles beneath the surface of the water? What is the constitution of these animals? It's almost beyond conjecture.
+"However, the solution to this problem submitted to me can take the form of a choice between two alternatives.
+"Either we know every variety of creature populating our planet, or we do not.
+"If we do not know every one of them, if nature still keeps ichthyological secrets from us, nothing is more admissible than to accept the existence of fish or cetaceans of new species or even new genera, animals with a basically 'cast-iron' constitution that inhabit strata beyond the reach of our soundings, and which some development or other, an urge or a whim if you prefer, can bring to the upper level of the ocean for long intervals.
+"If, on the other hand, we do know every living species, we must look for the animal in question among those marine creatures already cataloged, and in this event I would be inclined to accept the existence of a giant narwhale.
+"The common narwhale, or sea unicorn, often reaches a length of sixty feet. Increase its dimensions fivefold or even tenfold, then give this cetacean a strength in proportion to its size while enlarging its offensive weapons, and you have the animal we're looking for. It would have the proportions determined by the officers of the Shannon, the instrument needed to perforate the Scotia, and the power to pierce a steamer's hull.
+"In essence, the narwhale is armed with a sort of ivory sword, or lance, as certain naturalists have expressed it. It's a king-sized tooth as hard as steel. Some of these teeth have been found buried in the bodies of baleen whales, which the narwhale attacks with invariable success. Others have been wrenched, not without difficulty, from the undersides of vessels that narwhales have pierced clean through, as a gimlet pierces a wine barrel. The museum at the Faculty of Medicine in Paris owns one of these tusks with a length of 2.25 meters and a width at its base of forty-eight centimeters!
+"All right then! Imagine this weapon to be ten times stronger and the animal ten times more powerful, launch it at a speed of twenty miles per hour, multiply its mass times its velocity, and you get just the collision we need to cause the specified catastrophe.
+"So, until information becomes more abundant, I plump for a sea unicorn of colossal dimensions, no longer armed with a mere lance but with an actual spur, like ironclad frigates or those warships called 'rams,' whose mass and motor power it would possess simultaneously.
+"This inexplicable phenomenon is thus explained away--unless it's something else entirely, which, despite everything that has been sighted, studied, explored and experienced, is still possible!"
diff --git a/pdf/fpdf/tutorial/calligra.php b/pdf/fpdf/tutorial/calligra.php new file mode 100755 index 0000000..e262f4c --- /dev/null +++ b/pdf/fpdf/tutorial/calligra.php @@ -0,0 +1,25 @@ +<?php
+$type = 'TrueType';
+$name = 'CalligrapherRegular';
+$desc = array('Ascent'=>899,'Descent'=>-234,'CapHeight'=>899,'Flags'=>32,'FontBBox'=>'[-173 -234 1328 899]','ItalicAngle'=>0,'StemV'=>70,'MissingWidth'=>800);
+$up = -200;
+$ut = 20;
+$cw = array(
+ chr(0)=>800,chr(1)=>800,chr(2)=>800,chr(3)=>800,chr(4)=>800,chr(5)=>800,chr(6)=>800,chr(7)=>800,chr(8)=>800,chr(9)=>800,chr(10)=>800,chr(11)=>800,chr(12)=>800,chr(13)=>800,chr(14)=>800,chr(15)=>800,chr(16)=>800,chr(17)=>800,chr(18)=>800,chr(19)=>800,chr(20)=>800,chr(21)=>800,
+ chr(22)=>800,chr(23)=>800,chr(24)=>800,chr(25)=>800,chr(26)=>800,chr(27)=>800,chr(28)=>800,chr(29)=>800,chr(30)=>800,chr(31)=>800,' '=>282,'!'=>324,'"'=>405,'#'=>584,'$'=>632,'%'=>980,'&'=>776,'\''=>259,'('=>299,')'=>299,'*'=>377,'+'=>600,
+ ','=>259,'-'=>432,'.'=>254,'/'=>597,'0'=>529,'1'=>298,'2'=>451,'3'=>359,'4'=>525,'5'=>423,'6'=>464,'7'=>417,'8'=>457,'9'=>479,':'=>275,';'=>282,'<'=>600,'='=>600,'>'=>600,'?'=>501,'@'=>800,'A'=>743,
+ 'B'=>636,'C'=>598,'D'=>712,'E'=>608,'F'=>562,'G'=>680,'H'=>756,'I'=>308,'J'=>314,'K'=>676,'L'=>552,'M'=>1041,'N'=>817,'O'=>729,'P'=>569,'Q'=>698,'R'=>674,'S'=>618,'T'=>673,'U'=>805,'V'=>753,'W'=>1238,
+ 'X'=>716,'Y'=>754,'Z'=>599,'['=>315,'\\'=>463,']'=>315,'^'=>600,'_'=>547,'`'=>278,'a'=>581,'b'=>564,'c'=>440,'d'=>571,'e'=>450,'f'=>347,'g'=>628,'h'=>611,'i'=>283,'j'=>283,'k'=>560,'l'=>252,'m'=>976,
+ 'n'=>595,'o'=>508,'p'=>549,'q'=>540,'r'=>395,'s'=>441,'t'=>307,'u'=>614,'v'=>556,'w'=>915,'x'=>559,'y'=>597,'z'=>452,'{'=>315,'|'=>222,'}'=>315,'~'=>600,chr(127)=>800,chr(128)=>800,chr(129)=>800,chr(130)=>0,chr(131)=>0,
+ chr(132)=>0,chr(133)=>780,chr(134)=>0,chr(135)=>0,chr(136)=>278,chr(137)=>0,chr(138)=>0,chr(139)=>0,chr(140)=>1064,chr(141)=>800,chr(142)=>0,chr(143)=>800,chr(144)=>800,chr(145)=>259,chr(146)=>259,chr(147)=>470,chr(148)=>470,chr(149)=>500,chr(150)=>300,chr(151)=>600,chr(152)=>278,chr(153)=>990,
+ chr(154)=>0,chr(155)=>0,chr(156)=>790,chr(157)=>800,chr(158)=>800,chr(159)=>754,chr(160)=>282,chr(161)=>324,chr(162)=>450,chr(163)=>640,chr(164)=>518,chr(165)=>603,chr(166)=>0,chr(167)=>519,chr(168)=>254,chr(169)=>800,chr(170)=>349,chr(171)=>0,chr(172)=>0,chr(173)=>432,chr(174)=>800,chr(175)=>278,
+ chr(176)=>0,chr(177)=>0,chr(178)=>0,chr(179)=>0,chr(180)=>278,chr(181)=>614,chr(182)=>0,chr(183)=>254,chr(184)=>278,chr(185)=>0,chr(186)=>305,chr(187)=>0,chr(188)=>0,chr(189)=>0,chr(190)=>0,chr(191)=>501,chr(192)=>743,chr(193)=>743,chr(194)=>743,chr(195)=>743,chr(196)=>743,chr(197)=>743,
+ chr(198)=>1060,chr(199)=>598,chr(200)=>608,chr(201)=>608,chr(202)=>608,chr(203)=>608,chr(204)=>308,chr(205)=>308,chr(206)=>308,chr(207)=>308,chr(208)=>0,chr(209)=>817,chr(210)=>729,chr(211)=>729,chr(212)=>729,chr(213)=>729,chr(214)=>729,chr(215)=>0,chr(216)=>729,chr(217)=>805,chr(218)=>805,chr(219)=>805,
+ chr(220)=>805,chr(221)=>0,chr(222)=>0,chr(223)=>688,chr(224)=>581,chr(225)=>581,chr(226)=>581,chr(227)=>581,chr(228)=>581,chr(229)=>581,chr(230)=>792,chr(231)=>440,chr(232)=>450,chr(233)=>450,chr(234)=>450,chr(235)=>450,chr(236)=>283,chr(237)=>283,chr(238)=>283,chr(239)=>283,chr(240)=>0,chr(241)=>595,
+ chr(242)=>508,chr(243)=>508,chr(244)=>508,chr(245)=>508,chr(246)=>508,chr(247)=>0,chr(248)=>508,chr(249)=>614,chr(250)=>614,chr(251)=>614,chr(252)=>614,chr(253)=>0,chr(254)=>0,chr(255)=>597);
+$enc = 'cp1252';
+$uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96));
+$file = 'calligra.z';
+$originalsize = 33948;
+$subsetted = true;
+?>
diff --git a/pdf/fpdf/tutorial/calligra.ttf b/pdf/fpdf/tutorial/calligra.ttf Binary files differnew file mode 100755 index 0000000..9713c46 --- /dev/null +++ b/pdf/fpdf/tutorial/calligra.ttf diff --git a/pdf/fpdf/tutorial/calligra.z b/pdf/fpdf/tutorial/calligra.z Binary files differnew file mode 100755 index 0000000..8a14e9c --- /dev/null +++ b/pdf/fpdf/tutorial/calligra.z diff --git a/pdf/fpdf/tutorial/certificate-bold.ttf b/pdf/fpdf/tutorial/certificate-bold.ttf Binary files differnew file mode 100755 index 0000000..29d2792 --- /dev/null +++ b/pdf/fpdf/tutorial/certificate-bold.ttf diff --git a/pdf/fpdf/tutorial/certificate.ttf b/pdf/fpdf/tutorial/certificate.ttf Binary files differnew file mode 100755 index 0000000..42fdef0 --- /dev/null +++ b/pdf/fpdf/tutorial/certificate.ttf diff --git a/pdf/fpdf/tutorial/countries.txt b/pdf/fpdf/tutorial/countries.txt new file mode 100755 index 0000000..aa8886c --- /dev/null +++ b/pdf/fpdf/tutorial/countries.txt @@ -0,0 +1,15 @@ +Austria;Vienna;83859;8075
+Belgium;Brussels;30518;10192
+Denmark;Copenhagen;43094;5295
+Finland;Helsinki;304529;5147
+France;Paris;543965;58728
+Germany;Berlin;357022;82057
+Greece;Athens;131625;10511
+Ireland;Dublin;70723;3694
+Italy;Roma;301316;57563
+Luxembourg;Luxembourg;2586;424
+Netherlands;Amsterdam;41526;15654
+Portugal;Lisbon;91906;9957
+Spain;Madrid;504790;39348
+Sweden;Stockholm;410934;8839
+United Kingdom;London;243820;58862
diff --git a/pdf/fpdf/tutorial/index.htm b/pdf/fpdf/tutorial/index.htm new file mode 100755 index 0000000..87cc484 --- /dev/null +++ b/pdf/fpdf/tutorial/index.htm @@ -0,0 +1,20 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Tutorials</title>
+<link type="text/css" rel="stylesheet" href="../fpdf.css">
+</head>
+<body>
+<h1>Tutorials</h1>
+<ul style="list-style-type:none; margin-left:0; padding-left:0">
+<li><a href="tuto1.htm">Tutorial 1</a>: Minimal example</li>
+<li><a href="tuto2.htm">Tutorial 2</a>: Header, footer, page break and image</li>
+<li><a href="tuto3.htm">Tutorial 3</a>: Line breaks and colors</li>
+<li><a href="tuto4.htm">Tutorial 4</a>: Multi-columns</li>
+<li><a href="tuto5.htm">Tutorial 5</a>: Tables</li>
+<li><a href="tuto6.htm">Tutorial 6</a>: Links and flowing text</li>
+<li><a href="tuto7.htm">Tutorial 7</a>: Adding new fonts and encodings</li>
+</ul>
+</body>
+</html>
diff --git a/pdf/fpdf/tutorial/logo.png b/pdf/fpdf/tutorial/logo.png Binary files differnew file mode 100755 index 0000000..284a007 --- /dev/null +++ b/pdf/fpdf/tutorial/logo.png diff --git a/pdf/fpdf/tutorial/makefont.php b/pdf/fpdf/tutorial/makefont.php new file mode 100755 index 0000000..285f27c --- /dev/null +++ b/pdf/fpdf/tutorial/makefont.php @@ -0,0 +1,6 @@ +<?php
+// Generation of font definition file for tutorial 7
+require('../makefont/makefont.php');
+
+MakeFont('calligra.ttf','cp1252');
+?>
diff --git a/pdf/fpdf/tutorial/tuto1.htm b/pdf/fpdf/tutorial/tuto1.htm new file mode 100755 index 0000000..36fabad --- /dev/null +++ b/pdf/fpdf/tutorial/tuto1.htm @@ -0,0 +1,76 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Minimal example</title>
+<link type="text/css" rel="stylesheet" href="../fpdf.css">
+</head>
+<body>
+<h1>Minimal example</h1>
+Let's start with the classic example:
+<div class="source">
+<pre><code><?php
+<span class="kw">require(</span><span class="str">'fpdf.php'</span><span class="kw">);
+
+</span>$pdf <span class="kw">= new </span>FPDF<span class="kw">();
+</span>$pdf<span class="kw">-></span>AddPage<span class="kw">();
+</span>$pdf<span class="kw">-></span>SetFont<span class="kw">(</span><span class="str">'Arial'</span><span class="kw">,</span><span class="str">'B'</span><span class="kw">,</span>16<span class="kw">);
+</span>$pdf<span class="kw">-></span>Cell<span class="kw">(</span>40<span class="kw">,</span>10<span class="kw">,</span><span class="str">'Hello World!'</span><span class="kw">);
+</span>$pdf<span class="kw">-></span>Output<span class="kw">();
+</span>?></code></pre>
+</div>
+<p class='demo'><a href='tuto1.php' target='_blank' class='demo'>[Demo]</a></p>
+After including the library file, we create an FPDF object.
+The <a href='../doc/__construct.htm'>constructor</a> is used here with the default values: pages are in A4 portrait and
+the unit of measure is millimeter. It could have been specified explicitly with:
+<div class="source">
+<pre><code>$pdf <span class="kw">= new </span>FPDF<span class="kw">(</span><span class="str">'P'</span><span class="kw">,</span><span class="str">'mm'</span><span class="kw">,</span><span class="str">'A4'</span><span class="kw">);
+</span></code></pre>
+</div>
+It's possible to use landscape (<code>L</code>), other page sizes (such as <code>Letter</code> and
+<code>Legal</code>) and units (<code>pt</code>, <code>cm</code>, <code>in</code>).
+<br>
+<br>
+There's no page at the moment, so we have to add one with <a href='../doc/addpage.htm'>AddPage()</a>. The origin
+is at the upper-left corner and the current position is by default set at 1 cm from the
+borders; the margins can be changed with <a href='../doc/setmargins.htm'>SetMargins()</a>.
+<br>
+<br>
+Before we can print text, it's mandatory to select a font with <a href='../doc/setfont.htm'>SetFont()</a>.
+We choose Arial bold 16:
+<div class="source">
+<pre><code>$pdf<span class="kw">-></span>SetFont<span class="kw">(</span><span class="str">'Arial'</span><span class="kw">,</span><span class="str">'B'</span><span class="kw">,</span>16<span class="kw">);
+</span></code></pre>
+</div>
+We could have specified italics with I, underlined with U or a regular font with an empty string
+(or any combination). Note that the font size is given in points, not millimeters (or another user
+unit); it's the only exception. The other standard fonts are Times, Courier, Symbol and ZapfDingbats.
+<br>
+<br>
+We can now print a cell with <a href='../doc/cell.htm'>Cell()</a>. A cell is a rectangular area, possibly framed,
+which contains a line of 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:
+<div class="source">
+<pre><code>$pdf<span class="kw">-></span>Cell<span class="kw">(</span>40<span class="kw">,</span>10<span class="kw">,</span><span class="str">'Hello World !'</span><span class="kw">,</span>1<span class="kw">);
+</span></code></pre>
+</div>
+To add a new cell next to it with centered text and go to the next line, we would do:
+<div class="source">
+<pre><code>$pdf<span class="kw">-></span>Cell<span class="kw">(</span>60<span class="kw">,</span>10<span class="kw">,</span><span class="str">'Powered by FPDF.'</span><span class="kw">,</span>0<span class="kw">,</span>1<span class="kw">,</span><span class="str">'C'</span><span class="kw">);
+</span></code></pre>
+</div>
+Remark: the line break can also be done with <a href='../doc/ln.htm'>Ln()</a>. This method additionnaly allows to specify
+the height of the break.
+<br>
+<br>
+Finally, the document is closed and sent to the browser with <a href='../doc/output.htm'>Output()</a>. We could have saved
+it to a file by passing the appropriate parameters.
+<br>
+<br>
+<strong>Caution:</strong> in case when the PDF is sent to the browser, nothing else must be output by the
+script, neither before nor after (no HTML, not even a space or a carriage return). If you send something
+before, you will get the error message: "Some data has already been output, can't send PDF file". If you
+send something after, the document might not display.
+</body>
+</html>
diff --git a/pdf/fpdf/tutorial/tuto1.php b/pdf/fpdf/tutorial/tuto1.php new file mode 100755 index 0000000..14a0504 --- /dev/null +++ b/pdf/fpdf/tutorial/tuto1.php @@ -0,0 +1,9 @@ +<?php
+require('../fpdf.php');
+
+$pdf = new FPDF();
+$pdf->AddPage();
+$pdf->SetFont('Arial','B',16);
+$pdf->Cell(40,10,'Hello World!');
+$pdf->Output();
+?>
diff --git a/pdf/fpdf/tutorial/tuto2.htm b/pdf/fpdf/tutorial/tuto2.htm new file mode 100755 index 0000000..b892d1d --- /dev/null +++ b/pdf/fpdf/tutorial/tuto2.htm @@ -0,0 +1,80 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Header, footer, page break and image</title>
+<link type="text/css" rel="stylesheet" href="../fpdf.css">
+</head>
+<body>
+<h1>Header, footer, page break and image</h1>
+Here's a two page example with header, footer and logo:
+<div class="source">
+<pre><code><?php
+<span class="kw">require(</span><span class="str">'fpdf.php'</span><span class="kw">);
+
+class </span>PDF <span class="kw">extends </span>FPDF
+<span class="kw">{
+</span><span class="cmt">// Page header
+</span><span class="kw">function </span>Header<span class="kw">()
+{
+ </span><span class="cmt">// Logo
+ </span>$<span class="kw">this-></span>Image<span class="kw">(</span><span class="str">'logo.png'</span><span class="kw">,</span>10<span class="kw">,</span>6<span class="kw">,</span>30<span class="kw">);
+ </span><span class="cmt">// Arial bold 15
+ </span>$<span class="kw">this-></span>SetFont<span class="kw">(</span><span class="str">'Arial'</span><span class="kw">,</span><span class="str">'B'</span><span class="kw">,</span>15<span class="kw">);
+ </span><span class="cmt">// Move to the right
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>80<span class="kw">);
+ </span><span class="cmt">// Title
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>30<span class="kw">,</span>10<span class="kw">,</span><span class="str">'Title'</span><span class="kw">,</span>1<span class="kw">,</span>0<span class="kw">,</span><span class="str">'C'</span><span class="kw">);
+ </span><span class="cmt">// Line break
+ </span>$<span class="kw">this-></span>Ln<span class="kw">(</span>20<span class="kw">);
+}
+
+</span><span class="cmt">// Page footer
+</span><span class="kw">function </span>Footer<span class="kw">()
+{
+ </span><span class="cmt">// Position at 1.5 cm from bottom
+ </span>$<span class="kw">this-></span>SetY<span class="kw">(-</span>15<span class="kw">);
+ </span><span class="cmt">// Arial italic 8
+ </span>$<span class="kw">this-></span>SetFont<span class="kw">(</span><span class="str">'Arial'</span><span class="kw">,</span><span class="str">'I'</span><span class="kw">,</span>8<span class="kw">);
+ </span><span class="cmt">// Page number
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>0<span class="kw">,</span>10<span class="kw">,</span><span class="str">'Page '</span><span class="kw">.</span>$<span class="kw">this-></span>PageNo<span class="kw">().</span><span class="str">'/{nb}'</span><span class="kw">,</span>0<span class="kw">,</span>0<span class="kw">,</span><span class="str">'C'</span><span class="kw">);
+}
+}
+
+</span><span class="cmt">// Instanciation of inherited class
+</span>$pdf <span class="kw">= new </span>PDF<span class="kw">();
+</span>$pdf<span class="kw">-></span>AliasNbPages<span class="kw">();
+</span>$pdf<span class="kw">-></span>AddPage<span class="kw">();
+</span>$pdf<span class="kw">-></span>SetFont<span class="kw">(</span><span class="str">'Times'</span><span class="kw">,</span><span class="str">''</span><span class="kw">,</span>12<span class="kw">);
+for(</span>$i<span class="kw">=</span>1<span class="kw">;</span>$i<span class="kw"><=</span>40<span class="kw">;</span>$i<span class="kw">++)
+ </span>$pdf<span class="kw">-></span>Cell<span class="kw">(</span>0<span class="kw">,</span>10<span class="kw">,</span><span class="str">'Printing line number '</span><span class="kw">.</span>$i<span class="kw">,</span>0<span class="kw">,</span>1<span class="kw">);
+</span>$pdf<span class="kw">-></span>Output<span class="kw">();
+</span>?></code></pre>
+</div>
+<p class='demo'><a href='tuto2.php' target='_blank' class='demo'>[Demo]</a></p>
+This example makes use of the <a href='../doc/header.htm'>Header()</a> and <a href='../doc/footer.htm'>Footer()</a> methods to process page headers and
+footers. They are called automatically. They already exist in the FPDF class but do nothing,
+therefore we have to extend the class and override them.
+<br>
+<br>
+The logo is printed with the <a href='../doc/image.htm'>Image()</a> method by specifying its upper-left corner and
+its width. The height is calculated automatically to respect the image proportions.
+<br>
+<br>
+To print the page number, a null value is passed as the cell width. It means that the cell
+should extend up to the right margin of the page; this is handy to center text. The current page
+number is returned by the <a href='../doc/pageno.htm'>PageNo()</a> method; as for the total number of pages, it's obtained
+via the special value <code>{nb}</code> which is substituted when the document is finished
+(provided you first called <a href='../doc/aliasnbpages.htm'>AliasNbPages()</a>).
+<br>
+Note the use of the <a href='../doc/sety.htm'>SetY()</a> method which allows to set position at an absolute location in
+the page, starting from the top or the bottom.
+<br>
+<br>
+Another interesting feature is used here: the automatic page breaking. As soon as a cell would
+cross a limit in the page (at 2 centimeters from the bottom by default), a break is issued
+and the font restored. Although the header and footer select their own font (Arial), the body
+continues with Times. This mechanism of automatic restoration also applies to colors and line
+width. The limit which triggers page breaks can be set with <a href='../doc/setautopagebreak.htm'>SetAutoPageBreak()</a>.
+</body>
+</html>
diff --git a/pdf/fpdf/tutorial/tuto2.php b/pdf/fpdf/tutorial/tuto2.php new file mode 100755 index 0000000..cc7d51c --- /dev/null +++ b/pdf/fpdf/tutorial/tuto2.php @@ -0,0 +1,41 @@ +<?php
+require('../fpdf.php');
+
+class PDF extends FPDF
+{
+// Page header
+function Header()
+{
+ // Logo
+ $this->Image('logo.png',10,6,30);
+ // Arial bold 15
+ $this->SetFont('Arial','B',15);
+ // Move to the right
+ $this->Cell(80);
+ // Title
+ $this->Cell(30,10,'Title',1,0,'C');
+ // Line break
+ $this->Ln(20);
+}
+
+// Page footer
+function Footer()
+{
+ // Position at 1.5 cm from bottom
+ $this->SetY(-15);
+ // Arial italic 8
+ $this->SetFont('Arial','I',8);
+ // Page number
+ $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
+}
+}
+
+// Instanciation of inherited class
+$pdf = new PDF();
+$pdf->AliasNbPages();
+$pdf->AddPage();
+$pdf->SetFont('Times','',12);
+for($i=1;$i<=40;$i++)
+ $pdf->Cell(0,10,'Printing line number '.$i,0,1);
+$pdf->Output();
+?>
diff --git a/pdf/fpdf/tutorial/tuto3.htm b/pdf/fpdf/tutorial/tuto3.htm new file mode 100755 index 0000000..fa58307 --- /dev/null +++ b/pdf/fpdf/tutorial/tuto3.htm @@ -0,0 +1,115 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Line breaks and colors</title>
+<link type="text/css" rel="stylesheet" href="../fpdf.css">
+</head>
+<body>
+<h1>Line breaks and colors</h1>
+Let's continue with an example which prints justified paragraphs. It also illustrates the use
+of colors.
+<div class="source">
+<pre><code><?php
+<span class="kw">require(</span><span class="str">'fpdf.php'</span><span class="kw">);
+
+class </span>PDF <span class="kw">extends </span>FPDF
+<span class="kw">{
+function </span>Header<span class="kw">()
+{
+ global </span>$title<span class="kw">;
+
+ </span><span class="cmt">// Arial bold 15
+ </span>$<span class="kw">this-></span>SetFont<span class="kw">(</span><span class="str">'Arial'</span><span class="kw">,</span><span class="str">'B'</span><span class="kw">,</span>15<span class="kw">);
+ </span><span class="cmt">// Calculate width of title and position
+ </span>$w <span class="kw">= </span>$<span class="kw">this-></span>GetStringWidth<span class="kw">(</span>$title<span class="kw">)+</span>6<span class="kw">;
+ </span>$<span class="kw">this-></span>SetX<span class="kw">((</span>210<span class="kw">-</span>$w<span class="kw">)/</span>2<span class="kw">);
+ </span><span class="cmt">// Colors of frame, background and text
+ </span>$<span class="kw">this-></span>SetDrawColor<span class="kw">(</span>0<span class="kw">,</span>80<span class="kw">,</span>180<span class="kw">);
+ </span>$<span class="kw">this-></span>SetFillColor<span class="kw">(</span>230<span class="kw">,</span>230<span class="kw">,</span>0<span class="kw">);
+ </span>$<span class="kw">this-></span>SetTextColor<span class="kw">(</span>220<span class="kw">,</span>50<span class="kw">,</span>50<span class="kw">);
+ </span><span class="cmt">// Thickness of frame (1 mm)
+ </span>$<span class="kw">this-></span>SetLineWidth<span class="kw">(</span>1<span class="kw">);
+ </span><span class="cmt">// Title
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>$w<span class="kw">,</span>9<span class="kw">,</span>$title<span class="kw">,</span>1<span class="kw">,</span>1<span class="kw">,</span><span class="str">'C'</span><span class="kw">,</span>true<span class="kw">);
+ </span><span class="cmt">// Line break
+ </span>$<span class="kw">this-></span>Ln<span class="kw">(</span>10<span class="kw">);
+}
+
+function </span>Footer<span class="kw">()
+{
+ </span><span class="cmt">// Position at 1.5 cm from bottom
+ </span>$<span class="kw">this-></span>SetY<span class="kw">(-</span>15<span class="kw">);
+ </span><span class="cmt">// Arial italic 8
+ </span>$<span class="kw">this-></span>SetFont<span class="kw">(</span><span class="str">'Arial'</span><span class="kw">,</span><span class="str">'I'</span><span class="kw">,</span>8<span class="kw">);
+ </span><span class="cmt">// Text color in gray
+ </span>$<span class="kw">this-></span>SetTextColor<span class="kw">(</span>128<span class="kw">);
+ </span><span class="cmt">// Page number
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>0<span class="kw">,</span>10<span class="kw">,</span><span class="str">'Page '</span><span class="kw">.</span>$<span class="kw">this-></span>PageNo<span class="kw">(),</span>0<span class="kw">,</span>0<span class="kw">,</span><span class="str">'C'</span><span class="kw">);
+}
+
+function </span>ChapterTitle<span class="kw">(</span>$num<span class="kw">, </span>$label<span class="kw">)
+{
+ </span><span class="cmt">// Arial 12
+ </span>$<span class="kw">this-></span>SetFont<span class="kw">(</span><span class="str">'Arial'</span><span class="kw">,</span><span class="str">''</span><span class="kw">,</span>12<span class="kw">);
+ </span><span class="cmt">// Background color
+ </span>$<span class="kw">this-></span>SetFillColor<span class="kw">(</span>200<span class="kw">,</span>220<span class="kw">,</span>255<span class="kw">);
+ </span><span class="cmt">// Title
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>0<span class="kw">,</span>6<span class="kw">,</span><span class="str">"Chapter </span>$num<span class="str"> : </span>$label<span class="str">"</span><span class="kw">,</span>0<span class="kw">,</span>1<span class="kw">,</span><span class="str">'L'</span><span class="kw">,</span>true<span class="kw">);
+ </span><span class="cmt">// Line break
+ </span>$<span class="kw">this-></span>Ln<span class="kw">(</span>4<span class="kw">);
+}
+
+function </span>ChapterBody<span class="kw">(</span>$file<span class="kw">)
+{
+ </span><span class="cmt">// Read text file
+ </span>$txt <span class="kw">= </span>file_get_contents<span class="kw">(</span>$file<span class="kw">);
+ </span><span class="cmt">// Times 12
+ </span>$<span class="kw">this-></span>SetFont<span class="kw">(</span><span class="str">'Times'</span><span class="kw">,</span><span class="str">''</span><span class="kw">,</span>12<span class="kw">);
+ </span><span class="cmt">// Output justified text
+ </span>$<span class="kw">this-></span>MultiCell<span class="kw">(</span>0<span class="kw">,</span>5<span class="kw">,</span>$txt<span class="kw">);
+ </span><span class="cmt">// Line break
+ </span>$<span class="kw">this-></span>Ln<span class="kw">();
+ </span><span class="cmt">// Mention in italics
+ </span>$<span class="kw">this-></span>SetFont<span class="kw">(</span><span class="str">''</span><span class="kw">,</span><span class="str">'I'</span><span class="kw">);
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>0<span class="kw">,</span>5<span class="kw">,</span><span class="str">'(end of excerpt)'</span><span class="kw">);
+}
+
+function </span>PrintChapter<span class="kw">(</span>$num<span class="kw">, </span>$title<span class="kw">, </span>$file<span class="kw">)
+{
+ </span>$<span class="kw">this-></span>AddPage<span class="kw">();
+ </span>$<span class="kw">this-></span>ChapterTitle<span class="kw">(</span>$num<span class="kw">,</span>$title<span class="kw">);
+ </span>$<span class="kw">this-></span>ChapterBody<span class="kw">(</span>$file<span class="kw">);
+}
+}
+
+</span>$pdf <span class="kw">= new </span>PDF<span class="kw">();
+</span>$title <span class="kw">= </span><span class="str">'20000 Leagues Under the Seas'</span><span class="kw">;
+</span>$pdf<span class="kw">-></span>SetTitle<span class="kw">(</span>$title<span class="kw">);
+</span>$pdf<span class="kw">-></span>SetAuthor<span class="kw">(</span><span class="str">'Jules Verne'</span><span class="kw">);
+</span>$pdf<span class="kw">-></span>PrintChapter<span class="kw">(</span>1<span class="kw">,</span><span class="str">'A RUNAWAY REEF'</span><span class="kw">,</span><span class="str">'20k_c1.txt'</span><span class="kw">);
+</span>$pdf<span class="kw">-></span>PrintChapter<span class="kw">(</span>2<span class="kw">,</span><span class="str">'THE PROS AND CONS'</span><span class="kw">,</span><span class="str">'20k_c2.txt'</span><span class="kw">);
+</span>$pdf<span class="kw">-></span>Output<span class="kw">();
+</span>?></code></pre>
+</div>
+<p class='demo'><a href='tuto3.php' target='_blank' class='demo'>[Demo]</a></p>
+The <a href='../doc/getstringwidth.htm'>GetStringWidth()</a> method allows to determine the length of a string in the current font,
+which is used here to calculate the position and the width of the frame surrounding the title.
+Then colors are set (via <a href='../doc/setdrawcolor.htm'>SetDrawColor()</a>, <a href='../doc/setfillcolor.htm'>SetFillColor()</a> and <a href='../doc/settextcolor.htm'>SetTextColor()</a>) and the
+thickness of the line is set to 1 mm (instead of 0.2 by default) with <a href='../doc/setlinewidth.htm'>SetLineWidth()</a>. Finally,
+we output the cell (the last parameter <code>true</code> indicates that the background must
+be filled).
+<br>
+<br>
+The method used to print the paragraphs is <a href='../doc/multicell.htm'>MultiCell()</a>. Each time a line reaches the
+right extremity of the cell or a carriage return character is met, a line break is issued
+and a new cell automatically created under the current one. Text is justified by default.
+<br>
+<br>
+Two document properties are defined: the title (<a href='../doc/settitle.htm'>SetTitle()</a>) and the author (<a href='../doc/setauthor.htm'>SetAuthor()</a>).
+There are several ways to view them in Adobe Reader. The first one is to open the file directly with
+the reader, go to the File menu and choose the Properties option. The second one, also available from
+the plug-in, is to right-click and select Document Properties. The third method is to type the Ctrl+D
+key combination.
+</body>
+</html>
diff --git a/pdf/fpdf/tutorial/tuto3.php b/pdf/fpdf/tutorial/tuto3.php new file mode 100755 index 0000000..eade51c --- /dev/null +++ b/pdf/fpdf/tutorial/tuto3.php @@ -0,0 +1,81 @@ +<?php
+require('../fpdf.php');
+
+class PDF extends FPDF
+{
+function Header()
+{
+ global $title;
+
+ // Arial bold 15
+ $this->SetFont('Arial','B',15);
+ // Calculate width of title and position
+ $w = $this->GetStringWidth($title)+6;
+ $this->SetX((210-$w)/2);
+ // Colors of frame, background and text
+ $this->SetDrawColor(0,80,180);
+ $this->SetFillColor(230,230,0);
+ $this->SetTextColor(220,50,50);
+ // Thickness of frame (1 mm)
+ $this->SetLineWidth(1);
+ // Title
+ $this->Cell($w,9,$title,1,1,'C',true);
+ // Line break
+ $this->Ln(10);
+}
+
+function Footer()
+{
+ // Position at 1.5 cm from bottom
+ $this->SetY(-15);
+ // Arial italic 8
+ $this->SetFont('Arial','I',8);
+ // Text color in gray
+ $this->SetTextColor(128);
+ // Page number
+ $this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C');
+}
+
+function ChapterTitle($num, $label)
+{
+ // Arial 12
+ $this->SetFont('Arial','',12);
+ // Background color
+ $this->SetFillColor(200,220,255);
+ // Title
+ $this->Cell(0,6,"Chapter $num : $label",0,1,'L',true);
+ // Line break
+ $this->Ln(4);
+}
+
+function ChapterBody($file)
+{
+ // Read text file
+ $txt = file_get_contents($file);
+ // Times 12
+ $this->SetFont('Times','',12);
+ // Output justified text
+ $this->MultiCell(0,5,$txt);
+ // Line break
+ $this->Ln();
+ // Mention in italics
+ $this->SetFont('','I');
+ $this->Cell(0,5,'(end of excerpt)');
+}
+
+function PrintChapter($num, $title, $file)
+{
+ $this->AddPage();
+ $this->ChapterTitle($num,$title);
+ $this->ChapterBody($file);
+}
+}
+
+$pdf = new PDF();
+$title = '20000 Leagues Under the Seas';
+$pdf->SetTitle($title);
+$pdf->SetAuthor('Jules Verne');
+$pdf->PrintChapter(1,'A RUNAWAY REEF','20k_c1.txt');
+$pdf->PrintChapter(2,'THE PROS AND CONS','20k_c2.txt');
+$pdf->Output();
+?>
diff --git a/pdf/fpdf/tutorial/tuto4.htm b/pdf/fpdf/tutorial/tuto4.htm new file mode 100755 index 0000000..7af730f --- /dev/null +++ b/pdf/fpdf/tutorial/tuto4.htm @@ -0,0 +1,132 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Multi-columns</title>
+<link type="text/css" rel="stylesheet" href="../fpdf.css">
+</head>
+<body>
+<h1>Multi-columns</h1>
+This example is a variant of the previous one showing how to lay the text across multiple
+columns.
+<div class="source">
+<pre><code><?php
+<span class="kw">require(</span><span class="str">'fpdf.php'</span><span class="kw">);
+
+class </span>PDF <span class="kw">extends </span>FPDF
+<span class="kw">{
+protected </span>$col <span class="kw">= </span>0<span class="kw">; </span><span class="cmt">// Current column
+</span><span class="kw">protected </span>$y0<span class="kw">; </span><span class="cmt">// Ordinate of column start
+
+</span><span class="kw">function </span>Header<span class="kw">()
+{
+ </span><span class="cmt">// Page header
+ </span><span class="kw">global </span>$title<span class="kw">;
+
+ </span>$<span class="kw">this-></span>SetFont<span class="kw">(</span><span class="str">'Arial'</span><span class="kw">,</span><span class="str">'B'</span><span class="kw">,</span>15<span class="kw">);
+ </span>$w <span class="kw">= </span>$<span class="kw">this-></span>GetStringWidth<span class="kw">(</span>$title<span class="kw">)+</span>6<span class="kw">;
+ </span>$<span class="kw">this-></span>SetX<span class="kw">((</span>210<span class="kw">-</span>$w<span class="kw">)/</span>2<span class="kw">);
+ </span>$<span class="kw">this-></span>SetDrawColor<span class="kw">(</span>0<span class="kw">,</span>80<span class="kw">,</span>180<span class="kw">);
+ </span>$<span class="kw">this-></span>SetFillColor<span class="kw">(</span>230<span class="kw">,</span>230<span class="kw">,</span>0<span class="kw">);
+ </span>$<span class="kw">this-></span>SetTextColor<span class="kw">(</span>220<span class="kw">,</span>50<span class="kw">,</span>50<span class="kw">);
+ </span>$<span class="kw">this-></span>SetLineWidth<span class="kw">(</span>1<span class="kw">);
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>$w<span class="kw">,</span>9<span class="kw">,</span>$title<span class="kw">,</span>1<span class="kw">,</span>1<span class="kw">,</span><span class="str">'C'</span><span class="kw">,</span>true<span class="kw">);
+ </span>$<span class="kw">this-></span>Ln<span class="kw">(</span>10<span class="kw">);
+ </span><span class="cmt">// Save ordinate
+ </span>$<span class="kw">this-></span>y0 <span class="kw">= </span>$<span class="kw">this-></span>GetY<span class="kw">();
+}
+
+function </span>Footer<span class="kw">()
+{
+ </span><span class="cmt">// Page footer
+ </span>$<span class="kw">this-></span>SetY<span class="kw">(-</span>15<span class="kw">);
+ </span>$<span class="kw">this-></span>SetFont<span class="kw">(</span><span class="str">'Arial'</span><span class="kw">,</span><span class="str">'I'</span><span class="kw">,</span>8<span class="kw">);
+ </span>$<span class="kw">this-></span>SetTextColor<span class="kw">(</span>128<span class="kw">);
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>0<span class="kw">,</span>10<span class="kw">,</span><span class="str">'Page '</span><span class="kw">.</span>$<span class="kw">this-></span>PageNo<span class="kw">(),</span>0<span class="kw">,</span>0<span class="kw">,</span><span class="str">'C'</span><span class="kw">);
+}
+
+function </span>SetCol<span class="kw">(</span>$col<span class="kw">)
+{
+ </span><span class="cmt">// Set position at a given column
+ </span>$<span class="kw">this-></span>col <span class="kw">= </span>$col<span class="kw">;
+ </span>$x <span class="kw">= </span>10<span class="kw">+</span>$col<span class="kw">*</span>65<span class="kw">;
+ </span>$<span class="kw">this-></span>SetLeftMargin<span class="kw">(</span>$x<span class="kw">);
+ </span>$<span class="kw">this-></span>SetX<span class="kw">(</span>$x<span class="kw">);
+}
+
+function </span>AcceptPageBreak<span class="kw">()
+{
+ </span><span class="cmt">// Method accepting or not automatic page break
+ </span><span class="kw">if(</span>$<span class="kw">this-></span>col<span class="kw"><</span>2<span class="kw">)
+ {
+ </span><span class="cmt">// Go to next column
+ </span>$<span class="kw">this-></span>SetCol<span class="kw">(</span>$<span class="kw">this-></span>col<span class="kw">+</span>1<span class="kw">);
+ </span><span class="cmt">// Set ordinate to top
+ </span>$<span class="kw">this-></span>SetY<span class="kw">(</span>$<span class="kw">this-></span>y0<span class="kw">);
+ </span><span class="cmt">// Keep on page
+ </span><span class="kw">return </span>false<span class="kw">;
+ }
+ else
+ {
+ </span><span class="cmt">// Go back to first column
+ </span>$<span class="kw">this-></span>SetCol<span class="kw">(</span>0<span class="kw">);
+ </span><span class="cmt">// Page break
+ </span><span class="kw">return </span>true<span class="kw">;
+ }
+}
+
+function </span>ChapterTitle<span class="kw">(</span>$num<span class="kw">, </span>$label<span class="kw">)
+{
+ </span><span class="cmt">// Title
+ </span>$<span class="kw">this-></span>SetFont<span class="kw">(</span><span class="str">'Arial'</span><span class="kw">,</span><span class="str">''</span><span class="kw">,</span>12<span class="kw">);
+ </span>$<span class="kw">this-></span>SetFillColor<span class="kw">(</span>200<span class="kw">,</span>220<span class="kw">,</span>255<span class="kw">);
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>0<span class="kw">,</span>6<span class="kw">,</span><span class="str">"Chapter </span>$num<span class="str"> : </span>$label<span class="str">"</span><span class="kw">,</span>0<span class="kw">,</span>1<span class="kw">,</span><span class="str">'L'</span><span class="kw">,</span>true<span class="kw">);
+ </span>$<span class="kw">this-></span>Ln<span class="kw">(</span>4<span class="kw">);
+ </span><span class="cmt">// Save ordinate
+ </span>$<span class="kw">this-></span>y0 <span class="kw">= </span>$<span class="kw">this-></span>GetY<span class="kw">();
+}
+
+function </span>ChapterBody<span class="kw">(</span>$file<span class="kw">)
+{
+ </span><span class="cmt">// Read text file
+ </span>$txt <span class="kw">= </span>file_get_contents<span class="kw">(</span>$file<span class="kw">);
+ </span><span class="cmt">// Font
+ </span>$<span class="kw">this-></span>SetFont<span class="kw">(</span><span class="str">'Times'</span><span class="kw">,</span><span class="str">''</span><span class="kw">,</span>12<span class="kw">);
+ </span><span class="cmt">// Output text in a 6 cm width column
+ </span>$<span class="kw">this-></span>MultiCell<span class="kw">(</span>60<span class="kw">,</span>5<span class="kw">,</span>$txt<span class="kw">);
+ </span>$<span class="kw">this-></span>Ln<span class="kw">();
+ </span><span class="cmt">// Mention
+ </span>$<span class="kw">this-></span>SetFont<span class="kw">(</span><span class="str">''</span><span class="kw">,</span><span class="str">'I'</span><span class="kw">);
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>0<span class="kw">,</span>5<span class="kw">,</span><span class="str">'(end of excerpt)'</span><span class="kw">);
+ </span><span class="cmt">// Go back to first column
+ </span>$<span class="kw">this-></span>SetCol<span class="kw">(</span>0<span class="kw">);
+}
+
+function </span>PrintChapter<span class="kw">(</span>$num<span class="kw">, </span>$title<span class="kw">, </span>$file<span class="kw">)
+{
+ </span><span class="cmt">// Add chapter
+ </span>$<span class="kw">this-></span>AddPage<span class="kw">();
+ </span>$<span class="kw">this-></span>ChapterTitle<span class="kw">(</span>$num<span class="kw">,</span>$title<span class="kw">);
+ </span>$<span class="kw">this-></span>ChapterBody<span class="kw">(</span>$file<span class="kw">);
+}
+}
+
+</span>$pdf <span class="kw">= new </span>PDF<span class="kw">();
+</span>$title <span class="kw">= </span><span class="str">'20000 Leagues Under the Seas'</span><span class="kw">;
+</span>$pdf<span class="kw">-></span>SetTitle<span class="kw">(</span>$title<span class="kw">);
+</span>$pdf<span class="kw">-></span>SetAuthor<span class="kw">(</span><span class="str">'Jules Verne'</span><span class="kw">);
+</span>$pdf<span class="kw">-></span>PrintChapter<span class="kw">(</span>1<span class="kw">,</span><span class="str">'A RUNAWAY REEF'</span><span class="kw">,</span><span class="str">'20k_c1.txt'</span><span class="kw">);
+</span>$pdf<span class="kw">-></span>PrintChapter<span class="kw">(</span>2<span class="kw">,</span><span class="str">'THE PROS AND CONS'</span><span class="kw">,</span><span class="str">'20k_c2.txt'</span><span class="kw">);
+</span>$pdf<span class="kw">-></span>Output<span class="kw">();
+</span>?></code></pre>
+</div>
+<p class='demo'><a href='tuto4.php' target='_blank' class='demo'>[Demo]</a></p>
+The key method used is <a href='../doc/acceptpagebreak.htm'>AcceptPageBreak()</a>. It allows to accept or not an automatic page
+break. By refusing it and altering the margin and current position, the desired column layout
+is achieved.
+<br>
+For the rest, not many changes; two properties have been added to the class to save the current
+column number and the position where columns begin, and the MultiCell() call specifies a
+6 centimeter width.
+</body>
+</html>
diff --git a/pdf/fpdf/tutorial/tuto4.php b/pdf/fpdf/tutorial/tuto4.php new file mode 100755 index 0000000..f5f4fa8 --- /dev/null +++ b/pdf/fpdf/tutorial/tuto4.php @@ -0,0 +1,109 @@ +<?php
+require('../fpdf.php');
+
+class PDF extends FPDF
+{
+protected $col = 0; // Current column
+protected $y0; // Ordinate of column start
+
+function Header()
+{
+ // Page header
+ global $title;
+
+ $this->SetFont('Arial','B',15);
+ $w = $this->GetStringWidth($title)+6;
+ $this->SetX((210-$w)/2);
+ $this->SetDrawColor(0,80,180);
+ $this->SetFillColor(230,230,0);
+ $this->SetTextColor(220,50,50);
+ $this->SetLineWidth(1);
+ $this->Cell($w,9,$title,1,1,'C',true);
+ $this->Ln(10);
+ // Save ordinate
+ $this->y0 = $this->GetY();
+}
+
+function Footer()
+{
+ // Page footer
+ $this->SetY(-15);
+ $this->SetFont('Arial','I',8);
+ $this->SetTextColor(128);
+ $this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C');
+}
+
+function SetCol($col)
+{
+ // Set position at a given column
+ $this->col = $col;
+ $x = 10+$col*65;
+ $this->SetLeftMargin($x);
+ $this->SetX($x);
+}
+
+function AcceptPageBreak()
+{
+ // Method accepting or not automatic page break
+ if($this->col<2)
+ {
+ // Go to next column
+ $this->SetCol($this->col+1);
+ // Set ordinate to top
+ $this->SetY($this->y0);
+ // Keep on page
+ return false;
+ }
+ else
+ {
+ // Go back to first column
+ $this->SetCol(0);
+ // Page break
+ return true;
+ }
+}
+
+function ChapterTitle($num, $label)
+{
+ // Title
+ $this->SetFont('Arial','',12);
+ $this->SetFillColor(200,220,255);
+ $this->Cell(0,6,"Chapter $num : $label",0,1,'L',true);
+ $this->Ln(4);
+ // Save ordinate
+ $this->y0 = $this->GetY();
+}
+
+function ChapterBody($file)
+{
+ // Read text file
+ $txt = file_get_contents($file);
+ // Font
+ $this->SetFont('Times','',12);
+ // Output text in a 6 cm width column
+ $this->MultiCell(60,5,$txt);
+ $this->Ln();
+ // Mention
+ $this->SetFont('','I');
+ $this->Cell(0,5,'(end of excerpt)');
+ // Go back to first column
+ $this->SetCol(0);
+}
+
+function PrintChapter($num, $title, $file)
+{
+ // Add chapter
+ $this->AddPage();
+ $this->ChapterTitle($num,$title);
+ $this->ChapterBody($file);
+}
+}
+
+$pdf = new PDF();
+$title = '20000 Leagues Under the Seas';
+$pdf->SetTitle($title);
+$pdf->SetAuthor('Jules Verne');
+$pdf->PrintChapter(1,'A RUNAWAY REEF','20k_c1.txt');
+$pdf->PrintChapter(2,'THE PROS AND CONS','20k_c2.txt');
+$pdf->Output();
+?>
diff --git a/pdf/fpdf/tutorial/tuto5.htm b/pdf/fpdf/tutorial/tuto5.htm new file mode 100755 index 0000000..03fdd54 --- /dev/null +++ b/pdf/fpdf/tutorial/tuto5.htm @@ -0,0 +1,134 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Tables</title>
+<link type="text/css" rel="stylesheet" href="../fpdf.css">
+</head>
+<body>
+<h1>Tables</h1>
+This tutorial shows different ways to make tables.
+<div class="source">
+<pre><code><?php
+<span class="kw">require(</span><span class="str">'fpdf.php'</span><span class="kw">);
+
+class </span>PDF <span class="kw">extends </span>FPDF
+<span class="kw">{
+</span><span class="cmt">// Load data
+</span><span class="kw">function </span>LoadData<span class="kw">(</span>$file<span class="kw">)
+{
+ </span><span class="cmt">// Read file lines
+ </span>$lines <span class="kw">= </span>file<span class="kw">(</span>$file<span class="kw">);
+ </span>$data <span class="kw">= array();
+ foreach(</span>$lines <span class="kw">as </span>$line<span class="kw">)
+ </span>$data<span class="kw">[] = </span>explode<span class="kw">(</span><span class="str">';'</span><span class="kw">,</span>trim<span class="kw">(</span>$line<span class="kw">));
+ return </span>$data<span class="kw">;
+}
+
+</span><span class="cmt">// Simple table
+</span><span class="kw">function </span>BasicTable<span class="kw">(</span>$header<span class="kw">, </span>$data<span class="kw">)
+{
+ </span><span class="cmt">// Header
+ </span><span class="kw">foreach(</span>$header <span class="kw">as </span>$col<span class="kw">)
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>40<span class="kw">,</span>7<span class="kw">,</span>$col<span class="kw">,</span>1<span class="kw">);
+ </span>$<span class="kw">this-></span>Ln<span class="kw">();
+ </span><span class="cmt">// Data
+ </span><span class="kw">foreach(</span>$data <span class="kw">as </span>$row<span class="kw">)
+ {
+ foreach(</span>$row <span class="kw">as </span>$col<span class="kw">)
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>40<span class="kw">,</span>6<span class="kw">,</span>$col<span class="kw">,</span>1<span class="kw">);
+ </span>$<span class="kw">this-></span>Ln<span class="kw">();
+ }
+}
+
+</span><span class="cmt">// Better table
+</span><span class="kw">function </span>ImprovedTable<span class="kw">(</span>$header<span class="kw">, </span>$data<span class="kw">)
+{
+ </span><span class="cmt">// Column widths
+ </span>$w <span class="kw">= array(</span>40<span class="kw">, </span>35<span class="kw">, </span>40<span class="kw">, </span>45<span class="kw">);
+ </span><span class="cmt">// Header
+ </span><span class="kw">for(</span>$i<span class="kw">=</span>0<span class="kw">;</span>$i<span class="kw"><</span>count<span class="kw">(</span>$header<span class="kw">);</span>$i<span class="kw">++)
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>$w<span class="kw">[</span>$i<span class="kw">],</span>7<span class="kw">,</span>$header<span class="kw">[</span>$i<span class="kw">],</span>1<span class="kw">,</span>0<span class="kw">,</span><span class="str">'C'</span><span class="kw">);
+ </span>$<span class="kw">this-></span>Ln<span class="kw">();
+ </span><span class="cmt">// Data
+ </span><span class="kw">foreach(</span>$data <span class="kw">as </span>$row<span class="kw">)
+ {
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>$w<span class="kw">[</span>0<span class="kw">],</span>6<span class="kw">,</span>$row<span class="kw">[</span>0<span class="kw">],</span><span class="str">'LR'</span><span class="kw">);
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>$w<span class="kw">[</span>1<span class="kw">],</span>6<span class="kw">,</span>$row<span class="kw">[</span>1<span class="kw">],</span><span class="str">'LR'</span><span class="kw">);
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>$w<span class="kw">[</span>2<span class="kw">],</span>6<span class="kw">,</span>number_format<span class="kw">(</span>$row<span class="kw">[</span>2<span class="kw">]),</span><span class="str">'LR'</span><span class="kw">,</span>0<span class="kw">,</span><span class="str">'R'</span><span class="kw">);
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>$w<span class="kw">[</span>3<span class="kw">],</span>6<span class="kw">,</span>number_format<span class="kw">(</span>$row<span class="kw">[</span>3<span class="kw">]),</span><span class="str">'LR'</span><span class="kw">,</span>0<span class="kw">,</span><span class="str">'R'</span><span class="kw">);
+ </span>$<span class="kw">this-></span>Ln<span class="kw">();
+ }
+ </span><span class="cmt">// Closing line
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>array_sum<span class="kw">(</span>$w<span class="kw">),</span>0<span class="kw">,</span><span class="str">''</span><span class="kw">,</span><span class="str">'T'</span><span class="kw">);
+}
+
+</span><span class="cmt">// Colored table
+</span><span class="kw">function </span>FancyTable<span class="kw">(</span>$header<span class="kw">, </span>$data<span class="kw">)
+{
+ </span><span class="cmt">// Colors, line width and bold font
+ </span>$<span class="kw">this-></span>SetFillColor<span class="kw">(</span>255<span class="kw">,</span>0<span class="kw">,</span>0<span class="kw">);
+ </span>$<span class="kw">this-></span>SetTextColor<span class="kw">(</span>255<span class="kw">);
+ </span>$<span class="kw">this-></span>SetDrawColor<span class="kw">(</span>128<span class="kw">,</span>0<span class="kw">,</span>0<span class="kw">);
+ </span>$<span class="kw">this-></span>SetLineWidth<span class="kw">(</span>.3<span class="kw">);
+ </span>$<span class="kw">this-></span>SetFont<span class="kw">(</span><span class="str">''</span><span class="kw">,</span><span class="str">'B'</span><span class="kw">);
+ </span><span class="cmt">// Header
+ </span>$w <span class="kw">= array(</span>40<span class="kw">, </span>35<span class="kw">, </span>40<span class="kw">, </span>45<span class="kw">);
+ for(</span>$i<span class="kw">=</span>0<span class="kw">;</span>$i<span class="kw"><</span>count<span class="kw">(</span>$header<span class="kw">);</span>$i<span class="kw">++)
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>$w<span class="kw">[</span>$i<span class="kw">],</span>7<span class="kw">,</span>$header<span class="kw">[</span>$i<span class="kw">],</span>1<span class="kw">,</span>0<span class="kw">,</span><span class="str">'C'</span><span class="kw">,</span>true<span class="kw">);
+ </span>$<span class="kw">this-></span>Ln<span class="kw">();
+ </span><span class="cmt">// Color and font restoration
+ </span>$<span class="kw">this-></span>SetFillColor<span class="kw">(</span>224<span class="kw">,</span>235<span class="kw">,</span>255<span class="kw">);
+ </span>$<span class="kw">this-></span>SetTextColor<span class="kw">(</span>0<span class="kw">);
+ </span>$<span class="kw">this-></span>SetFont<span class="kw">(</span><span class="str">''</span><span class="kw">);
+ </span><span class="cmt">// Data
+ </span>$fill <span class="kw">= </span>false<span class="kw">;
+ foreach(</span>$data <span class="kw">as </span>$row<span class="kw">)
+ {
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>$w<span class="kw">[</span>0<span class="kw">],</span>6<span class="kw">,</span>$row<span class="kw">[</span>0<span class="kw">],</span><span class="str">'LR'</span><span class="kw">,</span>0<span class="kw">,</span><span class="str">'L'</span><span class="kw">,</span>$fill<span class="kw">);
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>$w<span class="kw">[</span>1<span class="kw">],</span>6<span class="kw">,</span>$row<span class="kw">[</span>1<span class="kw">],</span><span class="str">'LR'</span><span class="kw">,</span>0<span class="kw">,</span><span class="str">'L'</span><span class="kw">,</span>$fill<span class="kw">);
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>$w<span class="kw">[</span>2<span class="kw">],</span>6<span class="kw">,</span>number_format<span class="kw">(</span>$row<span class="kw">[</span>2<span class="kw">]),</span><span class="str">'LR'</span><span class="kw">,</span>0<span class="kw">,</span><span class="str">'R'</span><span class="kw">,</span>$fill<span class="kw">);
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>$w<span class="kw">[</span>3<span class="kw">],</span>6<span class="kw">,</span>number_format<span class="kw">(</span>$row<span class="kw">[</span>3<span class="kw">]),</span><span class="str">'LR'</span><span class="kw">,</span>0<span class="kw">,</span><span class="str">'R'</span><span class="kw">,</span>$fill<span class="kw">);
+ </span>$<span class="kw">this-></span>Ln<span class="kw">();
+ </span>$fill <span class="kw">= !</span>$fill<span class="kw">;
+ }
+ </span><span class="cmt">// Closing line
+ </span>$<span class="kw">this-></span>Cell<span class="kw">(</span>array_sum<span class="kw">(</span>$w<span class="kw">),</span>0<span class="kw">,</span><span class="str">''</span><span class="kw">,</span><span class="str">'T'</span><span class="kw">);
+}
+}
+
+</span>$pdf <span class="kw">= new </span>PDF<span class="kw">();
+</span><span class="cmt">// Column headings
+</span>$header <span class="kw">= array(</span><span class="str">'Country'</span><span class="kw">, </span><span class="str">'Capital'</span><span class="kw">, </span><span class="str">'Area (sq km)'</span><span class="kw">, </span><span class="str">'Pop. (thousands)'</span><span class="kw">);
+</span><span class="cmt">// Data loading
+</span>$data <span class="kw">= </span>$pdf<span class="kw">-></span>LoadData<span class="kw">(</span><span class="str">'countries.txt'</span><span class="kw">);
+</span>$pdf<span class="kw">-></span>SetFont<span class="kw">(</span><span class="str">'Arial'</span><span class="kw">,</span><span class="str">''</span><span class="kw">,</span>14<span class="kw">);
+</span>$pdf<span class="kw">-></span>AddPage<span class="kw">();
+</span>$pdf<span class="kw">-></span>BasicTable<span class="kw">(</span>$header<span class="kw">,</span>$data<span class="kw">);
+</span>$pdf<span class="kw">-></span>AddPage<span class="kw">();
+</span>$pdf<span class="kw">-></span>ImprovedTable<span class="kw">(</span>$header<span class="kw">,</span>$data<span class="kw">);
+</span>$pdf<span class="kw">-></span>AddPage<span class="kw">();
+</span>$pdf<span class="kw">-></span>FancyTable<span class="kw">(</span>$header<span class="kw">,</span>$data<span class="kw">);
+</span>$pdf<span class="kw">-></span>Output<span class="kw">();
+</span>?></code></pre>
+</div>
+<p class='demo'><a href='tuto5.php' target='_blank' class='demo'>[Demo]</a></p>
+A table being just a collection of cells, it's natural to build one from them. The first
+example is achieved in the most basic way possible: simple framed cells, all of the same size
+and left aligned. The result is rudimentary but very quick to obtain.
+<br>
+<br>
+The second table brings some improvements: each column has its own width, headings are centered,
+and numbers right aligned. Moreover, horizontal lines have been removed. This is done by means
+of the <code>border</code> parameter of the <a href='../doc/cell.htm'>Cell()</a> method, which specifies which sides of the
+cell must be drawn. Here we want the left (<code>L</code>) and right (<code>R</code>) ones. It remains
+the problem of the horizontal line to finish the table. There are two possibilities: either
+check for the last line in the loop, in which case we use <code>LRB</code> for the <code>border</code>
+parameter; or, as done here, add the line once the loop is over.
+<br>
+<br>
+The third table is similar to the second one but uses colors. Fill, text and line colors are
+simply specified. Alternate coloring for rows is obtained by using alternatively transparent
+and filled cells.
+</body>
+</html>
diff --git a/pdf/fpdf/tutorial/tuto5.php b/pdf/fpdf/tutorial/tuto5.php new file mode 100755 index 0000000..f1b64a2 --- /dev/null +++ b/pdf/fpdf/tutorial/tuto5.php @@ -0,0 +1,102 @@ +<?php
+require('../fpdf.php');
+
+class PDF extends FPDF
+{
+// Load data
+function LoadData($file)
+{
+ // Read file lines
+ $lines = file($file);
+ $data = array();
+ foreach($lines as $line)
+ $data[] = explode(';',trim($line));
+ return $data;
+}
+
+// Simple table
+function BasicTable($header, $data)
+{
+ // Header
+ foreach($header as $col)
+ $this->Cell(40,7,$col,1);
+ $this->Ln();
+ // Data
+ foreach($data as $row)
+ {
+ foreach($row as $col)
+ $this->Cell(40,6,$col,1);
+ $this->Ln();
+ }
+}
+
+// Better table
+function ImprovedTable($header, $data)
+{
+ // Column widths
+ $w = array(40, 35, 40, 45);
+ // Header
+ for($i=0;$i<count($header);$i++)
+ $this->Cell($w[$i],7,$header[$i],1,0,'C');
+ $this->Ln();
+ // Data
+ foreach($data as $row)
+ {
+ $this->Cell($w[0],6,$row[0],'LR');
+ $this->Cell($w[1],6,$row[1],'LR');
+ $this->Cell($w[2],6,number_format($row[2]),'LR',0,'R');
+ $this->Cell($w[3],6,number_format($row[3]),'LR',0,'R');
+ $this->Ln();
+ }
+ // Closing line
+ $this->Cell(array_sum($w),0,'','T');
+}
+
+// Colored table
+function FancyTable($header, $data)
+{
+ // Colors, line width and bold font
+ $this->SetFillColor(255,0,0);
+ $this->SetTextColor(255);
+ $this->SetDrawColor(128,0,0);
+ $this->SetLineWidth(.3);
+ $this->SetFont('','B');
+ // Header
+ $w = array(40, 35, 40, 45);
+ for($i=0;$i<count($header);$i++)
+ $this->Cell($w[$i],7,$header[$i],1,0,'C',true);
+ $this->Ln();
+ // Color and font restoration
+ $this->SetFillColor(224,235,255);
+ $this->SetTextColor(0);
+ $this->SetFont('');
+ // Data
+ $fill = false;
+ foreach($data as $row)
+ {
+ $this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);
+ $this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);
+ $this->Cell($w[2],6,number_format($row[2]),'LR',0,'R',$fill);
+ $this->Cell($w[3],6,number_format($row[3]),'LR',0,'R',$fill);
+ $this->Ln();
+ $fill = !$fill;
+ }
+ // Closing line
+ $this->Cell(array_sum($w),0,'','T');
+}
+}
+
+$pdf = new PDF();
+// Column headings
+$header = array('Country', 'Capital', 'Area (sq km)', 'Pop. (thousands)');
+// Data loading
+$data = $pdf->LoadData('countries.txt');
+$pdf->SetFont('Arial','',14);
+$pdf->AddPage();
+$pdf->BasicTable($header,$data);
+$pdf->AddPage();
+$pdf->ImprovedTable($header,$data);
+$pdf->AddPage();
+$pdf->FancyTable($header,$data);
+$pdf->Output();
+?>
diff --git a/pdf/fpdf/tutorial/tuto6.htm b/pdf/fpdf/tutorial/tuto6.htm new file mode 100755 index 0000000..24516e6 --- /dev/null +++ b/pdf/fpdf/tutorial/tuto6.htm @@ -0,0 +1,154 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Links and flowing text</title>
+<link type="text/css" rel="stylesheet" href="../fpdf.css">
+</head>
+<body>
+<h1>Links and flowing text</h1>
+This tutorial explains how to insert links (internal and external) and shows a new text writing
+mode. It also contains a basic HTML parser.
+<div class="source">
+<pre><code><?php
+<span class="kw">require(</span><span class="str">'fpdf.php'</span><span class="kw">);
+
+class </span>PDF <span class="kw">extends </span>FPDF
+<span class="kw">{
+protected </span>$B <span class="kw">= </span>0<span class="kw">;
+protected </span>$I <span class="kw">= </span>0<span class="kw">;
+protected </span>$U <span class="kw">= </span>0<span class="kw">;
+protected </span>$HREF <span class="kw">= </span><span class="str">''</span><span class="kw">;
+
+function </span>WriteHTML<span class="kw">(</span>$html<span class="kw">)
+{
+ </span><span class="cmt">// HTML parser
+ </span>$html <span class="kw">= </span>str_replace<span class="kw">(</span><span class="str">"\n"</span><span class="kw">,</span><span class="str">' '</span><span class="kw">,</span>$html<span class="kw">);
+ </span>$a <span class="kw">= </span>preg_split<span class="kw">(</span><span class="str">'/<(.*)>/U'</span><span class="kw">,</span>$html<span class="kw">,-</span>1<span class="kw">,</span>PREG_SPLIT_DELIM_CAPTURE<span class="kw">);
+ foreach(</span>$a <span class="kw">as </span>$i<span class="kw">=></span>$e<span class="kw">)
+ {
+ if(</span>$i<span class="kw">%</span>2<span class="kw">==</span>0<span class="kw">)
+ {
+ </span><span class="cmt">// Text
+ </span><span class="kw">if(</span>$<span class="kw">this-></span>HREF<span class="kw">)
+ </span>$<span class="kw">this-></span>PutLink<span class="kw">(</span>$<span class="kw">this-></span>HREF<span class="kw">,</span>$e<span class="kw">);
+ else
+ </span>$<span class="kw">this-></span>Write<span class="kw">(</span>5<span class="kw">,</span>$e<span class="kw">);
+ }
+ else
+ {
+ </span><span class="cmt">// Tag
+ </span><span class="kw">if(</span>$e<span class="kw">[</span>0<span class="kw">]==</span><span class="str">'/'</span><span class="kw">)
+ </span>$<span class="kw">this-></span>CloseTag<span class="kw">(</span>strtoupper<span class="kw">(</span>substr<span class="kw">(</span>$e<span class="kw">,</span>1<span class="kw">)));
+ else
+ {
+ </span><span class="cmt">// Extract attributes
+ </span>$a2 <span class="kw">= </span>explode<span class="kw">(</span><span class="str">' '</span><span class="kw">,</span>$e<span class="kw">);
+ </span>$tag <span class="kw">= </span>strtoupper<span class="kw">(</span>array_shift<span class="kw">(</span>$a2<span class="kw">));
+ </span>$attr <span class="kw">= array();
+ foreach(</span>$a2 <span class="kw">as </span>$v<span class="kw">)
+ {
+ if(</span>preg_match<span class="kw">(</span><span class="str">'/([^=]*)=["\']?([^"\']*)/'</span><span class="kw">,</span>$v<span class="kw">,</span>$a3<span class="kw">))
+ </span>$attr<span class="kw">[</span>strtoupper<span class="kw">(</span>$a3<span class="kw">[</span>1<span class="kw">])] = </span>$a3<span class="kw">[</span>2<span class="kw">];
+ }
+ </span>$<span class="kw">this-></span>OpenTag<span class="kw">(</span>$tag<span class="kw">,</span>$attr<span class="kw">);
+ }
+ }
+ }
+}
+
+function </span>OpenTag<span class="kw">(</span>$tag<span class="kw">, </span>$attr<span class="kw">)
+{
+ </span><span class="cmt">// Opening tag
+ </span><span class="kw">if(</span>$tag<span class="kw">==</span><span class="str">'B' </span><span class="kw">|| </span>$tag<span class="kw">==</span><span class="str">'I' </span><span class="kw">|| </span>$tag<span class="kw">==</span><span class="str">'U'</span><span class="kw">)
+ </span>$<span class="kw">this-></span>SetStyle<span class="kw">(</span>$tag<span class="kw">,</span>true<span class="kw">);
+ if(</span>$tag<span class="kw">==</span><span class="str">'A'</span><span class="kw">)
+ </span>$<span class="kw">this-></span>HREF <span class="kw">= </span>$attr<span class="kw">[</span><span class="str">'HREF'</span><span class="kw">];
+ if(</span>$tag<span class="kw">==</span><span class="str">'BR'</span><span class="kw">)
+ </span>$<span class="kw">this-></span>Ln<span class="kw">(</span>5<span class="kw">);
+}
+
+function </span>CloseTag<span class="kw">(</span>$tag<span class="kw">)
+{
+ </span><span class="cmt">// Closing tag
+ </span><span class="kw">if(</span>$tag<span class="kw">==</span><span class="str">'B' </span><span class="kw">|| </span>$tag<span class="kw">==</span><span class="str">'I' </span><span class="kw">|| </span>$tag<span class="kw">==</span><span class="str">'U'</span><span class="kw">)
+ </span>$<span class="kw">this-></span>SetStyle<span class="kw">(</span>$tag<span class="kw">,</span>false<span class="kw">);
+ if(</span>$tag<span class="kw">==</span><span class="str">'A'</span><span class="kw">)
+ </span>$<span class="kw">this-></span>HREF <span class="kw">= </span><span class="str">''</span><span class="kw">;
+}
+
+function </span>SetStyle<span class="kw">(</span>$tag<span class="kw">, </span>$enable<span class="kw">)
+{
+ </span><span class="cmt">// Modify style and select corresponding font
+ </span>$<span class="kw">this-></span>$tag <span class="kw">+= (</span>$enable <span class="kw">? </span>1 <span class="kw">: -</span>1<span class="kw">);
+ </span>$style <span class="kw">= </span><span class="str">''</span><span class="kw">;
+ foreach(array(</span><span class="str">'B'</span><span class="kw">, </span><span class="str">'I'</span><span class="kw">, </span><span class="str">'U'</span><span class="kw">) as </span>$s<span class="kw">)
+ {
+ if(</span>$<span class="kw">this-></span>$s<span class="kw">></span>0<span class="kw">)
+ </span>$style <span class="kw">.= </span>$s<span class="kw">;
+ }
+ </span>$<span class="kw">this-></span>SetFont<span class="kw">(</span><span class="str">''</span><span class="kw">,</span>$style<span class="kw">);
+}
+
+function </span>PutLink<span class="kw">(</span>$URL<span class="kw">, </span>$txt<span class="kw">)
+{
+ </span><span class="cmt">// Put a hyperlink
+ </span>$<span class="kw">this-></span>SetTextColor<span class="kw">(</span>0<span class="kw">,</span>0<span class="kw">,</span>255<span class="kw">);
+ </span>$<span class="kw">this-></span>SetStyle<span class="kw">(</span><span class="str">'U'</span><span class="kw">,</span>true<span class="kw">);
+ </span>$<span class="kw">this-></span>Write<span class="kw">(</span>5<span class="kw">,</span>$txt<span class="kw">,</span>$URL<span class="kw">);
+ </span>$<span class="kw">this-></span>SetStyle<span class="kw">(</span><span class="str">'U'</span><span class="kw">,</span>false<span class="kw">);
+ </span>$<span class="kw">this-></span>SetTextColor<span class="kw">(</span>0<span class="kw">);
+}
+}
+
+</span>$html <span class="kw">= </span><span class="str">'You can now easily print text mixing different styles: <b>bold</b>, <i>italic</i>,
+<u>underlined</u>, or <b><i><u>all at once</u></i></b>!<br><br>You can also insert links on
+text, such as <a href="http://www.fpdf.org">www.fpdf.org</a>, or on an image: click on the logo.'</span><span class="kw">;
+
+</span>$pdf <span class="kw">= new </span>PDF<span class="kw">();
+</span><span class="cmt">// First page
+</span>$pdf<span class="kw">-></span>AddPage<span class="kw">();
+</span>$pdf<span class="kw">-></span>SetFont<span class="kw">(</span><span class="str">'Arial'</span><span class="kw">,</span><span class="str">''</span><span class="kw">,</span>20<span class="kw">);
+</span>$pdf<span class="kw">-></span>Write<span class="kw">(</span>5<span class="kw">,</span><span class="str">"To find out what's new in this tutorial, click "</span><span class="kw">);
+</span>$pdf<span class="kw">-></span>SetFont<span class="kw">(</span><span class="str">''</span><span class="kw">,</span><span class="str">'U'</span><span class="kw">);
+</span>$link <span class="kw">= </span>$pdf<span class="kw">-></span>AddLink<span class="kw">();
+</span>$pdf<span class="kw">-></span>Write<span class="kw">(</span>5<span class="kw">,</span><span class="str">'here'</span><span class="kw">,</span>$link<span class="kw">);
+</span>$pdf<span class="kw">-></span>SetFont<span class="kw">(</span><span class="str">''</span><span class="kw">);
+</span><span class="cmt">// Second page
+</span>$pdf<span class="kw">-></span>AddPage<span class="kw">();
+</span>$pdf<span class="kw">-></span>SetLink<span class="kw">(</span>$link<span class="kw">);
+</span>$pdf<span class="kw">-></span>Image<span class="kw">(</span><span class="str">'logo.png'</span><span class="kw">,</span>10<span class="kw">,</span>12<span class="kw">,</span>30<span class="kw">,</span>0<span class="kw">,</span><span class="str">''</span><span class="kw">,</span><span class="str">'http://www.fpdf.org'</span><span class="kw">);
+</span>$pdf<span class="kw">-></span>SetLeftMargin<span class="kw">(</span>45<span class="kw">);
+</span>$pdf<span class="kw">-></span>SetFontSize<span class="kw">(</span>14<span class="kw">);
+</span>$pdf<span class="kw">-></span>WriteHTML<span class="kw">(</span>$html<span class="kw">);
+</span>$pdf<span class="kw">-></span>Output<span class="kw">();
+</span>?></code></pre>
+</div>
+<p class='demo'><a href='tuto6.php' target='_blank' class='demo'>[Demo]</a></p>
+The new method to print text is <a href='../doc/write.htm'>Write()</a>. It's very close to <a href='../doc/multicell.htm'>MultiCell()</a>; the differences are:
+<ul>
+<li>The end of line is at the right margin and the next line begins at the left one</li>
+<li>The current position moves at the end of the text</li>
+</ul>
+So it allows to write a chunk of text, alter the font style, then continue from the exact
+place we left it. On the other hand, you cannot justify it.
+<br>
+<br>
+The method is used on the first page to put a link pointing to the second one. The beginning of
+the sentence is written in regular style, then we switch to underline and finish it. The link
+is created with <a href='../doc/addlink.htm'>AddLink()</a>, which returns a link identifier. The identifier is
+passed as third parameter of Write(). Once the second page is created, we use <a href='../doc/setlink.htm'>SetLink()</a> to
+make the link point to the beginning of the current page.
+<br>
+<br>
+Then we put an image with an external link on it. An external link is just a URL. It's passed as
+last parameter of <a href='../doc/image.htm'>Image()</a>.
+<br>
+<br>
+Finally, the left margin is moved after the image with <a href='../doc/setleftmargin.htm'>SetLeftMargin()</a> and some text in
+HTML format is output. A very simple HTML parser is used for this, based on regular expressions.
+Recognized tags are <b>, <i>, <u>, <a> and <br>; the others are
+ignored. The parser also makes use of the Write() method. An external link is put the same way as
+an internal one (third parameter of Write()). Note that <a href='../doc/cell.htm'>Cell()</a> also allows to put links.
+</body>
+</html>
diff --git a/pdf/fpdf/tutorial/tuto6.php b/pdf/fpdf/tutorial/tuto6.php new file mode 100755 index 0000000..66580e9 --- /dev/null +++ b/pdf/fpdf/tutorial/tuto6.php @@ -0,0 +1,113 @@ +<?php
+require('../fpdf.php');
+
+class PDF extends FPDF
+{
+protected $B = 0;
+protected $I = 0;
+protected $U = 0;
+protected $HREF = '';
+
+function WriteHTML($html)
+{
+ // HTML parser
+ $html = str_replace("\n",' ',$html);
+ $a = preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
+ foreach($a as $i=>$e)
+ {
+ if($i%2==0)
+ {
+ // Text
+ if($this->HREF)
+ $this->PutLink($this->HREF,$e);
+ else
+ $this->Write(5,$e);
+ }
+ else
+ {
+ // Tag
+ if($e[0]=='/')
+ $this->CloseTag(strtoupper(substr($e,1)));
+ else
+ {
+ // Extract attributes
+ $a2 = explode(' ',$e);
+ $tag = strtoupper(array_shift($a2));
+ $attr = array();
+ foreach($a2 as $v)
+ {
+ if(preg_match('/([^=]*)=["\']?([^"\']*)/',$v,$a3))
+ $attr[strtoupper($a3[1])] = $a3[2];
+ }
+ $this->OpenTag($tag,$attr);
+ }
+ }
+ }
+}
+
+function OpenTag($tag, $attr)
+{
+ // Opening tag
+ if($tag=='B' || $tag=='I' || $tag=='U')
+ $this->SetStyle($tag,true);
+ if($tag=='A')
+ $this->HREF = $attr['HREF'];
+ if($tag=='BR')
+ $this->Ln(5);
+}
+
+function CloseTag($tag)
+{
+ // Closing tag
+ if($tag=='B' || $tag=='I' || $tag=='U')
+ $this->SetStyle($tag,false);
+ if($tag=='A')
+ $this->HREF = '';
+}
+
+function SetStyle($tag, $enable)
+{
+ // Modify style and select corresponding font
+ $this->$tag += ($enable ? 1 : -1);
+ $style = '';
+ foreach(array('B', 'I', 'U') as $s)
+ {
+ if($this->$s>0)
+ $style .= $s;
+ }
+ $this->SetFont('',$style);
+}
+
+function PutLink($URL, $txt)
+{
+ // Put a hyperlink
+ $this->SetTextColor(0,0,255);
+ $this->SetStyle('U',true);
+ $this->Write(5,$txt,$URL);
+ $this->SetStyle('U',false);
+ $this->SetTextColor(0);
+}
+}
+
+$html = 'You can now easily print text mixing different styles: <b>bold</b>, <i>italic</i>,
+<u>underlined</u>, or <b><i><u>all at once</u></i></b>!<br><br>You can also insert links on
+text, such as <a href="http://www.fpdf.org">www.fpdf.org</a>, or on an image: click on the logo.';
+
+$pdf = new PDF();
+// First page
+$pdf->AddPage();
+$pdf->SetFont('Arial','',20);
+$pdf->Write(5,"To find out what's new in this tutorial, click ");
+$pdf->SetFont('','U');
+$link = $pdf->AddLink();
+$pdf->Write(5,'here',$link);
+$pdf->SetFont('');
+// Second page
+$pdf->AddPage();
+$pdf->SetLink($link);
+$pdf->Image('logo.png',10,12,30,0,'','http://www.fpdf.org');
+$pdf->SetLeftMargin(45);
+$pdf->SetFontSize(14);
+$pdf->WriteHTML($html);
+$pdf->Output();
+?>
diff --git a/pdf/fpdf/tutorial/tuto7.htm b/pdf/fpdf/tutorial/tuto7.htm new file mode 100755 index 0000000..b42e552 --- /dev/null +++ b/pdf/fpdf/tutorial/tuto7.htm @@ -0,0 +1,187 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Adding new fonts and encodings</title>
+<link type="text/css" rel="stylesheet" href="../fpdf.css">
+</head>
+<body>
+<h1>Adding new fonts and encodings</h1>
+This tutorial explains how to use TrueType, OpenType and Type1 fonts so that you are not limited to the
+standard fonts anymore. The other benefit is that you can choose the text encoding, which allows you to
+use other languages than the Western ones (the standard fonts support only cp1252 aka windows-1252).
+<br>
+<br>
+For OpenType, only the format based on TrueType is supported (not the one based on Type1).<br>
+For Type1, you will need the corresponding AFM file (it is usually provided with the font).
+<br>
+<br>
+Adding a new font requires two steps:
+<ul>
+<li>Generation of the font definition file</li>
+<li>Declaration of the font in the script</li>
+</ul>
+
+<h2>Generation of the font definition file</h2>
+The first step consists in generating a PHP file containing all the information needed by FPDF;
+in addition, the font file is compressed. To do this, a helper script is provided in the makefont
+directory of the package: makefont.php. It contains the following function:
+<br>
+<br>
+<code>MakeFont(<b>string</b> fontfile [, <b>string</b> enc [, <b>boolean</b> embed [, <b>boolean</b> subset]]])</code>
+<dl class="param" style="margin-bottom:2em">
+<dt><code>fontfile</code></dt>
+<dd>
+<p>Path to the .ttf, .otf or .pfb file.</p>
+</dd>
+<dt><code>enc</code></dt>
+<dd>
+<p>Name of the encoding to use. Default value: <code>cp1252</code>.</p>
+</dd>
+<dt><code>embed</code></dt>
+<dd>
+<p>Whether to embed the font or not. Default value: <code>true</code>.</p>
+</dd>
+<dt><code>subset</code></dt>
+<dd>
+<p>Whether to subset the font or not. Default value: <code>true</code>.</p>
+</dd>
+</dl>
+The first parameter is the name of the font file. The extension must be either .ttf, .otf or .pfb and
+determines the font type. If your Type1 font is in ASCII format (.pfa), you can convert it to binary
+(.pfb) with the help of <a href="http://www.lcdf.org/~eddietwo/type/#t1utils" target="_blank">t1utils</a>.
+<br>
+<br>
+For Type1 fonts, the corresponding .afm file must be present in the same directory.
+<br>
+<br>
+The encoding defines the association between a code (from 0 to 255) and a character. The first 128 are
+always the same and correspond to ASCII; the following are variable. Encodings are stored in .map
+files. The available ones are:
+<ul>
+<li>cp1250 (Central Europe)</li>
+<li>cp1251 (Cyrillic)</li>
+<li>cp1252 (Western Europe)</li>
+<li>cp1253 (Greek)</li>
+<li>cp1254 (Turkish)</li>
+<li>cp1255 (Hebrew)</li>
+<li>cp1257 (Baltic)</li>
+<li>cp1258 (Vietnamese)</li>
+<li>cp874 (Thai)</li>
+<li>ISO-8859-1 (Western Europe)</li>
+<li>ISO-8859-2 (Central Europe)</li>
+<li>ISO-8859-4 (Baltic)</li>
+<li>ISO-8859-5 (Cyrillic)</li>
+<li>ISO-8859-7 (Greek)</li>
+<li>ISO-8859-9 (Turkish)</li>
+<li>ISO-8859-11 (Thai)</li>
+<li>ISO-8859-15 (Western Europe)</li>
+<li>ISO-8859-16 (Central Europe)</li>
+<li>KOI8-R (Russian)</li>
+<li>KOI8-U (Ukrainian)</li>
+</ul>
+Of course, the font must contain the characters corresponding to the selected encoding.
+<br>
+<br>
+The third parameter indicates whether the font should be embedded in the PDF or not. When a font is
+not embedded, it is searched in the system. The advantage is that the PDF file is smaller; on the
+other hand, if it is not available, then a substitution font is used. So you should ensure that the
+needed font is installed on the client systems. Embedding is the recommended option to guarantee a
+correct rendering.
+<br>
+<br>
+The last parameter indicates whether subsetting should be used, that is to say, whether only
+the characters from the selected encoding should be kept in the embedded font. As a result,
+the size of the PDF file can be greatly reduced, especially if the original font was big.
+<br>
+<br>
+After you have called the function (create a new file for this and include makefont.php), a .php file
+is created, with the same name as the font file. You may rename it if you wish. If the case of embedding,
+the font file is compressed and gives a second file with .z as extension (except if the compression
+function is not available, it requires Zlib). You may rename it too, but in this case you have to change
+the variable <code>$file</code> in the .php file accordingly.
+<br>
+<br>
+Example:
+<div class="source">
+<pre><code><?php
+<span class="kw">require(</span><span class="str">'makefont/makefont.php'</span><span class="kw">);
+
+</span>MakeFont<span class="kw">(</span><span class="str">'C:\\Windows\\Fonts\\comic.ttf'</span><span class="kw">,</span><span class="str">'cp1252'</span><span class="kw">);
+</span>?></code></pre>
+</div>
+which gives the files comic.php and comic.z.
+<br>
+<br>
+Then copy the generated files to the font directory. If the font file could not be compressed, copy
+it directly instead of the .z version.
+<br>
+<br>
+Another way to call MakeFont() is through the command line:
+<br>
+<br>
+<kbd>php makefont\makefont.php C:\Windows\Fonts\comic.ttf cp1252</kbd>
+<br>
+<br>
+Finally, for TrueType and OpenType fonts, you can also generate the files
+<a href="http://www.fpdf.org/makefont/">online</a> instead of doing it manually.
+
+<h2>Declaration of the font in the script</h2>
+The second step is simple. You just need to call the <a href='../doc/addfont.htm'>AddFont()</a> method:
+<div class="source">
+<pre><code>$pdf<span class="kw">-></span>AddFont<span class="kw">(</span><span class="str">'Comic'</span><span class="kw">,</span><span class="str">''</span><span class="kw">,</span><span class="str">'comic.php'</span><span class="kw">);
+</span></code></pre>
+</div>
+And the font is now available (in regular and underlined styles), usable like the others. If we
+had worked with Comic Sans MS Bold (comicbd.ttf), we would have written:
+<div class="source">
+<pre><code>$pdf<span class="kw">-></span>AddFont<span class="kw">(</span><span class="str">'Comic'</span><span class="kw">,</span><span class="str">'B'</span><span class="kw">,</span><span class="str">'comicbd.php'</span><span class="kw">);
+</span></code></pre>
+</div>
+
+<h2>Example</h2>
+Let's now see a complete example. We will use the font <a href="http://www.abstractfonts.com/font/52" target="_blank">Calligrapher</a>.
+The first step is the generation of the font files:
+<div class="source">
+<pre><code><?php
+<span class="kw">require(</span><span class="str">'makefont/makefont.php'</span><span class="kw">);
+
+</span>MakeFont<span class="kw">(</span><span class="str">'calligra.ttf'</span><span class="kw">,</span><span class="str">'cp1252'</span><span class="kw">);
+</span>?></code></pre>
+</div>
+The script gives the following report:
+<br>
+<br>
+<b>Warning:</b> character Euro is missing<br>
+<b>Warning:</b> character zcaron is missing<br>
+Font file compressed: calligra.z<br>
+Font definition file generated: calligra.php<br>
+<br>
+The euro character is not present in the font (it's too old). Another character is missing too.
+<br>
+<br>
+Alternatively we could have used the command line:
+<br>
+<br>
+<kbd>php makefont\makefont.php calligra.ttf cp1252</kbd>
+<br>
+<br>
+or used the online generator.
+<br>
+<br>
+We can now copy the two generated files to the font directory and write the script:
+<div class="source">
+<pre><code><?php
+<span class="kw">require(</span><span class="str">'fpdf.php'</span><span class="kw">);
+
+</span>$pdf <span class="kw">= new </span>FPDF<span class="kw">();
+</span>$pdf<span class="kw">-></span>AddFont<span class="kw">(</span><span class="str">'Calligrapher'</span><span class="kw">,</span><span class="str">''</span><span class="kw">,</span><span class="str">'calligra.php'</span><span class="kw">);
+</span>$pdf<span class="kw">-></span>AddPage<span class="kw">();
+</span>$pdf<span class="kw">-></span>SetFont<span class="kw">(</span><span class="str">'Calligrapher'</span><span class="kw">,</span><span class="str">''</span><span class="kw">,</span>35<span class="kw">);
+</span>$pdf<span class="kw">-></span>Write<span class="kw">(</span>10<span class="kw">,</span><span class="str">'Enjoy new fonts with FPDF!'</span><span class="kw">);
+</span>$pdf<span class="kw">-></span>Output<span class="kw">();
+</span>?></code></pre>
+</div>
+<p class='demo'><a href='tuto7.php' target='_blank' class='demo'>[Demo]</a></p>
+</body>
+</html>
diff --git a/pdf/fpdf/tutorial/tuto7.php b/pdf/fpdf/tutorial/tuto7.php new file mode 100755 index 0000000..d1127f3 --- /dev/null +++ b/pdf/fpdf/tutorial/tuto7.php @@ -0,0 +1,11 @@ +<?php
+define('FPDF_FONTPATH','.');
+require('../fpdf.php');
+
+$pdf = new FPDF();
+$pdf->AddFont('Calligrapher','','calligra.php');
+$pdf->AddPage();
+$pdf->SetFont('Calligrapher','',35);
+$pdf->Cell(0,10,'Enjoy new fonts with FPDF!');
+$pdf->Output();
+?>
|