initial move to git (subversion history dropped intentionally)

This commit is contained in:
Florian Overkamp
2012-09-01 14:34:41 +02:00
commit 75f0a3d9b8
223 changed files with 23550 additions and 0 deletions

10
fpdf16/tutorial/20k_c1.txt Executable file
View File

@@ -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<61>p<EFBFBD>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.

23
fpdf16/tutorial/20k_c2.txt Executable file
View File

@@ -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!"

275
fpdf16/tutorial/calligra.afm Executable file
View File

@@ -0,0 +1,275 @@
StartFontMetrics 4.1
FontName Calligrapher-Regular
FullName Calligrapher Regular
Notice Generated by Fontographer 3.5
EncodingScheme FontSpecific
FamilyName Calligrapher
Weight Regular
Version (Altsys Fontographer 3.5 5/26/92)
Characters 215
ItalicAngle 0.0
Ascender 899
Descender -234
UnderlineThickness 20
UnderlinePosition -200
IsFixedPitch false
FontBBox -50 -234 1328 899
StartCharMetrics 256
C 0 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 1 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 2 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 3 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 4 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 5 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 6 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 7 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 8 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 9 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 10 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 11 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 12 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 13 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 14 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 15 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 16 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 17 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 18 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 19 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 20 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 21 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 22 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 23 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 24 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 25 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 26 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 27 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 28 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 29 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 30 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 31 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 32 ; WX 282 ; N space ; B 67 -16 251 718 ;
C 33 ; WX 324 ; N exclam ; B 67 -16 251 718 ;
C 34 ; WX 405 ; N quotedbl ; B 60 460 353 718 ;
C 35 ; WX 584 ; N numbersign ; B 35 0 549 701 ;
C 36 ; WX 632 ; N dollar ; B 32 -126 595 814 ;
C 37 ; WX 980 ; N percent ; B 35 -16 945 703 ;
C 38 ; WX 776 ; N ampersand ; B 41 -17 811 670 ;
C 39 ; WX 259 ; N quotesingle ; B 72 460 206 718 ;
C 40 ; WX 299 ; N parenleft ; B 57 -119 299 785 ;
C 41 ; WX 299 ; N parenright ; B 0 -119 242 785 ;
C 42 ; WX 377 ; N asterisk ; B 35 407 342 714 ;
C 43 ; WX 600 ; N plus ; B 47 0 553 506 ;
C 44 ; WX 259 ; N comma ; B 35 -67 224 162 ;
C 45 ; WX 432 ; N hyphen ; B 28 249 404 377 ;
C 46 ; WX 254 ; N period ; B 43 -16 227 162 ;
C 47 ; WX 597 ; N slash ; B 7 -14 591 714 ;
C 48 ; WX 529 ; N zero ; B 21 -18 508 583 ;
C 49 ; WX 298 ; N one ; B 8 -15 233 582 ;
C 50 ; WX 451 ; N two ; B 17 -8 430 588 ;
C 51 ; WX 359 ; N three ; B 11 -54 337 582 ;
C 52 ; WX 525 ; N four ; B 18 -20 519 602 ;
C 53 ; WX 423 ; N five ; B 10 -55 420 582 ;
C 54 ; WX 464 ; N six ; B 23 -14 447 589 ;
C 55 ; WX 417 ; N seven ; B 8 -18 415 589 ;
C 56 ; WX 457 ; N eight ; B 19 -16 432 583 ;
C 57 ; WX 479 ; N nine ; B 26 -16 450 588 ;
C 58 ; WX 275 ; N colon ; B 59 -16 242 491 ;
C 59 ; WX 282 ; N semicolon ; B 54 -67 245 491 ;
C 60 ; WX 600 ; N less ; B 47 -8 553 514 ;
C 61 ; WX 600 ; N equal ; B 47 98 553 408 ;
C 62 ; WX 600 ; N greater ; B 47 -8 553 514 ;
C 63 ; WX 501 ; N question ; B 21 -16 473 721 ;
C 64 ; WX 800 ; N at ; B 29 -12 771 730 ;
C 65 ; WX 743 ; N A ; B -23 -14 754 723 ;
C 66 ; WX 636 ; N B ; B -42 -7 608 706 ;
C 67 ; WX 598 ; N C ; B 27 -12 572 712 ;
C 68 ; WX 712 ; N D ; B -42 -11 684 705 ;
C 69 ; WX 608 ; N E ; B -21 0 608 708 ;
C 70 ; WX 562 ; N F ; B -21 -18 584 716 ;
C 71 ; WX 680 ; N G ; B 29 -8 668 714 ;
C 72 ; WX 756 ; N H ; B 70 -17 777 728 ;
C 73 ; WX 308 ; N I ; B 14 -15 238 718 ;
C 74 ; WX 314 ; N J ; B 7 -223 244 727 ;
C 75 ; WX 676 ; N K ; B 14 -16 683 725 ;
C 76 ; WX 552 ; N L ; B 14 -8 580 713 ;
C 77 ; WX 1041 ; N M ; B 42 -17 1017 739 ;
C 78 ; WX 817 ; N N ; B -42 -17 747 736 ;
C 79 ; WX 729 ; N O ; B 32 -16 698 709 ;
C 80 ; WX 569 ; N P ; B -35 -15 570 716 ;
C 81 ; WX 698 ; N Q ; B 27 -201 1328 715 ;
C 82 ; WX 674 ; N R ; B -35 -20 696 712 ;
C 83 ; WX 618 ; N S ; B 31 -16 589 709 ;
C 84 ; WX 673 ; N T ; B -21 -20 702 714 ;
C 85 ; WX 805 ; N U ; B 0 -19 804 722 ;
C 86 ; WX 753 ; N V ; B -28 -20 788 729 ;
C 87 ; WX 1238 ; N W ; B -28 -17 1273 736 ;
C 88 ; WX 716 ; N X ; B 7 -38 709 731 ;
C 89 ; WX 754 ; N Y ; B -35 -17 789 747 ;
C 90 ; WX 599 ; N Z ; B 30 -5 584 748 ;
C 91 ; WX 315 ; N bracketleft ; B 93 -124 322 718 ;
C 92 ; WX 463 ; N backslash ; B -21 -18 484 736 ;
C 93 ; WX 315 ; N bracketright ; B -7 -124 222 718 ;
C 94 ; WX 600 ; N asciicircum ; B 63 266 537 658 ;
C 95 ; WX 547 ; N underscore ; B -7 -198 554 -163 ;
C 96 ; WX 278 ; N grave ; B -1 541 214 693 ;
C 97 ; WX 581 ; N a ; B 21 -16 581 494 ;
C 98 ; WX 564 ; N b ; B -24 -17 543 793 ;
C 99 ; WX 440 ; N c ; B 21 -17 422 490 ;
C 100 ; WX 571 ; N d ; B 0 -15 550 659 ;
C 101 ; WX 450 ; N e ; B 28 -23 428 493 ;
C 102 ; WX 347 ; N f ; B -35 -14 474 785 ;
C 103 ; WX 628 ; N g ; B 19 -219 612 496 ;
C 104 ; WX 611 ; N h ; B -29 -18 569 785 ;
C 105 ; WX 283 ; N i ; B -14 -15 241 679 ;
C 106 ; WX 283 ; N j ; B -14 -234 241 679 ;
C 107 ; WX 560 ; N k ; B -24 -15 582 789 ;
C 108 ; WX 252 ; N l ; B -28 -15 210 789 ;
C 109 ; WX 976 ; N m ; B -21 -16 927 494 ;
C 110 ; WX 595 ; N n ; B -28 -15 574 493 ;
C 111 ; WX 508 ; N o ; B 27 -17 485 490 ;
C 112 ; WX 549 ; N p ; B -28 -216 526 496 ;
C 113 ; WX 540 ; N q ; B 28 -219 491 493 ;
C 114 ; WX 395 ; N r ; B -21 -19 430 492 ;
C 115 ; WX 441 ; N s ; B 34 -15 413 493 ;
C 116 ; WX 307 ; N t ; B -21 -16 378 621 ;
C 117 ; WX 614 ; N u ; B -14 -18 558 501 ;
C 118 ; WX 556 ; N v ; B -28 -20 569 483 ;
C 119 ; WX 915 ; N w ; B -28 -17 928 495 ;
C 120 ; WX 559 ; N x ; B 14 -17 546 500 ;
C 121 ; WX 597 ; N y ; B -21 -227 541 500 ;
C 122 ; WX 452 ; N z ; B 28 -5 442 515 ;
C 123 ; WX 315 ; N braceleft ; B 6 -118 309 718 ;
C 124 ; WX 222 ; N bar ; B 63 -18 159 730 ;
C 125 ; WX 315 ; N braceright ; B 6 -118 309 718 ;
C 126 ; WX 600 ; N asciitilde ; B 69 166 531 340 ;
C 127 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 128 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 129 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 130 ; WX 0 ; N quotesinglbase ; B -23 -14 754 877 ;
C 131 ; WX 0 ; N florin ; B 0 -19 804 854 ;
C 132 ; WX 0 ; N quotedblbase ; B -23 -14 754 877 ;
C 133 ; WX 780 ; N ellipsis ; B 43 -16 747 162 ;
C 134 ; WX 0 ; N dagger ; B 27 -122 437 592 ;
C 135 ; WX 0 ; N daggerdbl ; B 43 278 227 456 ;
C 136 ; WX 278 ; N circumflex ; B -14 557 292 677 ;
C 137 ; WX 0 ; N perthousand ; B -23 -14 754 877 ;
C 138 ; WX 0 ; N Scaron ; B 0 0 0 100 ;
C 139 ; WX 0 ; N guilsinglleft ; B 43 278 227 456 ;
C 140 ; WX 1064 ; N OE ; B 32 -16 1055 709 ;
C 141 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 142 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 143 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 144 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 145 ; WX 259 ; N quoteleft ; B 35 489 224 717 ;
C 146 ; WX 259 ; N quoteright ; B 35 489 224 717 ;
C 147 ; WX 470 ; N quotedblleft ; B 35 489 443 717 ;
C 148 ; WX 470 ; N quotedblright ; B 35 487 443 717 ;
C 149 ; WX 500 ; N bullet ; B 70 179 430 539 ;
C 150 ; WX 300 ; N endash ; B 0 245 300 350 ;
C 151 ; WX 600 ; N emdash ; B 0 245 600 350 ;
C 152 ; WX 278 ; N tilde ; B -44 563 326 689 ;
C 153 ; WX 990 ; N trademark ; B 62 306 928 718 ;
C 154 ; WX 0 ; N scaron ; B 0 0 0 100 ;
C 155 ; WX 0 ; N guilsinglright ; B 43 278 227 456 ;
C 156 ; WX 790 ; N oe ; B 27 -23 764 493 ;
C 157 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 158 ; WX 800 ; N .notdef ; B 50 0 750 800 ;
C 159 ; WX 754 ; N Ydieresis ; B -35 -17 789 882 ;
C 160 ; WX 282 ; N nbspace ; B -23 -14 754 893 ;
C 161 ; WX 324 ; N exclamdown ; B 69 -203 253 531 ;
C 162 ; WX 450 ; N cent ; B 27 -122 437 592 ;
C 163 ; WX 640 ; N sterling ; B 0 -9 619 716 ;
C 164 ; WX 518 ; N currency ; B 3 72 515 586 ;
C 165 ; WX 603 ; N yen ; B -28 -65 631 747 ;
C 166 ; WX 0 ; N brokenbar ; B 0 0 0 100 ;
C 167 ; WX 519 ; N section ; B -50 -216 524 762 ;
C 168 ; WX 254 ; N dieresis ; B -20 554 308 682 ;
C 169 ; WX 800 ; N copyright ; B 29 -12 771 730 ;
C 170 ; WX 349 ; N ordfeminine ; B 13 385 349 717 ;
C 171 ; WX 0 ; N guillemotleft ; B 43 -16 747 162 ;
C 172 ; WX 0 ; N logicalnot ; B 30 0 730 700 ;
C 173 ; WX 432 ; N hyphen ; B 28 249 404 377 ;
C 174 ; WX 800 ; N registered ; B 29 -12 771 730 ;
C 175 ; WX 278 ; N macron ; B -47 584 325 665 ;
C 176 ; WX 0 ; N degree ; B 27 -122 437 592 ;
C 177 ; WX 0 ; N plusminus ; B 29 -8 668 877 ;
C 178 ; WX 0 ; N twosuperior ; B 0 0 0 100 ;
C 179 ; WX 0 ; N threesuperior ; B 0 0 0 100 ;
C 180 ; WX 278 ; N acute ; B 49 536 279 693 ;
C 181 ; WX 614 ; N mu ; B -14 -231 558 501 ;
C 182 ; WX 0 ; N paragraph ; B -35 -15 668 785 ;
C 183 ; WX 254 ; N periodcentered ; B 43 278 227 456 ;
C 184 ; WX 278 ; N cedilla ; B -8 -216 231 6 ;
C 185 ; WX 0 ; N onesuperior ; B 0 0 0 100 ;
C 186 ; WX 305 ; N ordmasculine ; B 16 373 291 702 ;
C 187 ; WX 0 ; N guillemotright ; B 43 -16 747 162 ;
C 188 ; WX 0 ; N onequarter ; B 0 0 0 100 ;
C 189 ; WX 0 ; N onehalf ; B 0 0 0 100 ;
C 190 ; WX 0 ; N threequarters ; B 0 0 0 100 ;
C 191 ; WX 501 ; N questiondown ; B 15 -196 467 541 ;
C 192 ; WX 743 ; N Agrave ; B -23 -14 754 893 ;
C 193 ; WX 743 ; N Aacute ; B -23 -14 754 893 ;
C 194 ; WX 743 ; N Acircumflex ; B -23 -14 754 877 ;
C 195 ; WX 743 ; N Atilde ; B -23 -14 754 889 ;
C 196 ; WX 743 ; N Adieresis ; B -23 -14 754 882 ;
C 197 ; WX 743 ; N Aring ; B -23 -14 754 899 ;
C 198 ; WX 1060 ; N AE ; B -29 -14 1053 708 ;
C 199 ; WX 598 ; N Ccedilla ; B 27 -183 572 712 ;
C 200 ; WX 608 ; N Egrave ; B -21 0 608 893 ;
C 201 ; WX 608 ; N Eacute ; B -21 0 608 893 ;
C 202 ; WX 608 ; N Ecircumflex ; B -21 0 608 877 ;
C 203 ; WX 608 ; N Edieresis ; B -21 0 608 882 ;
C 204 ; WX 308 ; N Igrave ; B 14 -15 264 893 ;
C 205 ; WX 308 ; N Iacute ; B 14 -15 274 893 ;
C 206 ; WX 308 ; N Icircumflex ; B 1 -15 307 877 ;
C 207 ; WX 308 ; N Idieresis ; B -15 -15 313 882 ;
C 208 ; WX 0 ; N Eth ; B 0 0 0 100 ;
C 209 ; WX 817 ; N Ntilde ; B -42 -17 747 889 ;
C 210 ; WX 729 ; N Ograve ; B 32 -16 698 893 ;
C 211 ; WX 729 ; N Oacute ; B 32 -16 698 893 ;
C 212 ; WX 729 ; N Ocircumflex ; B 32 -16 698 877 ;
C 213 ; WX 729 ; N Otilde ; B 32 -16 698 889 ;
C 214 ; WX 729 ; N Odieresis ; B 32 -16 698 882 ;
C 215 ; WX 0 ; N multiply ; B 0 0 0 100 ;
C 216 ; WX 729 ; N Oslash ; B 14 -24 724 709 ;
C 217 ; WX 805 ; N Ugrave ; B 0 -19 804 893 ;
C 218 ; WX 805 ; N Uacute ; B 0 -19 804 893 ;
C 219 ; WX 805 ; N Ucircumflex ; B 0 -19 804 877 ;
C 220 ; WX 805 ; N Udieresis ; B 0 -19 804 882 ;
C 221 ; WX 0 ; N _235 ; B 0 0 0 100 ;
C 222 ; WX 0 ; N Thorn ; B 0 0 0 100 ;
C 223 ; WX 688 ; N germandbls ; B -35 -15 668 785 ;
C 224 ; WX 581 ; N agrave ; B 21 -16 581 693 ;
C 225 ; WX 581 ; N aacute ; B 21 -16 581 693 ;
C 226 ; WX 581 ; N acircumflex ; B 21 -16 581 677 ;
C 227 ; WX 581 ; N atilde ; B 21 -16 581 689 ;
C 228 ; WX 581 ; N adieresis ; B 21 -16 581 682 ;
C 229 ; WX 581 ; N aring ; B 21 -16 581 734 ;
C 230 ; WX 792 ; N ae ; B 21 -23 773 494 ;
C 231 ; WX 440 ; N ccedilla ; B 21 -183 422 490 ;
C 232 ; WX 450 ; N egrave ; B 28 -23 428 693 ;
C 233 ; WX 450 ; N eacute ; B 28 -23 428 693 ;
C 234 ; WX 450 ; N ecircumflex ; B 28 -23 432 677 ;
C 235 ; WX 450 ; N edieresis ; B 28 -23 428 682 ;
C 236 ; WX 283 ; N igrave ; B -14 -15 244 693 ;
C 237 ; WX 283 ; N iacute ; B -14 -15 269 693 ;
C 238 ; WX 283 ; N icircumflex ; B -14 -15 297 677 ;
C 239 ; WX 283 ; N idieresis ; B -25 -15 303 682 ;
C 240 ; WX 0 ; N Yacute ; B 0 0 0 100 ;
C 241 ; WX 595 ; N ntilde ; B -28 -15 574 689 ;
C 242 ; WX 508 ; N ograve ; B 27 -17 485 693 ;
C 243 ; WX 508 ; N oacute ; B 27 -17 485 693 ;
C 244 ; WX 508 ; N ocircumflex ; B 27 -17 485 677 ;
C 245 ; WX 508 ; N otilde ; B 27 -17 485 689 ;
C 246 ; WX 508 ; N odieresis ; B 27 -17 485 682 ;
C 247 ; WX 0 ; N divide ; B 35 0 760 727 ;
C 248 ; WX 508 ; N oslash ; B -8 -54 496 589 ;
C 249 ; WX 614 ; N ugrave ; B -14 -18 558 693 ;
C 250 ; WX 614 ; N uacute ; B -14 -18 558 693 ;
C 251 ; WX 614 ; N ucircumflex ; B -14 -18 558 677 ;
C 252 ; WX 614 ; N udieresis ; B -14 -18 558 682 ;
C 253 ; WX 0 ; N yacute ; B 0 0 0 100 ;
C 254 ; WX 0 ; N thorn ; B 0 0 0 100 ;
C 255 ; WX 597 ; N ydieresis ; B -21 -227 541 682 ;
EndCharMetrics
EndFontMetrics

24
fpdf16/tutorial/calligra.php Executable file
View File

@@ -0,0 +1,24 @@
<?php
$type='TrueType';
$name='Calligrapher-Regular';
$desc=array('Ascent'=>899,'Descent'=>-234,'CapHeight'=>731,'Flags'=>32,'FontBBox'=>'[-50 -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)=>800,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)=>800,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';
$diff='';
$file='calligra.z';
$originalsize=40120;
?>

BIN
fpdf16/tutorial/calligra.ttf Executable file

Binary file not shown.

BIN
fpdf16/tutorial/calligra.z Executable file

Binary file not shown.

15
fpdf16/tutorial/countries.txt Executable file
View File

@@ -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

21
fpdf16/tutorial/index.htm Executable file
View File

@@ -0,0 +1,21 @@
<!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>
<p>The different examples rapidly show how to use FPDF. You will find all main features explained.</p>
<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 encoding support</li>
</UL>
</body>
</html>

BIN
fpdf16/tutorial/logo.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
fpdf16/tutorial/logo_pb.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

6
fpdf16/tutorial/makefont.php Executable file
View File

@@ -0,0 +1,6 @@
<?php
//Generation of font definition file for tutorial 7
require('../font/makefont/makefont.php');
MakeFont('calligra.ttf','calligra.afm');
?>

77
fpdf16/tutorial/tuto1.htm Executable file
View File

@@ -0,0 +1,77 @@
<!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>&lt;?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">-&gt;</span>AddPage<span class="kw">();
</span>$pdf<span class="kw">-&gt;</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">-&gt;</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">-&gt;</span>Output<span class="kw">();
</span>?&gt;</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/fpdf.htm'>FPDF()</a> constructor 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 is possible to use landscape (<code>L</code>), other page formats (such as <code>Letter</code> and
<code>Legal</code>) and units of measure (<code>pt</code>, <code>cm</code>, <code>in</code>).
<br>
<br>
There is no page for 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 placed 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 is mandatory to select a font with <a href='../doc/setfont.htm'>SetFont()</a>, otherwise the
document would be invalid. We choose Arial bold 16:
<div class="source">
<pre><code>$pdf<span class="kw">-&gt;</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 is 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">-&gt;</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">-&gt;</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 desired file name.
<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>

9
fpdf16/tutorial/tuto1.php Executable file
View File

@@ -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();
?>

80
fpdf16/tutorial/tuto2.htm Executable file
View File

@@ -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 is a two page example with header, footer and logo:
<div class="source">
<pre><code>&lt;?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-&gt;</span>Image<span class="kw">(</span><span class="str">'logo_pb.png'</span><span class="kw">,</span>10<span class="kw">,</span>8<span class="kw">,</span>33<span class="kw">);
</span><span class="cmt">//Arial bold 15
</span>$<span class="kw">this-&gt;</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-&gt;</span>Cell<span class="kw">(</span>80<span class="kw">);
</span><span class="cmt">//Title
</span>$<span class="kw">this-&gt;</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-&gt;</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-&gt;</span>SetY<span class="kw">(-</span>15<span class="kw">);
</span><span class="cmt">//Arial italic 8
</span>$<span class="kw">this-&gt;</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-&gt;</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-&gt;</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">-&gt;</span>AliasNbPages<span class="kw">();
</span>$pdf<span class="kw">-&gt;</span>AddPage<span class="kw">();
</span>$pdf<span class="kw">-&gt;</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">&lt;=</span>40<span class="kw">;</span>$i<span class="kw">++)
</span>$pdf<span class="kw">-&gt;</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">-&gt;</span>Output<span class="kw">();
</span>?&gt;</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; it 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 is obtained
by means of the special value <code>{nb}</code> which will be substituted on document closure
(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 performed
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>

41
fpdf16/tutorial/tuto2.php Executable file
View File

@@ -0,0 +1,41 @@
<?php
require('../fpdf.php');
class PDF extends FPDF
{
//Page header
function Header()
{
//Logo
$this->Image('logo_pb.png',10,8,33);
//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();
?>

116
fpdf16/tutorial/tuto3.htm Executable file
View File

@@ -0,0 +1,116 @@
<!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>&lt;?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-&gt;</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-&gt;</span>GetStringWidth<span class="kw">(</span>$title<span class="kw">)+</span>6<span class="kw">;
</span>$<span class="kw">this-&gt;</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-&gt;</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-&gt;</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-&gt;</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-&gt;</span>SetLineWidth<span class="kw">(</span>1<span class="kw">);
</span><span class="cmt">//Title
</span>$<span class="kw">this-&gt;</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-&gt;</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-&gt;</span>SetY<span class="kw">(-</span>15<span class="kw">);
</span><span class="cmt">//Arial italic 8
</span>$<span class="kw">this-&gt;</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-&gt;</span>SetTextColor<span class="kw">(</span>128<span class="kw">);
</span><span class="cmt">//Page number
</span>$<span class="kw">this-&gt;</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-&gt;</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-&gt;</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-&gt;</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-&gt;</span>Cell<span class="kw">(</span>0<span class="kw">,</span>6<span class="kw">,</span><span class="str">"Chapter $num : $label"</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-&gt;</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>$f<span class="kw">=</span>fopen<span class="kw">(</span>$file<span class="kw">,</span><span class="str">'r'</span><span class="kw">);
</span>$txt<span class="kw">=</span>fread<span class="kw">(</span>$f<span class="kw">,</span>filesize<span class="kw">(</span>$file<span class="kw">));
</span>fclose<span class="kw">(</span>$f<span class="kw">);
</span><span class="cmt">//Times 12
</span>$<span class="kw">this-&gt;</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-&gt;</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-&gt;</span>Ln<span class="kw">();
</span><span class="cmt">//Mention in italics
</span>$<span class="kw">this-&gt;</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-&gt;</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-&gt;</span>AddPage<span class="kw">();
</span>$<span class="kw">this-&gt;</span>ChapterTitle<span class="kw">(</span>$num<span class="kw">,</span>$title<span class="kw">);
</span>$<span class="kw">this-&gt;</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">-&gt;</span>SetTitle<span class="kw">(</span>$title<span class="kw">);
</span>$pdf<span class="kw">-&gt;</span>SetAuthor<span class="kw">(</span><span class="str">'Jules Verne'</span><span class="kw">);
</span>$pdf<span class="kw">-&gt;</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">-&gt;</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">-&gt;</span>Output<span class="kw">();
</span>?&gt;</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 (against 0.2 by default) with <a href='../doc/setlinewidth.htm'>SetLineWidth()</a>. Finally,
we output the cell (the last parameter to <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>).
Properties can be viewed by two means. First is to open the document directly with Acrobat Reader,
go to the File menu and choose the Document Properties option. The second, also available from
the plug-in, is to right-click and select Document Properties.
</body>
</html>

83
fpdf16/tutorial/tuto3.php Executable file
View File

@@ -0,0 +1,83 @@
<?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
$f=fopen($file,'r');
$txt=fread($f,filesize($file));
fclose($f);
//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();
?>

136
fpdf16/tutorial/tuto4.htm Executable file
View File

@@ -0,0 +1,136 @@
<!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>&lt;?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">//Current column
</span><span class="kw">var </span>$col<span class="kw">=</span>0<span class="kw">;
</span><span class="cmt">//Ordinate of column start
</span><span class="kw">var </span>$y0<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-&gt;</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-&gt;</span>GetStringWidth<span class="kw">(</span>$title<span class="kw">)+</span>6<span class="kw">;
</span>$<span class="kw">this-&gt;</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-&gt;</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-&gt;</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-&gt;</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-&gt;</span>SetLineWidth<span class="kw">(</span>1<span class="kw">);
</span>$<span class="kw">this-&gt;</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-&gt;</span>Ln<span class="kw">(</span>10<span class="kw">);
</span><span class="cmt">//Save ordinate
</span>$<span class="kw">this-&gt;</span>y0<span class="kw">=</span>$<span class="kw">this-&gt;</span>GetY<span class="kw">();
}
function </span>Footer<span class="kw">()
{
</span><span class="cmt">//Page footer
</span>$<span class="kw">this-&gt;</span>SetY<span class="kw">(-</span>15<span class="kw">);
</span>$<span class="kw">this-&gt;</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-&gt;</span>SetTextColor<span class="kw">(</span>128<span class="kw">);
</span>$<span class="kw">this-&gt;</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-&gt;</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-&gt;</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-&gt;</span>SetLeftMargin<span class="kw">(</span>$x<span class="kw">);
</span>$<span class="kw">this-&gt;</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-&gt;</span>col<span class="kw">&lt;</span>2<span class="kw">)
{
</span><span class="cmt">//Go to next column
</span>$<span class="kw">this-&gt;</span>SetCol<span class="kw">(</span>$<span class="kw">this-&gt;</span>col<span class="kw">+</span>1<span class="kw">);
</span><span class="cmt">//Set ordinate to top
</span>$<span class="kw">this-&gt;</span>SetY<span class="kw">(</span>$<span class="kw">this-&gt;</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-&gt;</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-&gt;</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-&gt;</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-&gt;</span>Cell<span class="kw">(</span>0<span class="kw">,</span>6<span class="kw">,</span><span class="str">"Chapter $num : $label"</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-&gt;</span>Ln<span class="kw">(</span>4<span class="kw">);
</span><span class="cmt">//Save ordinate
</span>$<span class="kw">this-&gt;</span>y0<span class="kw">=</span>$<span class="kw">this-&gt;</span>GetY<span class="kw">();
}
function </span>ChapterBody<span class="kw">(</span>$file<span class="kw">)
{
</span><span class="cmt">//Read text file
</span>$f<span class="kw">=</span>fopen<span class="kw">(</span>$file<span class="kw">,</span><span class="str">'r'</span><span class="kw">);
</span>$txt<span class="kw">=</span>fread<span class="kw">(</span>$f<span class="kw">,</span>filesize<span class="kw">(</span>$file<span class="kw">));
</span>fclose<span class="kw">(</span>$f<span class="kw">);
</span><span class="cmt">//Font
</span>$<span class="kw">this-&gt;</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-&gt;</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-&gt;</span>Ln<span class="kw">();
</span><span class="cmt">//Mention
</span>$<span class="kw">this-&gt;</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-&gt;</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-&gt;</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-&gt;</span>AddPage<span class="kw">();
</span>$<span class="kw">this-&gt;</span>ChapterTitle<span class="kw">(</span>$num<span class="kw">,</span>$title<span class="kw">);
</span>$<span class="kw">this-&gt;</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">-&gt;</span>SetTitle<span class="kw">(</span>$title<span class="kw">);
</span>$pdf<span class="kw">-&gt;</span>SetAuthor<span class="kw">(</span><span class="str">'Jules Verne'</span><span class="kw">);
</span>$pdf<span class="kw">-&gt;</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">-&gt;</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">-&gt;</span>Output<span class="kw">();
</span>?&gt;</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>

113
fpdf16/tutorial/tuto4.php Executable file
View File

@@ -0,0 +1,113 @@
<?php
require('../fpdf.php');
class PDF extends FPDF
{
//Current column
var $col=0;
//Ordinate of column start
var $y0;
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
$f=fopen($file,'r');
$txt=fread($f,filesize($file));
fclose($f);
//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();
?>

133
fpdf16/tutorial/tuto5.htm Executable file
View File

@@ -0,0 +1,133 @@
<!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 how to make tables easily.
<div class="source">
<pre><code>&lt;?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>chop<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-&gt;</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-&gt;</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-&gt;</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-&gt;</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">&lt;</span>count<span class="kw">(</span>$header<span class="kw">);</span>$i<span class="kw">++)
</span>$<span class="kw">this-&gt;</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-&gt;</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-&gt;</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-&gt;</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-&gt;</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-&gt;</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-&gt;</span>Ln<span class="kw">();
}
</span><span class="cmt">//Closure line
</span>$<span class="kw">this-&gt;</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-&gt;</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-&gt;</span>SetTextColor<span class="kw">(</span>255<span class="kw">);
</span>$<span class="kw">this-&gt;</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-&gt;</span>SetLineWidth<span class="kw">(</span>.3<span class="kw">);
</span>$<span class="kw">this-&gt;</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">&lt;</span>count<span class="kw">(</span>$header<span class="kw">);</span>$i<span class="kw">++)
</span>$<span class="kw">this-&gt;</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-&gt;</span>Ln<span class="kw">();
</span><span class="cmt">//Color and font restoration
</span>$<span class="kw">this-&gt;</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-&gt;</span>SetTextColor<span class="kw">(</span>0<span class="kw">);
</span>$<span class="kw">this-&gt;</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-&gt;</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-&gt;</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-&gt;</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-&gt;</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-&gt;</span>Ln<span class="kw">();
</span>$fill<span class="kw">=!</span>$fill<span class="kw">;
}
</span>$<span class="kw">this-&gt;</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 titles
</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">-&gt;</span>LoadData<span class="kw">(</span><span class="str">'countries.txt'</span><span class="kw">);
</span>$pdf<span class="kw">-&gt;</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">-&gt;</span>AddPage<span class="kw">();
</span>$pdf<span class="kw">-&gt;</span>BasicTable<span class="kw">(</span>$header<span class="kw">,</span>$data<span class="kw">);
</span>$pdf<span class="kw">-&gt;</span>AddPage<span class="kw">();
</span>$pdf<span class="kw">-&gt;</span>ImprovedTable<span class="kw">(</span>$header<span class="kw">,</span>$data<span class="kw">);
</span>$pdf<span class="kw">-&gt;</span>AddPage<span class="kw">();
</span>$pdf<span class="kw">-&gt;</span>FancyTable<span class="kw">(</span>$header<span class="kw">,</span>$data<span class="kw">);
</span>$pdf<span class="kw">-&gt;</span>Output<span class="kw">();
</span>?&gt;</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 is 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, titles are centered
and figures 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>

101
fpdf16/tutorial/tuto5.php Executable file
View File

@@ -0,0 +1,101 @@
<?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(';',chop($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();
}
//Closure 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;
}
$this->Cell(array_sum($w),0,'','T');
}
}
$pdf=new PDF();
//Column titles
$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();
?>

163
fpdf16/tutorial/tuto6.htm Executable file
View File

@@ -0,0 +1,163 @@
<!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>&lt;?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">{
var </span>$B<span class="kw">;
var </span>$I<span class="kw">;
var </span>$U<span class="kw">;
var </span>$HREF<span class="kw">;
function </span>PDF<span class="kw">(</span>$orientation<span class="kw">=</span><span class="str">'P'</span><span class="kw">,</span>$unit<span class="kw">=</span><span class="str">'mm'</span><span class="kw">,</span>$format<span class="kw">=</span><span class="str">'A4'</span><span class="kw">)
{
</span><span class="cmt">//Call parent constructor
</span>$<span class="kw">this-&gt;</span>FPDF<span class="kw">(</span>$orientation<span class="kw">,</span>$unit<span class="kw">,</span>$format<span class="kw">);
</span><span class="cmt">//Initialization
</span>$<span class="kw">this-&gt;</span>B<span class="kw">=</span>0<span class="kw">;
</span>$<span class="kw">this-&gt;</span>I<span class="kw">=</span>0<span class="kw">;
</span>$<span class="kw">this-&gt;</span>U<span class="kw">=</span>0<span class="kw">;
</span>$<span class="kw">this-&gt;</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">'/&lt;(.*)&gt;/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">=&gt;</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-&gt;</span>HREF<span class="kw">)
</span>$<span class="kw">this-&gt;</span>PutLink<span class="kw">(</span>$<span class="kw">this-&gt;</span>HREF<span class="kw">,</span>$e<span class="kw">);
else
</span>$<span class="kw">this-&gt;</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-&gt;</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-&gt;</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">or </span>$tag<span class="kw">==</span><span class="str">'I' </span><span class="kw">or </span>$tag<span class="kw">==</span><span class="str">'U'</span><span class="kw">)
</span>$<span class="kw">this-&gt;</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-&gt;</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-&gt;</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">or </span>$tag<span class="kw">==</span><span class="str">'I' </span><span class="kw">or </span>$tag<span class="kw">==</span><span class="str">'U'</span><span class="kw">)
</span>$<span class="kw">this-&gt;</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-&gt;</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-&gt;</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-&gt;</span>$s<span class="kw">&gt;</span>0<span class="kw">)
</span>$style<span class="kw">.=</span>$s<span class="kw">;
</span>$<span class="kw">this-&gt;</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-&gt;</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-&gt;</span>SetStyle<span class="kw">(</span><span class="str">'U'</span><span class="kw">,</span>true<span class="kw">);
</span>$<span class="kw">this-&gt;</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-&gt;</span>SetStyle<span class="kw">(</span><span class="str">'U'</span><span class="kw">,</span>false<span class="kw">);
</span>$<span class="kw">this-&gt;</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: &lt;b&gt;bold&lt;/b&gt;, &lt;i&gt;italic&lt;/i&gt;,
&lt;u&gt;underlined&lt;/u&gt;, or &lt;b&gt;&lt;i&gt;&lt;u&gt;all at once&lt;/u&gt;&lt;/i&gt;&lt;/b&gt;!&lt;br&gt;&lt;br&gt;You can also insert links on
text, such as &lt;a href="http://www.fpdf.org"&gt;www.fpdf.org&lt;/a&gt;, 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">-&gt;</span>AddPage<span class="kw">();
</span>$pdf<span class="kw">-&gt;</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">-&gt;</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">-&gt;</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">-&gt;</span>AddLink<span class="kw">();
</span>$pdf<span class="kw">-&gt;</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">-&gt;</span>SetFont<span class="kw">(</span><span class="str">''</span><span class="kw">);
</span><span class="cmt">//Second page
</span>$pdf<span class="kw">-&gt;</span>AddPage<span class="kw">();
</span>$pdf<span class="kw">-&gt;</span>SetLink<span class="kw">(</span>$link<span class="kw">);
</span>$pdf<span class="kw">-&gt;</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">-&gt;</span>SetLeftMargin<span class="kw">(</span>45<span class="kw">);
</span>$pdf<span class="kw">-&gt;</span>SetFontSize<span class="kw">(</span>14<span class="kw">);
</span>$pdf<span class="kw">-&gt;</span>WriteHTML<span class="kw">(</span>$html<span class="kw">);
</span>$pdf<span class="kw">-&gt;</span>Output<span class="kw">();
</span>?&gt;</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 is 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 a link on it. An external link points to an URL (HTTP, mailto...).
The URL is simply 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 &lt;b&gt;, &lt;i&gt;, &lt;u&gt;, &lt;a&gt; and &lt;br&gt;; 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>

122
fpdf16/tutorial/tuto6.php Executable file
View File

@@ -0,0 +1,122 @@
<?php
require('../fpdf.php');
class PDF extends FPDF
{
var $B;
var $I;
var $U;
var $HREF;
function PDF($orientation='P',$unit='mm',$format='A4')
{
//Call parent constructor
$this->FPDF($orientation,$unit,$format);
//Initialization
$this->B=0;
$this->I=0;
$this->U=0;
$this->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' or $tag=='I' or $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' or $tag=='I' or $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();
?>

303
fpdf16/tutorial/tuto7.htm Executable file
View File

@@ -0,0 +1,303 @@
<!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 encoding support</title>
<link type="text/css" rel="stylesheet" href="../fpdf.css">
<style type="text/css">
table {border-collapse:collapse; border-style:solid; border-width:2px; border-color:#A0A0A0 #000000 #000000 #A0A0A0}
table {margin:1.4em 0 1.4em 1em}
th {background-color:#E0EBFF; color:#900000; text-align:left}
th, td {border:1px solid #808080; padding:2px 10px}
tr.alt0 {background-color:#FFFFEE}
tr.alt1 {background-color:#FFFFE0}
</style>
</head>
<body>
<h1>Adding new fonts and encoding support</h1>
This tutorial explains how to use TrueType or Type1 fonts so that you are not limited to the standard
fonts any more. The other interest is that you can choose the font encoding, which allows you to
use other languages than the Western ones (the standard fonts having too few available characters).
<br>
<br>
There are two ways to use a new font: embedding it 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 lighter; on the other
hand, if it is not available, a substitution font is used. So it is preferable to ensure that the
needed font is installed on the client systems. If the file is to be viewed by a large audience,
it is recommended to embed.
<br>
<br>
Adding a new font requires three steps for TrueTypes:
<ul>
<li>Generation of the metric file (.afm)</li>
<li>Generation of the font definition file (.php)</li>
<li>Declaration of the font in the script</li>
</ul>
For Type1, the first one is theoretically not necessary because the AFM file is usually shipped
with the font. In case you have only a metric file in PFM format, use the convertor available
<a href="http://www.fpdf.org/fr/dl.php?id=34">here</a>.
<h2>Generation of the metric file</h2>
The first step for a TrueType consists in generating the AFM file. A utility exists to do this
task: <a href="http://ttf2pt1.sourceforge.net" target="_blank">ttf2pt1</a>. The Windows binary
is available <a href="http://www.fpdf.org/fr/dl.php?id=22">here</a>. The command line to use is
the following:
<br>
<br>
<kbd>ttf2pt1 -a font.ttf font</kbd>
<br>
<br>
For example, for Comic Sans MS Regular:
<br>
<br>
<kbd>ttf2pt1 -a c:\windows\fonts\comic.ttf comic</kbd>
<br>
<br>
Two files are created; the one we are interested in is comic.afm.
<h2>Generation of the font definition file</h2>
The second 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 font/makefont/
directory of the package: makefont.php. It contains the following function:
<br>
<br>
<code>MakeFont(<b>string</b> fontfile, <b>string</b> afmfile [, <b>string</b> enc [, <b>array</b> patch [, <b>string</b> type]]])</code>
<dl class="param" style="margin-bottom:2em">
<dt><code>fontfile</code></dt>
<dd>
<p>Path to the .ttf or .pfb file.</p>
</dd>
<dt><code>afmfile</code></dt>
<dd>
<p>Path to the .afm 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>patch</code></dt>
<dd>
<p>Optional modification of the encoding. Empty by default.</p>
</dd>
<dt><code>type</code></dt>
<dd>
<p>Type of the font (<code>TrueType</code> or <code>Type1</code>). Default value: <code>TrueType</code>.</p>
</dd>
</dl>
The first parameter is the name of the font file. The extension must be either .ttf or .pfb and
determines the font type. If you own a Type1 font in ASCII format (.pfa), you can convert it to
binary format with <a href="http://www.lcdf.org/~eddietwo/type/#t1utils" target="_blank">t1utils</a>.
<br>
If you don't want to embed the font, pass an empty string. In this case, type is given by the
<code>type</code> parameter.
<br>
Note: in the case of a font with the same name as a standard one, for instance arial.ttf, it is
recommended to embed. If you don't, some versions of Acrobat will use their own fonts.
<br>
<br>
The AFM file is the one previously generated.
<br>
<br>
The encoding defines the association between a code (from 0 to 255) and a character. The first
128 are fixed and correspond to ASCII; the following are variable. The encodings are stored in
.map files. Those available 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 chosen encoding.
<br>
In the particular case of a symbolic font (that is to say which does not contain letters, such
as Symbol or ZapfDingbats), pass an empty string.
<br>
The encodings which begin with cp are those used by Windows; Linux systems usually use ISO.
<br>
Remark: the standard fonts use cp1252.
<br>
<br>
The fourth parameter gives the possibility to alter the encoding. Sometimes you may want to add
some characters. For instance, ISO-8859-1 does not contain the euro symbol. To add it at position
164, pass <code>array(164=>'Euro')</code>.
<br>
<br>
The last parameter is used to give the type of the font in case it is not embedded (that is to
say the first parameter is empty).
<br>
<br>
After you have called the function (create a new file for this and include makefont.php, or
simply add the call directly inside), a .php file is created, with the same name as the .afm one.
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 alter the variable <code>$file</code>
in the .php file accordingly.
<br>
<br>
Example:
<div class="source">
<pre><code>MakeFont<span class="kw">(</span><span class="str">'c:\\windows\\fonts\\comic.ttf'</span><span class="kw">,</span><span class="str">'comic.afm'</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 you have to copy the generated file(s) to the font directory. If the font file
could not be compressed, copy the .ttf or .pfb instead of the .z.
<br>
<br>
Remark: for TTF fonts, you can generate the files online <a href="http://fpdf.fruit-lab.de" target="_blank">here</a>
instead of doing it manually.
<h2>Declaration of the font in the script</h2>
The last step is the most simple. You just need to call the <a href='../doc/addfont.htm'>AddFont()</a> method. For instance:
<div class="source">
<pre><code>$pdf<span class="kw">-&gt;</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>
or simply:
<div class="source">
<pre><code>$pdf<span class="kw">-&gt;</span>AddFont<span class="kw">(</span><span class="str">'Comic'</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 put:
<div class="source">
<pre><code>$pdf<span class="kw">-&gt;</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 small complete example. The font used is Calligrapher, available at
<a href="http://www.abstractfonts.com/fonts/" target="_blank">www.abstractfonts.com</a> (a site
offering numerous free TrueType fonts). The first step is the generation of the AFM file:
<br>
<br>
<kbd>ttf2pt1 -a calligra.ttf calligra</kbd>
<br>
<br>
which gives calligra.afm (and calligra.t1a that we can delete). Then we generate the definition
file:
<div class="source">
<pre><code>&lt;?php
<span class="kw">require(</span><span class="str">'font/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">'calligra.afm'</span><span class="kw">);
</span>?&gt;</code></pre>
</div>
The function call gives the following report:
<br>
<br>
<b>Warning:</b> character Euro is missing<br>
<b>Warning:</b> character Zcaron is missing<br>
<b>Warning:</b> character zcaron is missing<br>
<b>Warning:</b> character eth 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 is too old). Three other characters are missing
too, but we are not interested in them anyway.
<br>
We can now copy the two files to the font directory and write the script:
<div class="source">
<pre><code>&lt;?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">-&gt;</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">-&gt;</span>AddPage<span class="kw">();
</span>$pdf<span class="kw">-&gt;</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">-&gt;</span>Cell<span class="kw">(</span>0<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">-&gt;</span>Output<span class="kw">();
</span>?&gt;</code></pre>
</div>
<p class='demo'><a href='tuto7.php' target='_blank' class='demo'>[Demo]</a></p>
<h2>About the euro symbol</h2>
The euro character is not present in all encodings, and is not always placed at the same position:
<table>
<tr><th>Encoding</th><th>Position</th></tr>
<tr class="alt0"><td>cp1250</td><td>128</td></tr>
<tr class="alt1"><td>cp1251</td><td>136</td></tr>
<tr class="alt0"><td>cp1252</td><td>128</td></tr>
<tr class="alt1"><td>cp1253</td><td>128</td></tr>
<tr class="alt0"><td>cp1254</td><td>128</td></tr>
<tr class="alt1"><td>cp1255</td><td>128</td></tr>
<tr class="alt0"><td>cp1257</td><td>128</td></tr>
<tr class="alt1"><td>cp1258</td><td>128</td></tr>
<tr class="alt0"><td>cp874</td><td>128</td></tr>
<tr class="alt1"><td>ISO-8859-1</td><td>absent</td></tr>
<tr class="alt0"><td>ISO-8859-2</td><td>absent</td></tr>
<tr class="alt1"><td>ISO-8859-4</td><td>absent</td></tr>
<tr class="alt0"><td>ISO-8859-5</td><td>absent</td></tr>
<tr class="alt1"><td>ISO-8859-7</td><td>absent</td></tr>
<tr class="alt0"><td>ISO-8859-9</td><td>absent</td></tr>
<tr class="alt1"><td>ISO-8859-11</td><td>absent</td></tr>
<tr class="alt0"><td>ISO-8859-15</td><td>164</td></tr>
<tr class="alt1"><td>ISO-8859-16</td><td>164</td></tr>
<tr class="alt0"><td>KOI8-R</td><td>absent</td></tr>
<tr class="alt1"><td>KOI8-U</td><td>absent</td></tr>
</table>
ISO-8859-1 is widespread but does not include the euro sign. If you need it, the simplest thing
to do is using cp1252 or ISO-8859-15 instead, which are nearly identical but contain the precious
symbol.
<br>
As for ISO-8859-2, it is possible to use ISO-8859-16 instead, but it contains many differences.
It is therefore simpler to patch the encoding to add the symbol to it, as explained above. The
same is true for the other encodings.
<h2>Font synthesis under Windows</h2>
When a TrueType font is not available in a given style, Windows is able to synthesize it from the
regular version. For instance, there is no Comic Sans MS Italic, but it can be built from Comic
Sans MS Regular. This feature can be used in a PDF file, but unfortunately requires that the
regular font be present in the system (you must not embed it). Here is how to do it:
<ul>
<li>Generate the definition file for the regular font without embedding (you may rename it to
reflect the desired style)</li>
<li>Open it and append to the variable <code>$name</code> a comma followed by the desired style
(<code>Italic</code>, <code>Bold</code> or <code>BoldItalic</code>)</li>
</ul>
For instance, for the file comici.php:
<br>
<br>
<code>$name='ComicSansMS,Italic';</code>
<br>
<br>
It can then be used normally:
<div class="source">
<pre><code>$pdf<span class="kw">-&gt;</span>AddFont<span class="kw">(</span><span class="str">'Comic'</span><span class="kw">,</span><span class="str">'I'</span><span class="kw">,</span><span class="str">'comici.php'</span><span class="kw">);
</span></code></pre>
</div>
<h2>Reducing the size of TrueType fonts</h2>
Font files are often quite voluminous (more than 100, even 200KB); this is due to the fact that
they contain the characters corresponding to many encodings. zlib compression reduces them but
they remain fairly big. A technique exists to reduce them further. It consists in converting the
font to the Type1 format with ttf2pt1 by specifying the encoding you are interested in; all other
characters will be discarded.
<br>
For instance, the arial.ttf font shipped with Windows 98 is 267KB (it contains 1296 characters).
After compression it gives 147. Let's convert it to Type1 by keeping only cp1250 characters:
<br>
<br>
<kbd>ttf2pt1 -b -L cp1250.map c:\windows\fonts\arial.ttf arial</kbd>
<br>
<br>
The .map files are located in the font/makefont/ directory of the package. The command produces
arial.pfb and arial.afm. The arial.pfb file is only 35KB, and 30KB after compression.
<br>
<br>
It is possible to go even further. If you are interested only by a subset of the encoding (you
probably don't need all 217 characters), you can open the .map file and remove the lines you are
not interested in. This will reduce the file size accordingly.
</body>
</html>

11
fpdf16/tutorial/tuto7.php Executable file
View File

@@ -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();
?>