rbpdf-1.19.0/ 0000775 0000000 0000000 00000000000 12623665124 0012706 5 ustar 00root root 0000000 0000000 rbpdf-1.19.0/.gitignore 0000664 0000000 0000000 00000000023 12623665124 0014671 0 ustar 00root root 0000000 0000000 .DS_STORE .DS_Store rbpdf-1.19.0/.travis.yml 0000664 0000000 0000000 00000001324 12623665124 0015017 0 ustar 00root root 0000000 0000000 language: ruby rvm: - 1.8.7 - 1.9.2 - 1.9.3 - 2.0 - 2.1 - 2.2 - jruby matrix: allow_failures: - rvm: 1.8.7 gemfile: Gemfile.rails4 - rvm: 1.8.7 gemfile: Gemfile.rails4_rmagick - rvm: 1.9.2 gemfile: Gemfile.rails4 - rvm: 1.9.2 gemfile: Gemfile.rails4_rmagick - rvm: jruby gemfile: Gemfile.rails3_rmagick - rvm: jruby gemfile: Gemfile.rails4 - rvm: jruby gemfile: Gemfile.rails4_rmagick install: - bundle install env: - TEST_DIR=rbpdf-font - TEST_DIR=. script: - cd $TEST_DIR && bundle exec rake test gemfile: - Gemfile.rails3 - Gemfile.rails3_rmagick - Gemfile.rails4 - Gemfile.rails4_rmagick notifications: email: false rbpdf-1.19.0/CHANGELOG 0000664 0000000 0000000 00000011574 12623665124 0014130 0 ustar 00root root 0000000 0000000 1.19.0 2015-11-20 - Update base version to TCPDF 5.2.000. - IMPORTANT: Support for font subsetting was added by default to reduce the size of documents using large unicode font files. If you embed the whole font in the PDF, the person on the other end can make changes to it even if he didn't have your font. If you subset the font, file size of the PDF will be smaller but the person who receives your PDF would need to have your same font in order to make changes to your PDF. - The signature of the SetFont() and AddFont() methods were changed to include the font subsetting option (subsetting is applied by default). - html anchors support. (by Oleg German) - Test framework is changed to test-unit. This particular error will occur when the test suite is run from outside a Rails environment. Support the test suite is run from outside a Rails environment. - Fonts file was separated in rbpdf-font.gem. 1.18.7 2015-10-18 - Fixed case of missing HTML
tag texts with whitespace. (use htmlentities gem liblary.) - Fixed HTML Image function y position problem with png alpha image. 1.18.6 2015-06-20 - Fixed page boxes problem for iOS. - The dependence to the Rails environment was reduced. - Fixed Image tag's style attribute width/height parameter problem. - Open angled bracket '<' by HTML sanitize bug fixed. 1.18.5 2015-01-24 - Rails 4.2 and Ruby 2.2 supported. - Fix Rails 4.2 (new HTML sanitizer) compatible. - Method getHTMLUnitToUnits() and SetDisplayMode() was fixed, and the problem when dividing, by an integer was fixed. - Remove Rails 4.2 deprecated ::ActionView::Base.sanitized_allowed_css_properties=. - Fixed no left padding problem on tables. - Fixed thead tag position problem on page break. - fix case of missing HTML image (without height attribute) file. 1.18.4 2014-12-21 - utf8Bidi() Persion 0x200C(8204) and endedletter bug fixed. - utf8Bidi() Bidirectional Algorithm X9/I1 rule BN(ZERO WIDTH NON-JOINER) bug fixed. - utf8Bidi() Bidirectional Algorithm N1/N2 rule B/S/WS/ON bug fixed. - utf8Bidi() Bidirectional Algorithm W2/W7 rule bug fixed. - utf8Bidi() Bidirectional Algorithm N1/N2 rule multiple NIs bug fixed. - RTL direction problem fixed. isRTLTextDir direction bug fixed. - utf8Bidi() speed was improved. 1.18.3 2014-12-06 - fixed img and hr self html tag DOM problem. - fixed HTML table problem in writeHTMLCell function. - fixed the problem which is not separated when table tag continues. - fixed the problem that CSS classes don't work in thead table section. - HTML image margin was fixed so that a picture in the HTML table didn't overwrite a boundary line. - Method Write() was fixed to handle arabic strings. - Parameter of the method was changed fixed. - getPageDimensions, getBreakMargin, GetBreakMargin, startPageGroup methods fixed. - LICENSE.TXT file added. 1.18.2 2014-10-25 - getNumLines and a getStringHeight function fixed the problem which is wrong by the case of two or more lines. - fix case of missing image file. 1.18.1 2014-09-15 - ImagePngAlpha function fixed for the error case where an alpha channel cannot be deleted. - getimagesize function fixed for MAC OS rmagick. - getimagesize function fixed for grayscale JPEG Image. - 16-bit PNG with alpha channel image support improved. (use RMagick liblary) 1.18.0 2014-08-16 - rfpdf product name and TCPDF class name changed to RBPDF. - ImagePngAlpha function added. 1.17.4 2014-07-28 - getNumLines, getStringHeight, getMargins function added. - fix large image file page break bug. 1.17.3 2014-07-16 Several bug fixed. 1.17.2 2014-07-09 FreeSerif font added from GNU FreeFont(20080912). 1.17 2014-05-18 Update base version to TCPDF 5.1.002. Ruby 2.0/2.1 support. FPDF is deprecated. 1.16 2012-09-08 Rails 3.* and Ruby 1.9.* support, and fix FPDF severral bug. Jun NAITOH took over development of RFPDF from Edwin Moss. 1.15 2009-11-20 Rails 2.* support - Thanks to Prawnto plugin for showing the way to the new TemplateHandler 1.14 2006-09-26 * Added support for @options_for_rfpdf hash for configuration: * Added :filename option in this hash If you're using the same settings for @options_for_rfpdf often, you might want to put your assignment in a before_filter (perhaps overriding :filename, etc in your actions). 1.13 Updated to fpdf.rb 1.53d. Added makefont and fpdf_eps. Handle \n at the beginning of a string in MultiCell. Tried to fix clipping issue in MultiCell - still needs some work. 1.12 Added Korean support 1.11 Added Japanese support 1.10 Added Chinese support 1.00 Added view template functionality rbpdf-1.19.0/Gemfile 0000664 0000000 0000000 00000000155 12623665124 0014202 0 ustar 00root root 0000000 0000000 source 'https://rubygems.org' # Specify your gem's dependencies in rbpdf.gemspec gemspec gem "actionpack" rbpdf-1.19.0/Gemfile.rails3 0000664 0000000 0000000 00000000256 12623665124 0015400 0 ustar 00root root 0000000 0000000 source 'https://rubygems.org' # Specify your gem's dependencies in rbpdf.gemspec gemspec gem "actionpack", "~> 3.2.22" gem "i18n", "~> 0.6.11" gem "rack-cache", "~> 1.2.0" rbpdf-1.19.0/Gemfile.rails3_rmagick 0000664 0000000 0000000 00000000274 12623665124 0017075 0 ustar 00root root 0000000 0000000 source 'https://rubygems.org' # Specify your gem's dependencies in rbpdf.gemspec gemspec gem "actionpack", "~> 3.2.22" gem "i18n", "~> 0.6.11" gem "rack-cache", "~> 1.2.0" gem "rmagick" rbpdf-1.19.0/Gemfile.rails4 0000664 0000000 0000000 00000000170 12623665124 0015374 0 ustar 00root root 0000000 0000000 source 'https://rubygems.org' # Specify your gem's dependencies in rbpdf.gemspec gemspec gem "actionpack", "~> 4.2.4" rbpdf-1.19.0/Gemfile.rails4_rmagick 0000664 0000000 0000000 00000000206 12623665124 0017071 0 ustar 00root root 0000000 0000000 source 'https://rubygems.org' # Specify your gem's dependencies in rbpdf.gemspec gemspec gem "actionpack", "~> 4.2.4" gem "rmagick" rbpdf-1.19.0/LICENSE.TXT 0000775 0000000 0000000 00000063476 12623665124 0014414 0 ustar 00root root 0000000 0000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! rbpdf-1.19.0/MIT-LICENSE 0000664 0000000 0000000 00000002053 12623665124 0014342 0 ustar 00root root 0000000 0000000 Copyright (c) 2006 4ssoM LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOa AND NONINFRINGEMENT. IN NO EVENT SaALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. rbpdf-1.19.0/README.md 0000664 0000000 0000000 00000002475 12623665124 0014175 0 ustar 00root root 0000000 0000000 [](https://travis-ci.org/naitoh/rbpdf) # RBPDF Template Plugin A template plugin allowing the inclusion of ERB-enabled RBPDF template files. ## ## ## RBPDF Version (The New or UTF8 Version) ## ## * Use UTF-8 encoding. * RTL (Right-To-Left) languages support. * HTML tag support. * CSS minimum support. * Image - 8bit PNG image support without RMagick library. - PNG(with alpha channel)/JPEG/GIF image support. (use RMagick library) ## ## Installing RBPDF ## RBPDF is distributed via RubyGems, and can be installed the usual way that you install gems: by simply typing `gem install rbpdf` on the command line. == If you are using image file, it is recommended you install: ``` gem install rmagick ``` RBPDF Example of simple use in .html.erb: ``` <% @pdf = RBPDF.new() @pdf.set_margins(15, 27, 15) @pdf.set_font('FreeSans','', 8) @pdf.add_page() @pdf.write(5, "text\n", '') %><%==@pdf.output()%> ``` RBPDF Japanese Example of simple use in .html.erb: ``` <% @pdf = RBPDF.new() @pdf.set_margins(15, 27, 15) @pdf.set_font('kozminproregular','', 8) @pdf.add_page() @pdf.write(5, "UTF-8 Japanese text.\n", '') %><%==@pdf.output()%> ``` See the following files for sample of useage: test_unicode.rbpdf utf8test.txt logo_example.png ENJOY! rbpdf-1.19.0/Rakefile 0000664 0000000 0000000 00000000471 12623665124 0014355 0 ustar 00root root 0000000 0000000 require "bundler/gem_tasks" require 'rake/testtask' desc 'Run test_unit based test' Rake::TestTask.new do |t| # To run test for only one file (or file path pattern) # $ bundle exec rake test TEST=test/test_specified_path.rb t.libs << "test" t.test_files = Dir["test/rbpdf_*.rb"] t.verbose = true end rbpdf-1.19.0/example/ 0000775 0000000 0000000 00000000000 12623665124 0014341 5 ustar 00root root 0000000 0000000 rbpdf-1.19.0/example/rails/ 0000775 0000000 0000000 00000000000 12623665124 0015453 5 ustar 00root root 0000000 0000000 rbpdf-1.19.0/example/rails/app/ 0000775 0000000 0000000 00000000000 12623665124 0016233 5 ustar 00root root 0000000 0000000 rbpdf-1.19.0/example/rails/app/controllers/ 0000775 0000000 0000000 00000000000 12623665124 0020601 5 ustar 00root root 0000000 0000000 rbpdf-1.19.0/example/rails/app/controllers/example001_controller.rb 0000664 0000000 0000000 00000006325 12623665124 0025253 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-03-04 # Last Update : 2010-05-20 # # Description : Example 001 for RBPDF class # Default Header and Footer # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example001Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 001') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 001', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # Set font # dejavusans is a UTF-8 Unicode font, if you only need to # print standard ASCII chars, you can use core fonts like # helvetica or times to reduce file size. pdf.set_font('dejavusans', '', 14) # Add a page # This method has several options, check the source code documentation for more information. pdf.add_page() # Set some content to print html = < Welcome to RBPDF ! This is the first example of RBPDF library. This text is printed using the write_html_cell() method but you can also use: multi_cell(), write_html(), write(), cell() and text().
Please check the source code documentation and other examples for further information.
EOD # Print text using write_html_cell() pdf.write_html_cell(w=0, h=0, x='', y='', html, border=0, ln=1, fill=0, reseth=true, align='', autopadding=true) # --------------------------------------------------------- # Close and output PDF document # This method has several options, check the source code documentation for more information. send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example002_controller.rb 0000664 0000000 0000000 00000004254 12623665124 0025253 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-03-04 # Last Update : 2010-05-20 # # Description : Example 002 for RBPDF class # Removing Header and Footer # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example002Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 002') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # remove default header/footer pdf.set_print_header(false) pdf.set_print_footer(false) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('times', 'BI', 20) # add a page pdf.add_page() # set some text to print txt = <"application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example003_controller.rb 0000664 0000000 0000000 00000006352 12623665124 0025255 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-03-04 # Last Update : 2010-05-20 # # Description : Example 003 for RBPDF class # Custom Header and Footer # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example003Controller < ApplicationController # Extend the RBPDF class to create custom Header and Footer class MYPDF < RBPDF # Page header def Header() # Logo image_file = Rails.root.to_s + '/public/logo_example.png' Image(image_file, 10, 10, 15, '', 'PNG', '', 'T', false, 300, '', false, false, 0, false, false, false) # Set font set_font('helvetica', 'B', 20) # Title cell(0, 15, '<< RBPDF Example 003 >>', 0, 0, 'C', 0, '', 0, false, 'M', 'M') end # Page footer def Footer() # Position at 15 mm from bottom set_y(-15) # Set font set_font('helvetica', 'I', 8) # Page number cell(0, 10, 'Page ' + getAliasNumPage() + '/' + getAliasNbPages(), 0, 0, 'C', 0, '', 0, false, 'T', 'M') end end def index # create new PDF document pdf = MYPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 003') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('times', 'BI', 12) # add a page pdf.add_page() # set some text to print txt = < "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example004_controller.rb 0000664 0000000 0000000 00000005743 12623665124 0025261 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-03-04 # Last Update : 2010-05-20 # # Description : Example 004 for RBPDF class # Cell stretching # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example004Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 004') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 004', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('times', 'B', 12) # add a page pdf.add_page() #cell(w, h=0, txt='', border=0, ln=0, align='', fill=0, link='', stretch=0, ignore_min_height=false, calign='T', valign='M') # test Cell stretching pdf.cell(0, 10, 'TEST CELL STRETCH: no stretch', 1, 1, 'C', 0, '', 0) pdf.cell(0, 10, 'TEST CELL STRETCH: scaling', 1, 1, 'C', 0, '', 1) pdf.cell(0, 10, 'TEST CELL STRETCH: force scaling', 1, 1, 'C', 0, '', 2) pdf.cell(0, 10, 'TEST CELL STRETCH: spacing', 1, 1, 'C', 0, '', 3) pdf.cell(0, 10, 'TEST CELL STRETCH: force spacing', 1, 1, 'C', 0, '', 4) pdf.ln(10) pdf.cell(60, 10, 'TEST CELL STRETCH: scaling', 1, 1, 'C', 0, '', 1) pdf.cell(60, 10, 'TEST CELL STRETCH: force scaling', 1, 1, 'C', 0, '', 2) pdf.cell(60, 10, 'TEST CELL STRETCH: spacing', 1, 1, 'C', 0, '', 3) pdf.cell(60, 10, 'TEST CELL STRETCH: force spacing', 1, 1, 'C', 0, '', 4) # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example005_controller.rb 0000664 0000000 0000000 00000011150 12623665124 0025247 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-03-04 # Last Update : 2010-05-20 # # Description : Example 005 for RBPDF class # Multicell # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example005Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 005') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 005', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('times', '', 10) # add a page pdf.add_page() # set color for background pdf.set_fill_color(255, 255, 127) # multi_cell(w, h, txt, border=0, align='J', fill=0, ln=1, x='', y='', reseth=true, stretch=0, ishtml=false, autopadding=true, maxh=0) # set some text for example txt = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.' # Multicell test pdf.multi_cell(55, 5, '[LEFT] ' + txt, 1, 'L', 1, 0, '', '', true) pdf.multi_cell(55, 5, '[RIGHT] ' + txt, 1, 'R', 0, 1, '', '', true) pdf.multi_cell(55, 5, '[CENTER] ' + txt, 1, 'C', 0, 0, '', '', true) pdf.multi_cell(55, 5, '[JUSTIFY] ' + txt + "\n", 1, 'J', 1, 2, '' ,'', true) pdf.multi_cell(55, 5, '[DEFAULT] ' + txt, 1, '', 0, 1, '', '', true) # set color for background pdf.set_fill_color(215, 235, 255) # set some text for example txt = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sed imperdiet lectus. Phasellus quis velit velit, non condimentum quam. Sed neque urna, ultrices ac volutpat vel, laoreet vitae augue. Sed vel velit erat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Cras eget velit nila, eu sagittis elit. Nunc ac arcu est, in lobortis tellus. Praesent condimentum rhoncus sodales. In hac habitasse platea dictumst. Proin porta eros pharetra enim tincidunt dignissim nec vel dolor. Cras sapien elit, ornare ac dignissim eu, ultricies ac eros. Maecenas augue magna, ultrices a congue in, mollis eu nila. Nunc venenatis massa at est eleifend faucibus. Vivamus sed risus lectus, nec interdum nunc. Fusce et felis vitae diam lobortis sollicitudin. Aenean tincidunt accumsan nisi, id vehicula quam laoreet elementum. Phasellus egestas interdum erat, et viverra ipsum ultricies ac. Praesent sagittis augue at augue volutpat eleifend. Cras nec orci neque. Mauris bibendum posuere blandit. Donec feugiat mollis dui sit amet pellentesque. Sed a enim justo. Donec tincidunt, nisl eget elementum aliquam, odio ipsum ultrices quam, eu porttitor ligula urna at lorem. Donec varius, eros et convallis laoreet, ligula tellus consequat felis, ut ornare metus tellus sodales velit. Duis sed diam ante. Ut rutrum malesuada massa, vitae consectetur ipsum rhoncus sed. Suspendisse potenti. Pellentesque a congue massa.' # print a blox of text using multicell() pdf.multi_cell(80, 5, txt + "\n", 1, 'J', 1, 1, '' ,'', true) # move pointer to last page pdf.last_page() # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example006_controller.rb 0000664 0000000 0000000 00000033247 12623665124 0025263 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-03-04 # Last Update : 2010-05-20 # # Description : Example 006 for RBPDF class # write_html and RTL support # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example006Controller < ApplicationController require 'htmlcolors.rb' include Html_colors def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 006') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 006', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('dejavusans', '', 10) # add a page pdf.add_page() # write_html(html, ln=true, fill=false, reseth=false, cell=false, align='') # write_html_cell(w, h, x, y, html='', border=0, ln=0, fill=0, reseth=true, align='', autopadding=true) # create some HTML content html = ' HTML Example
Some special characters: < € € € & è è © > \\slash \\\\double-slash \\\\\\triple-slashList
List example:
test image
- bold text
- italic text
- underlined text
- bbibiubib
- link to https://github.com/naitoh/rbpdf
- Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.- SUBLIST
- row one
- sublist
- row two
- TEST
line through- font + 3
- small text normal small text normal subscript normal superscript normal
- Coffee
- Black hot drink
- Milk
- White cold drink
IMAGES' # output the HTML content pdf.write_html(html, true, false, true, false, '') # output some RTL HTML content html = '
The words “מזל [mazel] טוב [tov]” mean “Congratulations!”' pdf.write_html(html, true, false, true, false, '') # test some inline CSS html = 'This is just an example of html code to demonstrate some supported CSS inline styles. bold text line-trough underline and line-trough color background color bold xx-small x-small small medium large x-large xx-large
' pdf.write_html(html, true, false, true, false, '') # reset pointer to the last page pdf.last_page() # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Print a table # add a page pdf.add_page() # create some HTML content subtable = '' html = '
a b c d HTML TABLE:
' # output the HTML content pdf.write_html(html, true, false, true, false, '') # Print some HTML Cells html = 'red green blue
# RIGHT align LEFT align 4A 1 A1 example link column span. One two tree four five six seven eight nine ten.
line after br
small text normal subscript normal superscript normal bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla blasmall small small small small small small small small small small small small small small small small small small small
- first
- sublist
- sublist
- second
4B ' + subtable + ' A2 € € € & è è
A2 € € € & è èRed Yellow BG 4C 1A 2AA
2AB
2AC4D 1B 4E 1C 2C 3C 4F
red green blue' pdf.set_fill_color(255,255,0) pdf.write_html_cell(0, 0, '', '', html, 'LRTB', 1, 0, true, 'L', true) pdf.write_html_cell(0, 0, '', '', html, 'LRTB', 1, 1, true, 'C', true) pdf.write_html_cell(0, 0, '', '', html, 'LRTB', 1, 0, true, 'R', true) # reset pointer to the last page pdf.last_page() # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Print a table # add a page pdf.add_page() # create some HTML content html = 'Image alignments on HTML table
' # output the HTML content pdf.write_html(html, true, false, true, false, '') # reset pointer to the last page pdf.last_page() # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Print all HTML colors # add a page pdf.add_page() textcolors = '
HTML Text Colors
' bgcolors = 'HTML Background Colors
' @@webcolor.each{|k,v| textcolors << '' + v + ' ' bgcolors << '' + v + ' ' } # output the HTML content pdf.write_html(textcolors, true, false, true, false, '') pdf.write_html(bgcolors, true, false, true, false, '') # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Test word-wrap # create some HTML content html = '
Various tests
link to page 2
thisisaverylongword thisisanotherverylongword thisisaverylongword thisisanotherverylongword thisisaverylongword thisisaverylongword thisisanotherverylongword thisisaverylongword thisisanotherverylongword thisisaverylongword thisisaverylongword thisisanotherverylongword thisisaverylongword thisisanotherverylongword thisisaverylongword thisisaverylongword thisisanotherverylongword thisisaverylongword thisisanotherverylongword thisisaverylongword thisisaverylongword thisisanotherverylongword thisisaverylongword thisisanotherverylongword thisisaverylongword' # output the HTML content pdf.write_html(html, true, false, true, false, '') # Test fonts nesting html1 = 'Default Courier Helvetica Times dejavusans Times Helvetica Courier Default' html2 = 'small text normal small text normal subscript normal superscript normal' html3 = 'The quick brown fox jumps over the lazy dog.' html = html1 + '
' + html2 + '
' + html3 + '
' + html3 + '
' + html2 # output the HTML content pdf.write_html(html, true, false, true, false, '') # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # test pre tag # add a page pdf.add_page() html = <Hello World!
Helloint main() { printf("HelloWorld") return 0 }Monospace font, normal font, monospace font, normal font.
DIV LEVEL 1DIV LEVEL 2DIV LEVEL 1
SPAN LEVEL 1 SPAN LEVEL 2 SPAN LEVEL 1 EOF # output the HTML content pdf.write_html(html, true, false, true, false, '') # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # reset pointer to the last page pdf.last_page() # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example007_controller.rb 0000664 0000000 0000000 00000022477 12623665124 0025267 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-03-04 # Last Update : 2010-05-20 # # Description : Example 007 for RBPDF class # Two independent columns with write_htmlcell() # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example007Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 007') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 007', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('times', '', 12) # add a page pdf.add_page() # create columns content left_column = 'LEFT COLUMN left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column' right_column = 'RIGHT COLUMN right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column' # write_html_cell(w, h, x, y, html='', border=0, ln=0, fill=0, reseth=true, align='', autopadding=true) # get current vertical position y = pdf.get_y() # set color for background pdf.set_fill_color(255, 255, 200) # set color for text pdf.set_text_color(0, 63, 127) # write the first column pdf.write_html_cell(80, '', '', y, left_column, 1, 0, 1, true, 'J', true) # set color for background pdf.set_fill_color(215, 235, 255) # set color for text pdf.set_text_color(127, 31, 0) # write the second column pdf.write_html_cell(80, '', '', '', right_column, 1, 1, 1, true, 'J', true) # reset pointer to the last page pdf.last_page() # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example008_controller.rb 0000664 0000000 0000000 00000005122 12623665124 0025254 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-03-04 # Last Update : 2010-05-20 # # Description : Example 008 for RBPDF class # Include external UTF-8 text file # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example008Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 008') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 008', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('freeserif', '', 12) # add a page pdf.add_page() # get esternal file content utf8text='' file = Rails.root.to_s + '/public/utf8test.txt' open(file,'rb') do |f| utf8text<"application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example009_controller.rb 0000664 0000000 0000000 00000005017 12623665124 0025260 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-03-04 # Last Update : 2010-05-20 # # Description : Example 009 for RBPDF class # Test Image # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example009Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 009') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 009', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # add a page pdf.add_page() # set JPEG quality pdf.set_jpeg_quality(75) # image(file, x='', y='', w=0, h=0, type='', link='', align='', resize=false, dpi=300, palign='', ismask=false, imgmask=false, border=0, fitbox=false, hidden=false, fitonpage=false) # Image example pdf.image('' + Rails.root.to_s + '/public/image_demo.jpg', 50, 50, 100, 150, 'JPG', 'https://github.com/naitoh/rbpdf', '', true, 150, '', false, false, 1, false, false, false) # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example011_controller.rb 0000664 0000000 0000000 00000007251 12623665124 0025253 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-03-04 # Last Update : 2010-05-20 # # Description : Example 011 for RBPDF class # Colored Table # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example011Controller < ApplicationController # extend TCPF with custom functions class MYPDF < RBPDF # Load table data from file def LoadData(file) # Read file lines lines = File.open(file).readlines data = [] lines.each {|line| data.push line.rstrip.split(';') } return data end # Colored table def ColoredTable(header,data) # Colors, line width and bold font set_fill_color(255, 0, 0) set_text_color(255) set_draw_color(128, 0, 0) set_line_width(0.3) set_font('', 'B') # Header w = [40, 35, 40, 45] num_headers = header.length num_headers.times do |i| cell(w[i], 7, header[i], 1, 0, 'C', 1) end ln() # Color and font restoration set_fill_color(224, 235, 255) set_text_color(0) set_font('') # Data fill = 0 data.each {|row| cell(w[0], 6, row[0], 'LR', 0, 'L', fill) cell(w[1], 6, row[1], 'LR', 0, 'L', fill) cell(w[2], 6, number_with_delimiter(row[2], :delimiter => ","), 'LR', 0, 'R', fill) cell(w[3], 6, number_with_delimiter(row[3], :delimiter => ","), 'LR', 0, 'R', fill) ln() fill = fill == 0 ? 1 :0 } ww = w.inject {|sum,x| sum ? sum + x : x } cell(ww, 0, '', 'T') end end def index # create new PDF document pdf = MYPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 011') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 011', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('helvetica', '', 12) # add a page pdf.add_page() # Column titles header = ['Country', 'Capital', 'Area (sq km)', 'Pop. (thousands)'] # Data loading data = pdf.LoadData("#{File.join(Rails.root, 'public')}/table_data_demo.txt") # print colored table pdf.ColoredTable(header, data) # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example012_controller.rb 0000664 0000000 0000000 00000017116 12623665124 0025255 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-03-04 # Last Update : 2010-05-20 # # Description : Example 012 for RBPDF class # Graphic Functions # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example012Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 012') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # disable header and footer pdf.set_print_header(false) pdf.set_print_footer(false) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('helvetica', '', 10) # add a page pdf.add_page() style = {'width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => '10,20,5,10', 'phase' => 10, 'color' => [255, 0, 0]} style2 = {'width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => [255, 0, 0]} style3 = {'width' => 1, 'cap' => 'round', 'join' => 'round', 'dash' => '2,10', 'color' => [255, 0, 0]} style4 = {'L' => 0, 'T' => {'width' => 0.25, 'cap' => 'butt', 'join' => 'miter', 'dash' => '20,10', 'phase' => 10, 'color' => [100, 100, 255]}, 'R' => {'width' => 0.50, 'cap' => 'round', 'join' => 'miter', 'dash' => 0, 'color' => [50, 50, 127]}, 'B' => {'width' => 0.75, 'cap' => 'square', 'join' => 'miter', 'dash' => '30,10,5,10'}} style5 = {'width' => 0.25, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => [0, 64, 128]} style6 = {'width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => '10,10', 'color' => [0, 128, 0]} style7 = {'width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => [255, 128, 0]} # Line pdf.text(5, 4, 'Line examples') pdf.line(5, 10, 80, 30, style) pdf.line(5, 10, 5, 30, style2) pdf.line(5, 10, 80, 10, style3) # Rect pdf.text(100, 4, 'Rectangle examples') pdf.rect(100, 10, 40, 20, 'DF', style4, [220, 220, 200]) pdf.rect(145, 10, 40, 20, 'D', {'all' => style3}) # Curve pdf.text(5, 34, 'Curve examples') pdf.curve(5, 40, 30, 55, 70, 45, 60, 75, nil, style6) pdf.curve(80, 40, 70, 75, 150, 45, 100, 75, 'F', style6) pdf.curve(140, 40, 150, 55, 180, 45, 200, 75, 'DF', style6, [200, 220, 200]) # Circle and ellipse pdf.text(5, 79, 'Circle and ellipse examples') pdf.set_line_style(style5) pdf.circle(25,105,20) pdf.circle(25,105,10, 90, 180, nil, style6) pdf.circle(25,105,10, 270, 360, 'F') pdf.circle(25,105,10, 270, 360, 'C', style6) pdf.set_line_style(style5) pdf.ellipse(100,103,40,20) pdf.ellipse(100,105,20,10, 0, 90, 180, nil, style6) pdf.ellipse(100,105,20,10, 0, 270, 360, 'DF', style6) pdf.set_line_style(style5) pdf.ellipse(175,103,30,15,45) pdf.ellipse(175,105,15,7.50, 45, 90, 180, nil, style6) pdf.ellipse(175,105,15,7.50, 45, 270, 360, 'F', style6, [220, 200, 200]) # Polygon pdf.text(5, 129, 'Polygon examples') pdf.set_line_style({'width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => [0, 0, 0]}) pdf.polygon([5,135,45,135,15,165]) pdf.polygon([60,135,80,135,80,155,70,165,50,155], 'DF', [style6, style7, style7, 0, style6], [220, 200, 200]) pdf.polygon([120,135,140,135,150,155,110,155], 'D', [style6, 0, style7, style6]) pdf.polygon([160,135,190,155,170,155,200,160,160,165], 'DF', {'all' => style6}, [220, 220, 220]) # Polygonal Line pdf.set_line_style({'width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => [0, 0, 164]}) pdf.poly_line([80,165,90,160,100,165,110,160,120,165,130,160,140,165], 'D', nil, nil) # Regular polygon pdf.text(5, 169, 'Regular polygon examples') pdf.set_line_style(style5) pdf.regular_polygon(20, 190, 15, 6, 0, 1, 'F') pdf.regular_polygon(55, 190, 15, 6) pdf.regular_polygon(55, 190, 10, 6, 45, 0, 'DF', [style6, 0, style7, 0, style7, style7]) pdf.regular_polygon(90, 190, 15, 3, 0, 1, 'DF', {'all' => style5}, [200, 220, 200], 'F', [255, 200, 200]) pdf.regular_polygon(125, 190, 15, 4, 30, 1, nil, {'all' => style5}, nil, nil, style6) pdf.regular_polygon(160, 190, 15, 10) # Star polygon pdf.text(5, 209, 'Star polygon examples') pdf.set_line_style(style5) pdf.star_polygon(20, 230, 15, 20, 3, 0, 1, 'F') pdf.star_polygon(55, 230, 15, 12, 5) pdf.star_polygon(55, 230, 7, 12, 5, 45, 0, 'DF', {'all' => style7}, [220, 220, 200], 'F', [255, 200, 200]) pdf.star_polygon(90, 230, 15, 20, 6, 0, 1, 'DF', {'all' => style5}, [220, 220, 200], 'F', [255, 200, 200]) pdf.star_polygon(125, 230, 15, 5, 2, 30, 1, nil, {'all' => style5}, nil, nil, style6) pdf.star_polygon(160, 230, 15, 10, 3) pdf.star_polygon(160, 230, 7, 50, 26) # Rounded rectangle pdf.text(5, 249, 'Rounded rectangle examples') pdf.set_line_style({'width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => [0, 0, 0]}) pdf.rounded_rect(5, 255, 40, 30, 3.50, '1111', 'DF') pdf.rounded_rect(50, 255, 40, 30, 6.50, '1000') pdf.rounded_rect(95, 255, 40, 30, 10.0, '1111', nil, style6) pdf.rounded_rect(140, 255, 40, 30, 8.0, '0101', 'DF', style6, [200, 200, 200]) # Arrows pdf.text(185, 249, 'Arrows') pdf.set_line_style(style5) pdf.set_fill_color(255, 0, 0) pdf.Arrow(x0=200, y0=280, x1=185, y1=266, head_style=0, arm_size=5, arm_angle=15) pdf.Arrow(x0=200, y0=280, x1=190, y1=263, head_style=1, arm_size=5, arm_angle=15) pdf.Arrow(x0=200, y0=280, x1=195, y1=261, head_style=2, arm_size=5, arm_angle=15) pdf.Arrow(x0=200, y0=280, x1=200, y1=260, head_style=3, arm_size=5, arm_angle=15) # - . - . - . - . - . - . - . - . - . - . - . - . - . - . - # ellipse # add a page pdf.add_page() pdf.cell(0, 0, 'Arc of Ellipse') # center of ellipse xc=100 yc=100 # X Y axis pdf.set_draw_color(200, 200, 200) pdf.line(xc-50, yc, xc+50, yc) pdf.line(xc, yc-50, xc, yc+50) # ellipse axis pdf.set_draw_color(200, 220, 255) pdf.line(xc-50, yc-50, xc+50, yc+50) pdf.line(xc-50, yc+50, xc+50, yc-50) # ellipse pdf.set_draw_color(200, 255, 200) pdf.ellipse(xc, yc, rx=30, ry=15, angle=45, astart=0, afinish=360, style='D', line_style=nil, fill_color=nil, nc=2) # ellipse arc pdf.set_draw_color(255, 0, 0) pdf.ellipse(xc, yc, rx=30, ry=15, angle=45, astart=45, afinish=90, style='D', line_style=nil, fill_color=nil, nc=2) # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example015_controller.rb 0000664 0000000 0000000 00000006310 12623665124 0025252 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-03-04 # Last Update : 2010-05-20 # # Description : Example 015 for RBPDF class # Bookmarks (Table of Content) # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example015Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 015') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 015', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # bookmark(txt, level=0, y=-1, page='') # set font pdf.set_font('times', 'B', 20) # add a page pdf.add_page() # set a bookmark for the current position pdf.bookmark('Chapter 1', 0, 0) # print a line using cell() pdf.cell(0, 10, 'Chapter 1', 0, 1, 'L') pdf.set_font('times', 'I', 14) pdf.write(0, 'You can set PDF Bookmarks using the bookmark() method.') pdf.set_font('times', 'B', 20) # add other pages and bookmarks pdf.add_page() pdf.bookmark('Paragraph 1.1', 1, 0) pdf.cell(0, 10, 'Paragraph 1.1', 0, 1, 'L') pdf.add_page() pdf.bookmark('Paragraph 1.2', 1, 0) pdf.cell(0, 10, 'Paragraph 1.2', 0, 1, 'L') pdf.add_page() pdf.bookmark('Sub-Paragraph 1.2.1', 2, 0) pdf.cell(0, 10, 'Sub-Paragraph 1.2.1', 0, 1, 'L') pdf.add_page() pdf.bookmark('Paragraph 1.3', 1, 0) pdf.cell(0, 10, 'Paragraph 1.3', 0, 1, 'L') pdf.add_page() pdf.bookmark('Chapter 2', 0, 0) pdf.cell(0, 10, 'Chapter 2', 0, 1, 'L') pdf.add_page() pdf.bookmark('Chapter 3', 0, 0) pdf.cell(0, 10, 'Chapter 3', 0, 1, 'L') # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example017_controller.rb 0000664 0000000 0000000 00000022757 12623665124 0025271 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-03-04 # Last Update : 2010-05-20 # # Description : Example 017 for RBPDF class # Two independent columns with MultiCell # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example017Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 017') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 017', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('helvetica', '', 20) # add a page pdf.add_page() pdf.write(0, 'Example of independent multi_cell() columns', '', 0, 'L', true, 0, false, false, 0) pdf.ln(5) pdf.set_font('times', '', 12) # create columns content # create columns content left_column = '[LEFT COLUMN] left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column' + "\n" right_column = '[RIGHT COLUMN] right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column' + "\n" # multi_cell(w, h, txt, border=0, align='J', fill=0, ln=1, x='', y='', reseth=true, stretch=0, ishtml=false, autopadding=true, maxh=0) # set color for background pdf.set_fill_color(255, 255, 200) # set color for text pdf.set_text_color(0, 63, 127) # write the first column pdf.multi_cell(80, 0, left_column, 1, 'J', 1, 0, '', '', true, 0, false, true, 0) # set color for background pdf.set_fill_color(215, 235, 255) # set color for text pdf.set_text_color(127, 31, 0) # write the second column pdf.multi_cell(80, 0, right_column, 1, 'J', 1, 1, '', '', true, 0, false, true, 0) # reset pointer to the last page pdf.last_page() # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example018_controller.rb 0000664 0000000 0000000 00000011066 12623665124 0025261 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-03-06 # Last Update : 2010-05-20 # # Description : Example 018 for RBPDF class # RTL document with Persian language # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example018Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 018') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 018', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language dependent data: lg = {} lg['a_meta_charset'] = 'UTF-8' lg['a_meta_dir'] = 'rtl' lg['a_meta_language'] = 'fa' lg['w_page'] = 'page' # set some language-dependent strings pdf.set_language_array(lg) # --------------------------------------------------------- # set font pdf.set_font('dejavusans', '', 12) # add a page pdf.add_page() # Persian and English content htmlpersian = 'Persian example:
سلام بالاخره مشکل PDF فارسی به طور کامل حل شد. اینم یک نمونش.
مشکل حرف \"ژ\" در بعضی کلمات مانند کلمه ویژه نیز بر طرف شد.
نگارش حروف لام و الف پشت سر هم نیز تصحیح شد.
با تشکر از "Asuni Nicola" و محمد علی گل کار برای پشتیبانی زبان فارسی.' pdf.write_html(htmlpersian, true, 0, true, 0) # set LTR direction for english translation pdf.set_rtl(false) pdf.set_font_size(10) # print newline pdf.ln() # Persian and English content htmlpersiantranslation = 'Hi, At last Problem of Persian PDF Solved completely. This is a example for it.
Problem of "jeh" letter in some word like "ویژه" (=special) fix too.
The joining of laa and alf letter fix now.
Special thanks to "Nicola Asuni" and "Mohamad Ali Golkar" for Persian support.' pdf.write_html(htmlpersiantranslation, true, 0, true, 0) # Restore RTL direction pdf.set_rtl(true) # set font size #pdf.set_font('almohanad', '', 18) # print newline pdf.ln() # Arabic and English content pdf.cell(0, 12, 'بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ',0,1,'C') htmlcontent = 'تمَّ بِحمد الله حلّ مشكلة الكتابة باللغة العربية في ملفات الـPDF مع دعم الكتابة من اليمين إلى اليسار والحركَات .
تم الحل بواسطة صالح المطرفي و Asuni Nicola . ' pdf.write_html(htmlcontent, true, 0, true, 0) # set LTR direction for english translation pdf.set_rtl(false) # set font size pdf.set_font_size(18) # print newline pdf.ln() # Arabic and English content htmlcontent2 = 'This is Arabic "العربية" Example With RBPDF.' pdf.write_html(htmlcontent2, true, 0, true, 0) # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example020_controller.rb 0000664 0000000 0000000 00000012037 12623665124 0025251 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-03-04 # Last Update : 2010-05-20 # # Description : Example 020 for RBPDF class # Two columns composed by MultiCell of different # heights # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example020Controller < ApplicationController # extend RBPDF with custom functions class MYPDF < RBPDF def multi_row(left, right) # multi_cell(w, h, txt, border=0, align='J', fill=0, ln=1, x='', y='', reseth=true, stretch=0) page_start = get_page() y_start = get_y() # write the left cell multi_cell(40, 0, left, 1, 'R', 1, 2, '', '', true, 0) page_end_1 = get_page() y_end_1 = get_y() set_page(page_start) # write the right cell multi_cell(0, 0, right, 1, 'J', 0, 1, get_x() ,y_start, true, 0) page_end_2 = get_page() y_end_2 = get_y() # set the new row position by case if [page_end_1,page_end_2].max == page_start ynew = [y_end_1, y_end_2].max elsif page_end_1 == page_end_2 ynew = [y_end_1, y_end_2].max elsif page_end_1 > page_end_2 ynew = y_end_1 else ynew = y_end_2 end set_page([page_end_1,page_end_2].max) set_xy(get_x(), ynew) end end def index # create new PDF document pdf = MYPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 020') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 020', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('helvetica', '', 20) # add a page pdf.add_page() pdf.write(0, 'Example of text layout using multi_cell()', '', 0, 'L', true, 0, false, false, 0) pdf.ln(5) pdf.set_font('times', '', 9) #pdf.set_cell_padding(0) #pdf.set_line_width(2) # set color for background pdf.set_fill_color(255, 255, 200) text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sed imperdiet lectus. Phasellus quis velit velit, non condimentum quam. Sed neque urna, ultrices ac volutpat vel, laoreet vitae augue. Sed vel velit erat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Cras eget velit nila, eu sagittis elit. Nunc ac arcu est, in lobortis tellus. Praesent condimentum rhoncus sodales. In hac habitasse platea dictumst. Proin porta eros pharetra enim tincidunt dignissim nec vel dolor. Cras sapien elit, ornare ac dignissim eu, ultricies ac eros. Maecenas augue magna, ultrices a congue in, mollis eu nila. Nunc venenatis massa at est eleifend faucibus. Vivamus sed risus lectus, nec interdum nunc. Fusce et felis vitae diam lobortis sollicitudin. Aenean tincidunt accumsan nisi, id vehicula quam laoreet elementum. Phasellus egestas interdum erat, et viverra ipsum ultricies ac. Praesent sagittis augue at augue volutpat eleifend. Cras nec orci neque. Mauris bibendum posuere blandit. Donec feugiat mollis dui sit amet pellentesque. Sed a enim justo. Donec tincidunt, nisl eget elementum aliquam, odio ipsum ultrices quam, eu porttitor ligula urna at lorem. Donec varius, eros et convallis laoreet, ligula tellus consequat felis, ut ornare metus tellus sodales velit. Duis sed diam ante. Ut rutrum malesuada massa, vitae consectetur ipsum rhoncus sed. Suspendisse potenti. Pellentesque a congue massa.' # print some rows just as example 7.times do |i| pdf.multi_row('Row ' + (i+1).to_s, text + "\n") end # reset pointer to the last page pdf.last_page() # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example021_controller.rb 0000664 0000000 0000000 00000012341 12623665124 0025250 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-03-04 # Last Update : 2010-05-20 # # Description : Example 021 for RBPDF class # write_html text flow # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example021Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 021') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 021', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('helvetica', '', 9) # add a page pdf.add_page() # create some HTML content html = 'Example of HTML text flow
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nila pariatur?
A + B = C -> C - B = A -> C - A = B -> A + B = C -> C - B = A -> C - A = B -> A + B = C -> C - B = A -> C - A = B -> A + B = C -> C - B = A -> C - A = B -> A + B = C -> C - B = A -> C - A = B -> A + B = C -> C - B = A -> C - A = B -> A + B = C -> C - B = A -> C - A = B -> A + B = C -> C - B = A -> C - A = B
BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined' # output the HTML content pdf.write_html(html, true, 0, true, 0) # reset pointer to the last page pdf.last_page() # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example022_controller.rb 0000664 0000000 0000000 00000010223 12623665124 0025246 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-03-04 # Last Update : 2010-05-20 # # Description : Example 022 for RBPDF class # CMYK colors # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example022Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 022') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 022', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # check also the following methods: # set_draw_colorArray() # set_fill_colorArray() # set_text_colorArray() # set font pdf.set_font('helvetica', 'B', 18) # add a page pdf.add_page() pdf.write(0, 'Example of CMYK, RGB and Grayscale colours', '', 0, 'L', true, 0, false, false, 0) # define style for border border_style = {'all' => {'width' => 2, 'cap' => 'square', 'join' => 'miter', 'dash' => 0, 'phase' => 0}} # --- CMYK ------------------------------------------------ pdf.set_draw_color(50, 0, 0, 0) pdf.set_fill_color(100, 0, 0, 0) pdf.set_text_color(100, 0, 0, 0) pdf.rect(30, 60, 30, 30, 'DF', border_style) pdf.text(30, 92, 'Cyan') pdf.set_draw_color(0, 50, 0, 0) pdf.set_fill_color(0, 100, 0, 0) pdf.set_text_color(0, 100, 0, 0) pdf.rect(70, 60, 30, 30, 'DF', border_style) pdf.text(70, 92, 'Magenta') pdf.set_draw_color(0, 0, 50, 0) pdf.set_fill_color(0, 0, 100, 0) pdf.set_text_color(0, 0, 100, 0) pdf.rect(110, 60, 30, 30, 'DF', border_style) pdf.text(110, 92, 'Yellow') pdf.set_draw_color(0, 0, 0, 50) pdf.set_fill_color(0, 0, 0, 100) pdf.set_text_color(0, 0, 0, 100) pdf.rect(150, 60, 30, 30, 'DF', border_style) pdf.text(150, 92, 'Black') # --- RGB ------------------------------------------------- pdf.set_draw_color(255, 127, 127) pdf.set_fill_color(255, 0, 0) pdf.set_text_color(255, 0, 0) pdf.rect(30, 110, 30, 30, 'DF', border_style) pdf.text(30, 142, 'Red') pdf.set_draw_color(127, 255, 127) pdf.set_fill_color(0, 255, 0) pdf.set_text_color(0, 255, 0) pdf.rect(70, 110, 30, 30, 'DF', border_style) pdf.text(70, 142, 'Green') pdf.set_draw_color(127, 127, 255) pdf.set_fill_color(0, 0, 255) pdf.set_text_color(0, 0, 255) pdf.rect(110, 110, 30, 30, 'DF', border_style) pdf.text(110, 142, 'Blue') # --- GRAY ------------------------------------------------ pdf.set_draw_color(191) pdf.set_fill_color(127) pdf.set_text_color(127) pdf.rect(30, 160, 30, 30, 'DF', border_style) pdf.text(30, 192, 'Gray') # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example023_controller.rb 0000664 0000000 0000000 00000005755 12623665124 0025265 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-03-04 # Last Update : 2010-05-20 # # Description : Example 023 for RBPDF class # Page Groups # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example023Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 023') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 023', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('times', 'BI', 14) # Start First Page Group pdf.start_page_group() # add a page pdf.add_page() # set some text to print txt = <"application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example024_controller.rb 0000664 0000000 0000000 00000006370 12623665124 0025260 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-03-04 # Last Update : 2010-05-20 # # Description : Example 024 for RBPDF class # Object Visibility # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example024Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 024') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 024', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('times', '', 18) # add a page pdf.add_page() # # set_visibility() allows to restrict the rendering of some # elements to screen or printout. This can be useful, for # instance, to put a background image or color that will # show on screen but won't print. # txt = 'You can limit the visibility of PDF objects to screen or printer by using the set_visibility() method. Check the print preview of this document to display the alternative text.' pdf.write(0, txt, '', 0, '', true, 0, false, false, 0) # change font size pdf.set_font_size(40) # change text color pdf.set_text_color(0,63,127) # set visibility only for screen pdf.set_visibility('screen') # write something only for screen pdf.write(0, '[This line is for display]', '', 0, 'C', true, 0, false, false, 0) # set visibility only for print pdf.set_visibility('print') # change text color pdf.set_text_color(127,0,0) # write something only for print pdf.write(0, '[This line is for printout]', '', 0, 'C', true, 0, false, false, 0) # restore visibility pdf.set_visibility('all') # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example025_controller.rb 0000664 0000000 0000000 00000006172 12623665124 0025261 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-03-04 # Last Update : 2010-05-20 # # Description : Example 025 for RBPDF class # Object Transparency # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example025Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 025') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 025', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('helvetica', '', 12) # add a page pdf.add_page() txt = 'You can set the transparency of PDF objects using the set_alpha() method.' pdf.write(0, txt, '', 0, '', true, 0, false, false, 0) # # set_alpha() gives transparency support. You can set the # alpha channel from 0 (fully transparent) to 1 (fully # opaque). It applies to all elements (text, drawings, images). # pdf.set_line_width(2) # draw opaque red square pdf.set_fill_color(255, 0, 0) pdf.set_draw_color(127, 0, 0) pdf.rect(30, 40, 60, 60, 'DF') # set alpha to semi-transparency pdf.set_alpha(0.5) # draw green square pdf.set_fill_color(0, 255, 0) pdf.set_draw_color(0, 127, 0) pdf.rect(50, 60, 60, 60, 'DF') # draw blue square pdf.set_fill_color(0, 0, 255) pdf.set_draw_color(0, 0, 127) pdf.rect(70, 80, 60, 60, 'DF') # draw jpeg image pdf.image('' + Rails.root.to_s + '/public/image_demo.png', 90, 100, 60, 60, '', 'https://github.com/naitoh/rbpdf', '', true, 72) # restore full opacity pdf.set_alpha(1) # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example026_controller.rb 0000664 0000000 0000000 00000011701 12623665124 0025254 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-03-04 # Last Update : 2010-05-20 # # Description : Example 026 for RBPDF class # Text Rendering Modes and Text Clipping # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example026Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 026') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 026', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('helvetica', '', 22) # add a page pdf.add_page() # set color for text stroke pdf.set_draw_color(255,0,0) pdf.set_text_rendering_mode(stroke=0, fill=true, clip=false) pdf.write(0, 'Fill text', '', 0, '', true, 0, false, false, 0) pdf.set_text_rendering_mode(stroke=0.2, fill=false, clip=false) pdf.write(0, 'Stroke text', '', 0, '', true, 0, false, false, 0) pdf.set_text_rendering_mode(stroke=0.2, fill=true, clip=false) pdf.write(0, 'Fill, then stroke text', '', 0, '', true, 0, false, false, 0) pdf.set_text_rendering_mode(stroke=0, fill=false, clip=false) pdf.write(0, 'Neither fill nor stroke text (invisible)', '', 0, '', true, 0, false, false, 0) # * * * CLIPPING MODES * * * * * * * * * * * * * * * * * * pdf.start_transform() pdf.set_text_rendering_mode(stroke=0, fill=true, clip=true) pdf.write(0, 'Fill text and add to path for clipping', '', 0, '', true, 0, false, false, 0) pdf.image('' + Rails.root.to_s + '/public/image_demo.png', 15, 65, 170, 10, '', '', '', true, 72) pdf.stop_transform() pdf.start_transform() pdf.set_text_rendering_mode(stroke=0.3, fill=false, clip=true) pdf.write(0, 'Stroke text and add to path for clipping', '', 0, '', true, 0, false, false, 0) pdf.image('' + Rails.root.to_s + '/public/image_demo.png', 15, 75, 170, 10, '', '', '', true, 72) pdf.stop_transform() pdf.start_transform() pdf.set_text_rendering_mode(stroke=0.3, fill=true, clip=true) pdf.write(0, 'Fill, then stroke text and add to path for clipping', '', 0, '', true, 0, false, false, 0) pdf.image('' + Rails.root.to_s + '/public/image_demo.png', 15, 85, 170, 10, '', '', '', true, 72) pdf.stop_transform() pdf.start_transform() pdf.set_text_rendering_mode(stroke=0, fill=false, clip=true) pdf.write(0, 'Add text to path for clipping', '', 0, '', true, 0, false, false, 0) pdf.image('' + Rails.root.to_s + '/public/image_demo.png', 15, 95, 170, 10, '', '', '', true, 72) pdf.stop_transform() # reset text rendering mode pdf.set_text_rendering_mode(stroke=0, fill=true, clip=false) # * * * HTML MODE * * * * * * * * * * * * * * * * * * * * * # The following attributes were added to HTML: # stroke : stroke width # strokecolor : stroke color # fill : true (default) to fill the font, false otherwise # create some HTML content with text rendering modes html = 'HTML Fill text
' html << 'HTML Stroke text
' html << 'HTML Fill, then stroke text
' html << 'HTML Neither fill nor stroke text (invisible)
' # output the HTML content pdf.write_html(html, true, 0, true, 0) # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example028_controller.rb 0000664 0000000 0000000 00000006341 12623665124 0025262 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-03-04 # Last Update : 2010-05-20 # # Description : Example 028 for RBPDF class # Changing page formats # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example028Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 028') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # remove default header/footer pdf.set_print_header(false) pdf.set_print_footer(false) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(10, PDF_MARGIN_TOP, 10) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- pdf.set_display_mode('fullpage', 'SinglePage', 'UseNone') # set font pdf.set_font('times', 'B', 20) pdf.add_page('P', 'A4') pdf.cell(0, 0, 'A4 PORTRAIT', 1, 1, 'C') pdf.add_page('L', 'A4') pdf.cell(0, 0, 'A4 LANDSCAPE', 1, 1, 'C') pdf.add_page('P', 'A5') pdf.cell(0, 0, 'A5 PORTRAIT', 1, 1, 'C') pdf.add_page('L', 'A5') pdf.cell(0, 0, 'A5 LANDSCAPE', 1, 1, 'C') pdf.add_page('P', 'A6') pdf.cell(0, 0, 'A6 PORTRAIT', 1, 1, 'C') pdf.add_page('L', 'A6') pdf.cell(0, 0, 'A6 LANDSCAPE', 1, 1, 'C') pdf.add_page('P', 'A7') pdf.cell(0, 0, 'A7 PORTRAIT', 1, 1, 'C') pdf.add_page('L', 'A7') pdf.cell(0, 0, 'A7 LANDSCAPE', 1, 1, 'C') # --- test backward editing --- pdf.set_page(1, true) pdf.set_y(50) pdf.cell(0, 0, 'A4 test', 1, 1, 'C') pdf.set_page(2, true) pdf.set_y(50) pdf.cell(0, 0, 'A4 test', 1, 1, 'C') pdf.set_page(3, true) pdf.set_y(50) pdf.cell(0, 0, 'A5 test', 1, 1, 'C') pdf.set_page(4, true) pdf.set_y(50) pdf.cell(0, 0, 'A5 test', 1, 1, 'C') pdf.set_page(5, true) pdf.set_y(50) pdf.cell(0, 0, 'A6 test', 1, 1, 'C') pdf.set_page(6, true) pdf.set_y(50) pdf.cell(0, 0, 'A6 test', 1, 1, 'C') pdf.set_page(7, true) pdf.set_y(40) pdf.cell(0, 0, 'A7 test', 1, 1, 'C') pdf.set_page(8, true) pdf.set_y(40) pdf.cell(0, 0, 'A7 test', 1, 1, 'C') pdf.last_page() # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example029_controller.rb 0000664 0000000 0000000 00000007124 12623665124 0025263 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-06-09 # Last Update : 2010-05-20 # # Description : Example 029 for RBPDF class # Set PDF viewer display preferences. # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example029Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 029') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 029', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set array for viewer preferences preferences = { 'HideToolbar' => true, 'HideMenubar' => true, 'HideWindowUI' => true, 'FitWindow' => true, 'CenterWindow' => true, 'DisplayDocTitle' => true, 'NonFullScreenPageMode' => 'UseNone', # UseNone, UseOutlines, UseThumbs, UseOC 'ViewArea' => 'CropBox', # CropBox, BleedBox, TrimBox, ArtBox 'ViewClip' => 'CropBox', # CropBox, BleedBox, TrimBox, ArtBox 'PrintArea' => 'CropBox', # CropBox, BleedBox, TrimBox, ArtBox 'PrintClip' => 'CropBox', # CropBox, BleedBox, TrimBox, ArtBox 'PrintScaling' => 'AppDefault', # None, AppDefault 'Duplex' => 'DuplexFlipLongEdge', # Simplex, DuplexFlipShortEdge, DuplexFlipLongEdge 'PickTrayByPDFSize' => true, 'PrintPageRange' => [1,1,2,3], 'NumCopies' => 2 } # Check the example n. 60 for advanced page settings # set pdf viewer preferences pdf.set_viewer_preferences(preferences) # set font pdf.set_font('times', '', 14) # add a page pdf.add_page() # print a line pdf.cell(0, 12, 'DISPLAY PREFERENCES - PAGE 1', 1, 1, 'C') pdf.ln(5) pdf.write(0, 'You can use the set_viewer_preferences() method to change viewer preferences.', '', 0, 'L', true, 0, false, false, 0) # add a page pdf.add_page() # print a line pdf.cell(0, 12, 'DISPLAY PREFERENCES - PAGE 2', 0, 0, 'C') # add a page pdf.add_page() # print a line pdf.cell(0, 12, 'DISPLAY PREFERENCES - PAGE 3', 0, 0, 'C') # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example031_controller.rb 0000664 0000000 0000000 00000005144 12623665124 0025254 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-06-09 # Last Update : 2010-05-20 # # Description : Example 031 for RBPDF class # Pie Chart # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example031Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 031') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 031', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('helvetica', 'B', 20) # add a page pdf.add_page() pdf.write(0, 'Example of pie_sector() method.') xc = 105 yc = 100 r = 50 pdf.set_fill_color(0, 0, 255) pdf.pie_sector(xc, yc, r, 20, 120, 'FD', false, 0) pdf.set_fill_color(0, 255, 0) pdf.pie_sector(xc, yc, r, 120, 250, 'FD', false, 0) pdf.set_fill_color(255, 0, 0) pdf.pie_sector(xc, yc, r, 250, 20, 'FD', false, 0) # write labels pdf.set_text_color(255,255,255) pdf.text(105, 65, 'BLUE') pdf.text(60, 95, 'GREEN') pdf.text(120, 115, 'RED') # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example033_controller.rb 0000664 0000000 0000000 00000007507 12623665124 0025263 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-06-24 # Last Update : 2010-05-20 # # Description : Example 033 for RBPDF class # Mixed font types # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example033Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 033') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 033', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # add a page pdf.add_page() pdf.set_font('helvetica', 'B', 20) pdf.write(0, 'Font Types', '', 0, 'C', 1, 0, false, false, 0) pdf.ln(10) pdf.set_font('times', '', 10) pdf.multi_cell(80, 0, "[Core font] : Cras eros leo, porttitor porta, accumsan fermentum, ornare ac, est. Praesent dui lorem, imperdiet at, cursus sed, facilisis aliquam, nibh. Nulla accumsan nonummy diam. Donec tempus. Etiam posuere. Proin lectus. Donec purus. Duis in sem pretium urna feugiat vehicula. Ut suscipit velit eget massa. Nam nonummy, enim commodo euismod placerat, tortor elit tempus lectus, quis suscipit metus lorem blandit turpis.\n", 1, 'J', 0, 1, '', '', true, 0) pdf.ln(2) pdf.set_font('dejavusans', '', 10) pdf.multi_cell(80, 0, "[True Type Unicode font] : Cras eros leo, porttitor porta, accumsan fermentum, ornare ac, est. Praesent dui lorem, imperdiet at, cursus sed, facilisis aliquam, nibh. Nulla accumsan nonummy diam. Donec tempus. Etiam posuere. Proin lectus. Donec purus. Duis in sem pretium urna feugiat vehicula. Ut suscipit velit eget massa. Nam nonummy, enim commodo euismod placerat, tortor elit tempus lectus, quis suscipit metus lorem blandit turpis.\n", 1, 'J', 0, 1, '', '', true, 0) pdf.ln(2) pdf.set_font('cid0jp', '', 9) pdf.multi_cell(80, 0, "[CID-0 font] : Cras eros leo, porttitor porta, accumsan fermentum, ornare ac, est. Praesent dui lorem, imperdiet at, cursus sed, facilisis aliquam, nibh. Nulla accumsan nonummy diam. Donec tempus. Etiam posuere. Proin lectus. Donec purus. Duis in sem pretium urna feugiat vehicula. Ut suscipit velit eget massa. Nam nonummy, enim commodo euismod placerat, tortor elit tempus lectus, quis suscipit metus lorem blandit turpis.\n", 1, 'J', 0, 1, '', '', true, 0) # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example034_controller.rb 0000664 0000000 0000000 00000005153 12623665124 0025257 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-07-18 # Last Update : 2010-05-20 # # Description : Example 034 for RBPDF class # Clipping # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example034Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 034') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 034', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('helvetica', 'B', 20) # add a page pdf.add_page() pdf.write(0, 'Image Clipping using geometric functions', '', 0, 'C', 1, 0, false, false, 0) # Start Graphic Transformation pdf.start_transform() # set clipping mask pdf.star_polygon(105, 100, 30, 10, 3, 0, 1, 'CNZ') # draw jpeg image to be clipped pdf.image('' + Rails.root.to_s + '/public/image_demo.jpg', 75, 70, 60, 60, '', 'https://github.com/naitoh/rbpdf', '', true, 72) # Stop Graphic Transformation pdf.stop_transform() # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example035_controller.rb 0000664 0000000 0000000 00000006333 12623665124 0025261 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-07-22 # Last Update : 2010-05-20 # # Description : Example 035 for RBPDF class # Line styles with cells and multicells # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example035Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 035') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 035', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('times', 'BI', 16) # add a page pdf.add_page() pdf.write(0, 'Example of set_line_style() method', '', 0, 'L', true, 0, false, false, 0) pdf.ln() pdf.set_line_style({'width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 4, 'color' => [255, 0, 0]}) pdf.set_fill_color(255,255,128) pdf.set_text_color(0,0,128) text="DUMMY" pdf.cell(0, 0, text, 1, 1, 'L', 1, 0) pdf.ln() pdf.set_line_style({'width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => [0, 0, 255]}) pdf.set_fill_color(255,255,0) pdf.set_text_color(0,0,255) pdf.multi_cell(60, 4, text, 1, 'C', 1, 0) pdf.set_line_style({'width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => [255, 255, 0]}) pdf.set_fill_color(0,0,255) pdf.set_text_color(255,255,0) pdf.multi_cell(60, 4, text, 'TB', 'C', 1, 0) pdf.set_line_style({'width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => [255, 0, 255]}) pdf.set_fill_color(0,255,0) pdf.set_text_color(255,0,255) pdf.multi_cell(60, 4, text, 1, 'C', 1, 1) # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example036_controller.rb 0000664 0000000 0000000 00000005057 12623665124 0025264 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-08-08 # Last Update : 2010-05-20 # # Description : Example 036 for RBPDF class # Annotations # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example036Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 036') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 036', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('times', '', 16) # add a page pdf.add_page() txt = 'Example of Text Annotation. Move your mouse over the yellow box or double click on it to display the annotation text.' pdf.write(0, txt, '', 0, 'L', true, 0, false, false, 0) # text annotation pdf.annotation(83, 27, 10, 10, "Text annotation example\naccented letters test: àèéìòù", {'Subtype'=>'Text', 'Name' => 'Comment', 'T' => 'title example', 'Subj' => 'example', 'C' => [255, 255, 0]}) # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example038_controller.rb 0000664 0000000 0000000 00000004540 12623665124 0025262 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-09-15 # Last Update : 2010-05-20 # # Description : Example 038 for RBPDF class # CID-0 CJK unembedded font # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example038Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 038') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 038', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('cid0jp', '', 20) # add a page pdf.add_page() txt = 'Example of CID-0 CJK unembedded font. To display extended text you must have CJK fonts for your PDF reader: こんにちは世界' pdf.write(0, txt, '', 0, 'L', true, 0, false, false, 0) # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example039_controller.rb 0000664 0000000 0000000 00000007540 12623665124 0025266 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-10-16 # Last Update : 2010-05-20 # # Description : Example 039 for RBPDF class # HTML justification # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example039Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 039') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 039', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # add a page pdf.add_page() # set font pdf.set_font('helvetica', 'B', 20) pdf.write(0, 'Example of HTML Justification', '', 0, 'L', true, 0, false, false, 0) # create some HTML content html = 'a abc abcdefghijkl abcdef abcdefg abcdefghi a abc abcd![]()
abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg start a abc before yellow color after a abc abcd abcdef abcdefg abcdefghi a abc abcd end abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi
abcd abcdef abcdefg abcdefghi
abcd abcde abcdef' # set core font pdf.set_font('helvetica', '', 10) # output the HTML content pdf.write_html(html, true, 0, true, true) pdf.ln() # set UTF-8 Unicode font pdf.set_font('dejavusans', '', 10) # output the HTML content pdf.write_html(html, true, 0, true, true) # reset pointer to the last page pdf.last_page() # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example040_controller.rb 0000664 0000000 0000000 00000006012 12623665124 0025247 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-10-28 # Last Update : 2010-05-20 # # Description : Example 040 for RBPDF class # Booklet mode (double-sided pages) # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example040Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 040') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 040', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set display mode pdf.set_display_mode(zoom='fullpage', layout='TwoColumnRight', mode='UseNone') # set pdf viewer preferences pdf.set_viewer_preferences({'Duplex' => 'DuplexFlipLongEdge'}) # set booklet mode pdf.set_booklet(true, 10, 30) # set core font pdf.set_font('helvetica', '', 18) # add a page (left page) pdf.add_page() pdf.write(0, 'Example of booklet mode', '', 0, 'L', true, 0, false, false, 0) # print a line using cell() pdf.cell(0, 0, 'LEFT PAGE 1', 1, 1, 'C') # add a page (right page) pdf.add_page() # print a line using cell() pdf.cell(0, 0, 'RIGHT PAGE 2', 1, 1, 'C') # add a page (left page) pdf.add_page() # print a line using cell() pdf.cell(0, 0, 'LEFT PAGE 3', 1, 1, 'C') # add a page (right page) pdf.add_page() # print a line using cell() pdf.cell(0, 0, 'RIGHT PAGE 4', 1, 1, 'C') # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example041_controller.rb 0000664 0000000 0000000 00000004763 12623665124 0025263 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-12-07 # Last Update : 2010-05-20 # # Description : Example 041 for RBPDF class # Annotation - FileAttachment # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example041Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 041') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 041', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('times', '', 16) # add a page pdf.add_page() txt = 'Example of File Attachment. Double click on the icon to open the attached file.' pdf.write(0, txt, '', 0, 'L', true, 0, false, false, 0) # attach an external file pdf.annotation(85, 27, 5, 5, 'text file', {'Subtype'=>'FileAttachment', 'Name' => 'PushPin', 'FS' => "#{File.join(Rails.root, 'public')}/utf8test.txt"}) # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example042_controller.rb 0000664 0000000 0000000 00000006330 12623665124 0025254 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-12-23 # Last Update : 2010-05-20 # # Description : Example 042 for RBPDF class # Test Image with alpha channel # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example042Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 042') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 042', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set JPEG quality #pdf.set_jpeg_quality(75) pdf.set_font('helvetica', '', 18) # add a page pdf.add_page() # create background text background_text = 'RBPDF test PNG Alpha Channel ' * 50 pdf.multi_cell(0, 5, background_text, 0, 'J', 0, 2, '', '', true, 0, false) # --- Method (A) ------------------------------------------ # the image() method recognizes the alpha channel embedded on the image: pdf.image('' + Rails.root.to_s + '/public/png_test_alpha.png', 50, 50, 100, '', '', 'https://github.com/naitoh/rbpdf', '', false, 300) # --- Method (B) ------------------------------------------ # provide image + separate 8-bit mask # first embed mask image (w, h, x and y will be ignored, the image will be scaled to the target image's size) mask = pdf.image('' + Rails.root.to_s + '/public/png_test_msk_alpha.png', 50, 140, 100, '', '', '', '', false, 300, '', true) # embed image, masked with previously embedded mask pdf.image('' + Rails.root.to_s + '/public/png_test_non_alpha.png', 50, 140, 100, '', '', 'https://github.com/naitoh/rbpdf', '', false, 300, '', false, mask) # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example043_controller.rb 0000664 0000000 0000000 00000004425 12623665124 0025260 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2009-01-02 # Last Update : 2010-05-20 # # Description : Example 043 for RBPDF class # Disk caching # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example043Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', true) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 043') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 043', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('helvetica', '', 16) # add a page pdf.add_page() # Multicell test pdf.multi_cell(0, 0, 'DISK CACHING TEST: check the parameters of the class constructor.', 1, 'L', 0, 0, '', '', true) # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example044_controller.rb 0000664 0000000 0000000 00000006350 12623665124 0025260 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2009-01-02 # Last Update : 2010-05-20 # # Description : Example 044 for RBPDF class # Move, copy and delete pages # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example044Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 044') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 044', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('helvetica', 'B', 40) # print a line using cell() pdf.add_page() pdf.cell(0, 10, 'PAGE: A', 0, 1, 'L') # add some vertical space pdf.ln(10) # print some text pdf.set_font('times', 'I', 16) txt = 'RBPDF allows you to Move and Delete pages.' pdf.write(0, txt, '', 0, 'L', true, 0, false, false, 0) pdf.set_font('helvetica', 'B', 40) pdf.add_page() pdf.cell(0, 10, 'PAGE: B', 0, 1, 'L') pdf.add_page() pdf.cell(0, 10, 'PAGE: D', 0, 1, 'L') pdf.add_page() pdf.cell(0, 10, 'PAGE: E', 0, 1, 'L') pdf.add_page() pdf.cell(0, 10, 'PAGE: E-2', 0, 1, 'L') pdf.add_page() pdf.cell(0, 10, 'PAGE: F', 0, 1, 'L') pdf.add_page() pdf.cell(0, 10, 'PAGE: C', 0, 1, 'L') pdf.add_page() pdf.cell(0, 10, 'PAGE: G', 0, 1, 'L') # Move page 7 to page 3 pdf.move_page(7, 3) # Delete page 6 pdf.delete_page(6) pdf.add_page() pdf.cell(0, 10, 'PAGE: H', 0, 1, 'L') # copy the second page # pdf.copy_page(2) # NOTE: to insert a page to a previous position, you can add a new page to the end of document and then move it using move_page(). # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example045_controller.rb 0000664 0000000 0000000 00000006722 12623665124 0025264 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2008-03-04 # Last Update : 2010-05-20 # # Description : Example 045 for RBPDF class # Bookmarks and Table of Content # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example045Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 045') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 045', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('times', 'B', 20) # add a page pdf.add_page() # set a bookmark for the current position pdf.bookmark('Chapter 1', 0, 0) # print a line using cell() pdf.cell(0, 10, 'Chapter 1', 0, 1, 'L') pdf.add_page() pdf.bookmark('Paragraph 1.1', 1, 0) pdf.cell(0, 10, 'Paragraph 1.1', 0, 1, 'L') pdf.add_page() pdf.bookmark('Paragraph 1.2', 1, 0) pdf.cell(0, 10, 'Paragraph 1.2', 0, 1, 'L') pdf.add_page() pdf.bookmark('Sub-Paragraph 1.2.1', 2, 0) pdf.cell(0, 10, 'Sub-Paragraph 1.2.1', 0, 1, 'L') pdf.add_page() pdf.bookmark('Paragraph 1.3', 1, 0) pdf.cell(0, 10, 'Paragraph 1.3', 0, 1, 'L') # add some pages and bookmarks 2.upto(11) { |i| pdf.add_page() pdf.bookmark('Chapter ' + i.to_s, 0, 0) pdf.cell(0, 10, 'Chapter ' + i.to_s, 0, 1, 'L') } # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . # add a new page for TOC pdf.add_toc_page() # write the TOC title pdf.set_font('times', 'B', 16) pdf.multi_cell(0, 0, 'Table Of Content', 0, 'C', 0, 1, '', '', true, 0) pdf.ln() pdf.set_font('dejavusans', '', 12) # add a simple Table Of Content at first page # (check the example n. 59 for the HTML version) pdf.add_toc(1, 'courier', '.', 'INDEX') # end of TOC page pdf.end_toc_page() # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example047_controller.rb 0000664 0000000 0000000 00000005712 12623665124 0025264 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2009-03-19 # Last Update : 2010-05-20 # # Description : Example 047 for RBPDF class # Transactions # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example047Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 047') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 047', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('helvetica', '', 16) # add a page pdf.add_page() txt = 'Example of Transactions. RBPDF allows you to undo some operations using the Transactions. Check the source code for further information.' pdf.write(0, txt, '', 0, 'L', true, 0, false, false, 0) pdf.ln(5) pdf.set_font('times', '', 12) # start transaction pdf.start_transaction() pdf.write(0, "LINE 1\n") pdf.write(0, "LINE 2\n") # restarts transaction pdf.start_transaction() pdf.write(0, "LINE 3\n") pdf.write(0, "LINE 4\n") # rolls back to the last (re)start pdf = pdf.rollback_transaction() pdf.write(0, "LINE 5\n") pdf.write(0, "LINE 6\n") # start transaction pdf.start_transaction() pdf.write(0, "LINE 7\n") # commit transaction (actually just frees memory) pdf.commit_transaction(); # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example048_controller.rb 0000664 0000000 0000000 00000022136 12623665124 0025264 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2009-03-20 # Last Update : 2010-05-20 # # Description : Example 048 for RBPDF class # HTML tables and table headers # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example048Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 048') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 048', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('helvetica', 'B', 20) # add a page pdf.add_page() pdf.write(0, 'Example of HTML tables', '', 0, 'L', true, 0, false, false, 0) pdf.set_font('helvetica', '', 8) # ----------------------------------------------------------------------------- tbl = <COL 1 - ROW 1
COLSPAN 3COL 2 - ROW 1 COL 3 - ROW 1 COL 2 - ROW 2 - COLSPAN 2
text line
text line
text line
text lineCOL 3 - ROW 2 EOD pdf.write_html(tbl, true, false, false, false, '') # ----------------------------------------------------------------------------- tbl = < COL 3 - ROW 3 COL 1 - ROW 1
COLSPAN 3
text line
text line
text line
text line
text line
text lineCOL 2 - ROW 1 COL 3 - ROW 1 COL 2 - ROW 2 - COLSPAN 2
text line
text line
text line
text lineCOL 3 - ROW 2 EOD pdf.write_html(tbl, true, false, false, false, '') # ----------------------------------------------------------------------------- tbl = < COL 3 - ROW 3 COL 1 - ROW 1
COLSPAN 3
text line
text line
text line
text line
text line
text lineCOL 2 - ROW 1 COL 3 - ROW 1 COL 2 - ROW 2 - COLSPAN 2
text line
text line
text line
text lineCOL 3 - ROW 2
text line
text lineEOD pdf.write_html(tbl, true, false, false, false, '') # ----------------------------------------------------------------------------- tbl = < COL 3 - ROW 3 Left column Heading Column Span 5 Heading Column Span 9 Rowspan 2
This is some text that fills the table cell.span 2 span 2 2 rows Colspan 8 EOD pdf.write_html(tbl, true, false, false, false, '') # ----------------------------------------------------------------------------- # Table with rowspans and THEAD tbl = < 1a 2a 1b 2b 1 2 3 4 5 6 7 8 A XXXX XXXX XXXX XXXX XXXX B XXXX XXXX XXXX XXXX XXXX 1. XXXX
XXXX
XXXX
XXXX
XXXX
XXXX
XXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX XXXX
XXXX2. XXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX
XXXX
XXXX
XXXXXXXX
XXXXXXXX
XXXXRRRRRR
XXXX
XXXX
XXXX
XXXX
XXXX
XXXX
XXXXXXXX
XXXXXXXX
XXXX3. XXXX1
XXXXXXXX
XXXXXXXX
XXXXEOD pdf.write_html(tbl, true, false, false, false, '') pdf.write_html(tbl, true, false, false, false, '') # ----------------------------------------------------------------------------- # NON-BREAKING TABLE (nobr="true") tbl = < 4. XXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX
XXXXNON-BREAKING TABLE 1-1 1-2 1-3 2-1 3-2 3-3 EOD pdf.write_html(tbl, true, false, false, false, '') # ----------------------------------------------------------------------------- # NON-BREAKING ROWS (nobr="true") tbl = < 3-1 3-2 3-3 NON-BREAKING ROWS ROW 1
COLUMN 1ROW 1
COLUMN 2ROW 1
COLUMN 3ROW 2
COLUMN 1ROW 2
COLUMN 2ROW 2
COLUMN 3EOD pdf.write_html(tbl, true, false, false, false, '') # ----------------------------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example051_controller.rb 0000664 0000000 0000000 00000006053 12623665124 0025256 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2009-04-16 # Last Update : 2010-05-20 # # Description : Example 051 for RBPDF class # Full page background # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example051Controller < ApplicationController # Extend the RBPDF class to create custom Header and Footer class MYPDF < RBPDF # Page header def Header() # full background image # store current auto-page-break status bMargin = get_break_margin() auto_page_break = @auto_page_break set_auto_page_break(false, 0) img_file = "#{File.join(Rails.root, 'public')}/image_demo.png" image(img_file, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0) # restore auto-page-break status set_auto_page_break(auto_page_break, bMargin) end end def index # create new PDF document pdf = MYPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 051') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(0) pdf.set_footer_margin(0) # remove default footer pdf.set_print_footer(false) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('times', '', 48) # add a page pdf.add_page() # Print a text html = ' PAGE 1 ROW 3
COLUMN 1ROW 3
COLUMN 2ROW 3
COLUMN 3You can set a full page background.
' pdf.write_html(html, true, false, true, false, '') # add a page pdf.add_page() # Print a text html = ' PAGE 2 ' pdf.write_html(html, true, false, true, false, '') # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example055_controller.rb 0000664 0000000 0000000 00000006313 12623665124 0025261 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2009-10-21 # Last Update : 2010-05-20 # # Description : Example 055 for RBPDF class # Display all characters available on core fonts. # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example055Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 055') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 055', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('helvetica', '', 10) # add a page pdf.add_page() # array of core font names core_fonts = ['courier', 'helvetica', 'times', 'symbol', 'zapfdingbats'] html = 'Core Fonts Dump
' # create one HTML table for each core font core_fonts.each { |font| # create HTML content html << '' html << '
' + font.upcase + ' ' # print each character 256.times do |i| if (i > 0) and (i % 16 == 0) html << ' ' end if i != 0 chr = pdf.unichr(i) else chr = '' end # replace special characters chr.gsub!('<', '<') chr.gsub!('>', '>') html << ' ' + chr + ' ' end html << '
' } # output the HTML content pdf.write_html(html, true, false, true, false, '') # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example057_controller.rb 0000664 0000000 0000000 00000010515 12623665124 0025262 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2010-04-03 # Last Update : 2010-05-20 # # Description : Example 057 for RBPDF class # Cell vertical alignments # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example057Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 057') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 057', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('helvetica', 'B', 20) # add a page pdf.add_page() pdf.write(0, 'Example of alignment options for cell()', '', 0, 'L', true, 0, false, false, 0) pdf.set_font('helvetica', '', 11) # set border width pdf.set_line_width(0.7) # set color for cell border pdf.set_draw_color(0,128,255) pdf.set_cell_height_ratio(3) pdf.set_xy(15, 60) # text on center pdf.cell(30, 0, 'Top-Center', 1, ln=0, 'C', 0, '', 0, false, 'T', 'C') pdf.cell(30, 0, 'Center-Center', 1, ln=0, 'C', 0, '', 0, false, 'C', 'C') pdf.cell(30, 0, 'Bottom-Center', 1, ln=0, 'C', 0, '', 0, false, 'B', 'C') pdf.cell(30, 0, 'Ascent-Center', 1, ln=0, 'C', 0, '', 0, false, 'A', 'C') pdf.cell(30, 0, 'Baseline-Center', 1, ln=0, 'C', 0, '', 0, false, 'L', 'C') pdf.cell(30, 0, 'Descent-Center', 1, ln=0, 'C', 0, '', 0, false, 'D', 'C') pdf.set_xy(15, 90) # text on top pdf.cell(30, 0, 'Top-Top', 1, ln=0, 'C', 0, '', 0, false, 'T', 'T') pdf.cell(30, 0, 'Center-Top', 1, ln=0, 'C', 0, '', 0, false, 'C', 'T') pdf.cell(30, 0, 'Bottom-Top', 1, ln=0, 'C', 0, '', 0, false, 'B', 'T') pdf.cell(30, 0, 'Ascent-Top', 1, ln=0, 'C', 0, '', 0, false, 'A', 'T') pdf.cell(30, 0, 'Baseline-Top', 1, ln=0, 'C', 0, '', 0, false, 'L', 'T') pdf.cell(30, 0, 'Descent-Top', 1, ln=0, 'C', 0, '', 0, false, 'D', 'T') pdf.set_xy(15, 120) # text on bottom pdf.cell(30, 0, 'Top-Bottom', 1, ln=0, 'C', 0, '', 0, false, 'T', 'B') pdf.cell(30, 0, 'Center-Bottom', 1, ln=0, 'C', 0, '', 0, false, 'C', 'B') pdf.cell(30, 0, 'Bottom-Bottom', 1, ln=0, 'C', 0, '', 0, false, 'B', 'B') pdf.cell(30, 0, 'Ascent-Bottom', 1, ln=0, 'C', 0, '', 0, false, 'A', 'B') pdf.cell(30, 0, 'Baseline-Bottom', 1, ln=0, 'C', 0, '', 0, false, 'L', 'B') pdf.cell(30, 0, 'Descent-Bottom', 1, ln=0, 'C', 0, '', 0, false, 'D', 'B') # draw some reference lines linestyle = {'width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => [255, 0, 0]} pdf.line(15, 60, 195, 60, linestyle) pdf.line(15, 90, 195, 90, linestyle) pdf.line(15, 120, 195, 120, linestyle) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # reset pointer to the last page pdf.last_page() # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example059_controller.rb 0000664 0000000 0000000 00000014233 12623665124 0025265 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2010-05-06 # Last Update : 2010-05-20 # # Description : Example 059 for RBPDF class # Table Of Content using HTML templates. # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example059Controller < ApplicationController class TOC_RBPDF < RBPDF # # Overwrite Header() method. # @access public # def Header() if @tocpage # *** replace the following super() with your code for TOC page super() else # *** replace the following super() with your code for normal pages super() end end # # Overwrite Footer() method. # @access public # def Footer() if @tocpage # *** replace the following super() with your code for TOC page super() else # *** replace the following super() with your code for normal pages super() end end end # end of class def index # create new PDF document pdf = TOC_RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 059') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 059', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # set font pdf.set_font('helvetica', '', 10) # --------------------------------------------------------- # create some content ... # add a page pdf.add_page() # set a bookmark for the current position pdf.bookmark('Chapter 1', 0, 0) # print a line using cell() pdf.cell(0, 10, 'Chapter 1', 0, 1, 'L') pdf.add_page() pdf.bookmark('Paragraph 1.1', 1, 0) pdf.cell(0, 10, 'Paragraph 1.1', 0, 1, 'L') pdf.add_page() pdf.bookmark('Paragraph 1.2', 1, 0) pdf.cell(0, 10, 'Paragraph 1.2', 0, 1, 'L') pdf.add_page() pdf.bookmark('Sub-Paragraph 1.2.1', 2, 0) pdf.cell(0, 10, 'Sub-Paragraph 1.2.1', 0, 1, 'L') pdf.add_page() pdf.bookmark('Paragraph 1.3', 1, 0) pdf.cell(0, 10, 'Paragraph 1.3', 0, 1, 'L') 2.upto(11) do |i| pdf.add_page() pdf.bookmark('Chapter ' + i.to_s, 0, 0) pdf.cell(0, 10, 'Chapter ' + i.to_s, 0, 1, 'L') end # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . # add a new page for TOC pdf.add_toc_page() # write the TOC title and/or other elements on the TOC page pdf.set_font('times', 'B', 16) pdf.multi_cell(0, 0, 'Table Of Content', 0, 'C', 0, 1, '', '', true, 0) pdf.ln() pdf.set_font('helvetica', '', 10) # define styles for various bookmark levels bookmark_templates = [] # # The key of the bookmark_templates array represent the bookmark level (from 0 to n). # The following templates will be replaced with proper content: # #TOC_DESCRIPTION# this will be replaced with the bookmark description; # #TOC_PAGE_NUMBER# this will be replaced with page number. # # NOTES: # If you want to align the page number on the right you have to use a monospaced font like courier, otherwise you can left align using any font type. # The following is just an example, you can get various styles by combining various HTML elements. # # A monospaced font for the page number is mandatory to get the right alignment bookmark_templates[0] = '' bookmark_templates[1] = '
#TOC_DESCRIPTION# #TOC_PAGE_NUMBER# ' bookmark_templates[2] = '
#TOC_DESCRIPTION# #TOC_PAGE_NUMBER# ' # add other bookmark level templates here ... # add table of content at page 1 # (check the example n. 45 for a text-only TOC pdf.add_html_toc(page=1, toc_name='INDEX', bookmark_templates, correct_align=true) # end of TOC page pdf.end_toc_page() # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example060_controller.rb 0000664 0000000 0000000 00000005777 12623665124 0025272 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2010-05-17 # Last Update : 2010-05-20 # # Description : Example 060 for RBPDF class # Advanced page settings. # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example060Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 060') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 060', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # set font pdf.set_font('helvetica', '', 20) # --------------------------------------------------------- # set page format (read source code documentation for further information) page_format = { 'MediaBox' => {'llx' => 0, 'lly' => 0, 'urx' => 210, 'ury' => 297}, 'CropBox' => {'llx' => 0, 'lly' => 0, 'urx' => 210, 'ury' => 297}, 'BleedBox' => {'llx' => 5, 'lly' => 5, 'urx' => 205, 'ury' => 292}, 'TrimBox' => {'llx' => 10, 'lly' => 10, 'urx' => 200, 'ury' => 287}, 'ArtBox' => {'llx' => 15, 'lly' => 15, 'urx' => 195, 'ury' => 282}, 'Dur' => 3, 'trans' => { 'D' => 1.5, 'S' => 'Split', 'Dm' => 'V', 'M' => 'O' }, 'Rotate' => 90, 'PZ' => 1, } # Check the example n. 29 for viewer preferences # add first page --- pdf.add_page('P', page_format, false, false) pdf.cell(0, 12, 'First Page', 1, 1, 'C') # add second page --- page_format['Rotate'] = 270 pdf.add_page('P', page_format, false, false) pdf.cell(0, 12, 'Second Page', 1, 1, 'C') # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example061_controller.rb 0000664 0000000 0000000 00000012050 12623665124 0025251 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2010-05-24 # Last Update : 2010-05-25 # # Description : Example 061 for RBPDF class # XHTML + CSS # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ require("example_common.rb") class Example061Controller < ApplicationController def index # create new PDF document pdf = RBPDF.new(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false) # set document information pdf.set_creator(PDF_CREATOR) pdf.set_author(PDF_AUTHOR) pdf.set_title('RBPDF Example 061') pdf.set_subject('RBPDF Tutorial') pdf.set_keywords('RBPDF, PDF, example, test, guide') # set default header data pdf.set_header_data(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE + ' 061', PDF_HEADER_STRING) # set header and footer fonts pdf.set_header_font([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]) pdf.set_footer_font([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]) # set default monospaced font pdf.set_default_monospaced_font(PDF_FONT_MONOSPACED) # set margins pdf.set_margins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT) pdf.set_header_margin(PDF_MARGIN_HEADER) pdf.set_footer_margin(PDF_MARGIN_FOOTER) # set auto page breaks pdf.set_auto_page_break(TRUE, PDF_MARGIN_BOTTOM) # set image scale factor pdf.set_image_scale(PDF_IMAGE_SCALE_RATIO) # set some language-dependent strings pdf.set_language_array($l) # --------------------------------------------------------- # set font pdf.set_font('helvetica', '', 10) # add a page pdf.add_page() # NOTE: # ********************************************************* # You can load external XHTML using : # # html = '' # file = Rails.root.to_s + 'path/to/your/file.html' # open(file,'rb') do |f| # html << f.read() # end # # External CSS files will be automatically loaded. # Sometimes you need to fix the path of the external CSS. # ********************************************************* # define some HTML content with style html = <
#TOC_DESCRIPTION# #TOC_PAGE_NUMBER# Example of XHTML + CSS
Example of paragraph with class selector. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sed imperdiet lectus. Phasellus quis velit velit, non condimentum quam. Sed neque urna, ultrices ac volutpat vel, laoreet vitae augue. Sed vel velit erat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Cras eget velit nulla, eu sagittis elit. Nunc ac arcu est, in lobortis tellus. Praesent condimentum rhoncus sodales. In hac habitasse platea dictumst. Proin porta eros pharetra enim tincidunt dignissim nec vel dolor. Cras sapien elit, ornare ac dignissim eu, ultricies ac eros. Maecenas augue magna, ultrices a congue in, mollis eu nulla. Nunc venenatis massa at est eleifend faucibus. Vivamus sed risus lectus, nec interdum nunc.
Example of paragraph with ID selector. Fusce et felis vitae diam lobortis sollicitudin. Aenean tincidunt accumsan nisi, id vehicula quam laoreet elementum. Phasellus egestas interdum erat, et viverra ipsum ultricies ac. Praesent sagittis augue at augue volutpat eleifend. Cras nec orci neque. Mauris bibendum posuere blandit. Donec feugiat mollis dui sit amet pellentesque. Sed a enim justo. Donec tincidunt, nisl eget elementum aliquam, odio ipsum ultrices quam, eu porttitor ligula urna at lorem. Donec varius, eros et convallis laoreet, ligula tellus consequat felis, ut ornare metus tellus sodales velit. Duis sed diam ante. Ut rutrum malesuada massa, vitae consectetur ipsum rhoncus sed. Suspendisse potenti. Pellentesque a congue massa.
EOF # output the HTML content pdf.write_html(html, true, false, true, false, '') # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # reset pointer to the last page pdf.last_page() # --------------------------------------------------------- # Close and output PDF document send_data pdf.output(), :type => "application/pdf", :disposition => "inline" end end #============================================================+ # END OF FILE #============================================================+ rbpdf-1.19.0/example/rails/app/controllers/example_common.rb 0000664 0000000 0000000 00000001672 12623665124 0024137 0 ustar 00root root 0000000 0000000 # coding: UTF-8 #============================================================+ # Begin : 2004-06-11 # Last Update : 2010-04-28 # # Description : Configuration file for TCPDF. # # Author: Jun NAITOH # License: LGPL 2.1 or later #============================================================+ PDF_PAGE_ORIENTATION='P' PDF_UNIT='mm' PDF_PAGE_FORMAT='A4' PDF_CREATOR='RBPDF' PDF_AUTHOR='Jun NAITOH' PDF_HEADER_TITLE='RBPDF Example' PDF_HEADER_LOGO="#{File.join(Rails.root, 'public')}/logo_rbpdf_8bit.png" PDF_HEADER_LOGO_WIDTH=30 PDF_HEADER_STRING="by Jun NAITOH - @naitoh" PDF_FONT_NAME_MAIN='helvetica' PDF_FONT_SIZE_MAIN=10 PDF_FONT_NAME_DATA='helvetica' PDF_FONT_SIZE_DATA=8 PDF_FONT_MONOSPACED='courier' PDF_MARGIN_HEADER=5 PDF_MARGIN_FOOTER=10 PDF_MARGIN_TOP=27 PDF_MARGIN_BOTTOM=25 PDF_MARGIN_LEFT=15 PDF_MARGIN_RIGHT=15 PDF_IMAGE_SCALE_RATIO=1.25 $l = {} $l['a_meta_charset'] = 'UTF-8' $l['a_meta_dir'] = 'ltr' $l['a_meta_language'] = 'en' rbpdf-1.19.0/example/rails/public/ 0000775 0000000 0000000 00000000000 12623665124 0016731 5 ustar 00root root 0000000 0000000 rbpdf-1.19.0/example/rails/public/image_demo.jpg 0000664 0000000 0000000 00001660507 12623665124 0021540 0 ustar 00root root 0000000 0000000 JFIF H H AppleMark Exif MM * ( 1 2 <