pax_global_header00006660000000000000000000000064130747034120014513gustar00rootroot0000000000000052 comment=40498f02d9e1aff3c0d04e02cfb4ef4ed57bd5a1 extractpdfmark-1.0.2/000077500000000000000000000000001307470341200145325ustar00rootroot00000000000000extractpdfmark-1.0.2/.dir-locals.el000066400000000000000000000004201307470341200171570ustar00rootroot00000000000000;;; Directory Local Variables ;;; See Info node `(emacs) Directory Variables' for more information. ((c++-mode . ((c-default-style . "gnu") (indent-tabs-mode . nil))) (autoconf-mode . ((indent-tabs-mode . nil))) (shellscript-mode . ((indent-tabs-mode . nil)))) extractpdfmark-1.0.2/.gitignore000066400000000000000000000004071307470341200165230ustar00rootroot00000000000000*~ .\#* \#* \#.* /build/ /autom4te.cache/ /aclocal.m4 /compile /config.h.in /configure /depcomp /install-sh Makefile.in /missing .deps/ Makefile config.h config.log config.status stamp-h1 *.o *.exe extractpdfmark /test-driver config.guess config.rpath config.sub extractpdfmark-1.0.2/COPYING000066400000000000000000001045131307470341200155710ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, 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 them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If 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 convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU 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 Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state 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 program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . extractpdfmark-1.0.2/Makefile.am000066400000000000000000000001701307470341200165640ustar00rootroot00000000000000SUBDIRS = src man test dist_doc_DATA = README.md README.ja.md COPYING EXTRA_DIST = autogen.sh ACLOCAL_AMFLAGS = -I m4 extractpdfmark-1.0.2/README.ja.md000066400000000000000000000124631307470341200164100ustar00rootroot00000000000000 # Extract PDFmark PDF からページモードやリンクの宛先名を抽出し PDFmark として保存します https://github.com/trueroad/extractpdfmark http://www.ctan.org/pkg/extractpdfmark TeX のようなシステムを使って PDF のドキュメントを作る場合、 図としてたくさんの小さな PDF を用意して、 メインの PDF に貼り付けるようなことが行われます。 このとき、図の PDF では同じフォントを使っていることが多いと思います。 図の PDF にフォントのサブセットが埋め込まれていた場合、 TeX システムはそのフォントをそのままメインの PDF に埋め込みます。 結果として、 メイン PDF には重複した同じフォントの異なるサブセットが埋め込まれます。 サブセットが異なるため重複したフォントを削除することはできません。 よってメイン PDF のファイルサイズは、かなり大きくなってしまいます。 一方、図の PDF にフォントをフルセットで埋め込んだ場合、 TeX システムはフルセットのフォントをメインの PDF へ埋め込みます。 メイン PDF にはたくさんの重複したフォントが埋め込まれますが、 すべて同じフルセットのフォントです。 そのため、Ghostscript を使えば重複を削除することができ、 これによってメイン PDF のサイズを低減することができます。 さらに、図の PDF に一切フォントを埋め込まなかった場合、 TeX システムはフォントが欠けたメイン PDF を出力します。 この場合、Ghostscript は必要なフォントを埋め込むことができるので、 必要なディスク容量を劇的に減らすことができるようになります。 いずれの方法でも、 Ghostscript へ TeX システムの出力したメイン PDF を入力し、 最終的な PDF を出力することになります。 しかし、残念ながら、この処理で Ghostscript は PDF のページモードや リンクの宛先名を残してくれません。 そのため、最終的な PDF は意図したとおりに開かれなかったり、 リモートからのリンクが機能しなくなったりしてしまいます。 http://bugs.ghostscript.com/show_bug.cgi?id=696943 http://bugs.ghostscript.com/show_bug.cgi?id=695760 Extract PDFmark は PDF からページモードやリンクの宛先名を抽出し、 PDFmark として保存することができます。 このツールを使うと、ページモードやリンク先名を残したまま、 サイズの小さい PDF を得ることができます。 ## 使い方 $ extractpdfmark TeX出力.pdf > 抽出したPDFmark.ps $ gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite \ -sOutputFile=最終.pdf TeX出力.pdf 抽出したPDFmark.ps ## バイナリパッケージからのインストール いくつかのディストリビューションには `extractpdfmark` パッケージがあります。 * Debian [9 stretch](https://packages.debian.org/stretch/extractpdfmark) * Ubuntu [17.04 Zesty Zapus](http://packages.ubuntu.com/zesty/extractpdfmark) ## [ソース tarball](https://github.com/trueroad/extractpdfmark/releases/download/v1.0.2/extractpdfmark-1.0.2.tar.gz) からのインストール ### 必要なもの [poppler](https://poppler.freedesktop.org/) 0.13.3 以降 --enable-xpdf-headers オプション付き (推奨 poppler 0.48.0 以降) パッケージを使って準備したい場合には、以下が便利でしょう。 * Debian / Ubuntu + libpoppler-private-dev + libpoppler-dev * Fedora + poppler-devel * Cygwin + libpoppler-devel ### ビルド・インストール方法 $ ./configure $ make $ make install `Ghostscript` 9.14 以降と `diff` 等があれば、 以下のようにインストール前にテストすることができます。 $ ./configure $ make $ make check $ make install ## [Git リポジトリ](https://github.com/trueroad/extractpdfmark)からのインストール ソース tarball のビルド要件と追加の要件が必要です。 ### 追加で必要なもの Autoconf 2.69 以降 Automake autopoint 0.19.6 以降(gettext 0.19.6 以降) ### 追加で推奨するもの pdfTeX (テスト PDF の生成用) Ghostscript 9.14 以降(`make check` 用) ### ビルド・インストール方法 $ git clone https://github.com/trueroad/extractpdfmark.git $ cd extractpdfmark $ ./autogen.sh $ mkdir build $ cd build $ ../configure $ make $ make check $ make install ## ライセンス Copyright (C) 2016, 2017 Masamichi Hosoda Extract PDFmark is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Extract PDFmark 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 General Public License for more details. You should have received a copy of the GNU General Public License along with Extract PDFmark. If not, see . extractpdfmark-1.0.2/README.md000066400000000000000000000101661307470341200160150ustar00rootroot00000000000000# Extract PDFmark Extract page mode and named destinations as PDFmark from PDF https://github.com/trueroad/extractpdfmark http://www.ctan.org/pkg/extractpdfmark When you create a PDF document using something like a TeX system you may include many small PDF files in the main PDF file. It is common for each of the small PDF files to use the same fonts. If the small PDF files contain embedded font subsets, the TeX system includes them as-is in the main PDF. As a result, several subsets of the same font are embedded in the main PDF. It is not possible to remove the duplicates since they are different subsets. This vastly increases the size of the main PDF file. On the other hand, if the small PDF files contain embedded full font sets, the TeX system also includes all of them in the main PDF. This time, the main PDF contains duplicates of the same full sets of fonts. Therefore, Ghostscript can remove the duplicates. This may considerably reduce the main PDF-file's size. Finally, if the small PDF files contain some fonts that are *not* embedded, the TeX system outputs the main PDF file with some fonts missing. In this case, Ghostscript can embed the necessary fonts. It can significantly reduce the required disk size. Either way, when Ghostscript reads the main PDF produced by the TeX system and outputs the final PDF it does not preserve PDF page-mode and named-destinations etc. As a result, when you open the final PDF, it is not displayed correctly. Also, remote PDF links will not work correctly. http://bugs.ghostscript.com/show_bug.cgi?id=696943 http://bugs.ghostscript.com/show_bug.cgi?id=695760 This program is able to extract page mode and named destinations as PDFmark from PDF. By using this you can get the small PDF files that have preserved them. ## Usage $ extractpdfmark TeX-System-Outputted.pdf > Extracted-PDFmark.ps $ gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite \ -sOutputFile=Final.pdf TeX-System-Outputted.pdf Extracted-PDFmark.ps ## Install from binary package Some distributions have `extractpdfmark` package. * Debian [9 stretch](https://packages.debian.org/stretch/extractpdfmark) * Ubuntu [17.04 Zesty Zapus](http://packages.ubuntu.com/zesty/extractpdfmark) ## Install from [source tarball](https://github.com/trueroad/extractpdfmark/releases/download/v1.0.2/extractpdfmark-1.0.2.tar.gz) ### Required [poppler](https://poppler.freedesktop.org/) 0.13.3+ with --enable-xpdf-headers option (recommended poppler 0.48.0+) When you would like to use packages for preparing the required library, the following might be convenient. * Debian / Ubuntu + libpoppler-private-dev + libpoppler-dev * Fedora + poppler-devel * Cygwin + libpoppler-devel ### Build & install $ ./configure $ make $ make install If you have `Ghostscript` 9.14+ and `diff` etc., you can run tests before installation as follows. $ ./configure $ make $ make check $ make install ## Install from [Git repository](https://github.com/trueroad/extractpdfmark) Source tarball build requirements and additional requirements are necessary. ### Additional required Autoconf 2.69+ Automake autopoint 0.19.6+ (gettext 0.19.6+) ### Additional recommended pdfTeX (for generating test PDFs) Ghostscript 9.14+ (for `make check`) ### Build & install $ git clone https://github.com/trueroad/extractpdfmark.git $ cd extractpdfmark $ ./autogen.sh $ mkdir build $ cd build $ ../configure $ make $ make check $ make install ## Licence Copyright (C) 2016, 2017 Masamichi Hosoda Extract PDFmark is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Extract PDFmark 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 General Public License for more details. You should have received a copy of the GNU General Public License along with Extract PDFmark. If not, see . extractpdfmark-1.0.2/autogen.sh000077500000000000000000000026341307470341200165400ustar00rootroot00000000000000#!/bin/sh CURRENT_DIR=`pwd` AUTOPOINT_TMP_DIR=`mktemp -d autopoint.tmp.XXXXXXXXXX` echo "*** Entering temporary directory ${AUTOPOINT_TMP_DIR}" cd ${AUTOPOINT_TMP_DIR} echo echo "*** Creating dummy configure.ac" { cat < configure.ac echo echo "*** Invoking autopoint" autopoint || { echo echo "WARNING: autopoint failed." echo "WARNING: It is required for getting \`config.rpath'." echo "WARNING: Please install autopoint 0.19.6 or newer." echo "WARNING: Depending on the platform, this is either" echo "WARNING: a separate package or part of \`gettext-devel'." } echo echo "*** Leaving temporary directory ${AUTOPOINT_TMP_DIR}" cd ${CURRENT_DIR} echo echo "*** Copying config.rpath from temporary directory" cp ${AUTOPOINT_TMP_DIR}/config.rpath . || { echo echo "WARNING: Copy failed." if [ -e config.rpath ]; then echo "WARNING: Using existing \`config.rpath'." else echo echo "ERROR: config.rpath does not exist." echo "ERROR: Please install autopoint 0.19.6 or newer." echo "ERROR: Depending on the platform, this is either" echo "ERROR: a separate package or part of \`gettext-devel'." echo "ERROR: Or, please copy \`config.rpath'." exit 1 fi } echo echo "*** Deleting temporary directory" rm -fr ${AUTOPOINT_TMP_DIR} echo echo "*** Invoking autoreconf" autoreconf -v -i extractpdfmark-1.0.2/configure.ac000066400000000000000000000155661307470341200170350ustar00rootroot00000000000000# -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ([2.69]) AC_INIT([Extract PDFmark], [1.0.2], , [extractpdfmark], [https://github.com/trueroad/extractpdfmark/]) AM_INIT_AUTOMAKE([foreign]) AC_CONFIG_SRCDIR([src/main.cc]) AC_CONFIG_HEADERS([config.h]) PACKAGE_COPYRIGHT="Copyright (C) 2016, 2017 Masamichi Hosoda" PACKAGE_LICENSE="License: GPL3+" AC_SUBST([PACKAGE_COPYRIGHT]) AC_SUBST([PACKAGE_LICENSE]) AC_DEFINE_UNQUOTED([PACKAGE_COPYRIGHT], ["$PACKAGE_COPYRIGHT"], [Define to the copyright of this package.]) AC_DEFINE_UNQUOTED([PACKAGE_LICENSE], ["$PACKAGE_LICENSE"], [Define to the license of this package.]) # Checks for programs. AC_PROG_CXX AX_CXX_COMPILE_STDCXX_11([noext], [mandatory]) AC_PROG_RANLIB AC_PROG_GREP AC_PATH_PROG([DIFF], [diff]) AS_IF([test "x$DIFF" = x], [AC_MSG_WARN([diff isn't found. `make check' will skip tests.])]) AC_SUBST([DIFF]) AC_PATH_PROG([GHOSTSCRIPT], [gs]) AS_IF([test ! "x$GHOSTSCRIPT" = x], [AC_MSG_CHECKING([for gs version ( >= 9.14 )]) gs_ver=`$GHOSTSCRIPT --version` AX_COMPARE_VERSION([$gs_ver], [ge], [9.14], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) GHOSTSCRIPT=])]) AM_CONDITIONAL([HAVE_GHOSTSCRIPT], [test ! "x$GHOSTSCRIPT" = x]) AM_COND_IF([HAVE_GHOSTSCRIPT], , [AC_MSG_WARN( [Ghostscript isn't found. `make check' will skip some tests.])]) AC_SUBST([GHOSTSCRIPT]) AC_MSG_CHECKING([for pre-generated test PDFs]) AS_IF([test ! -e ${srcdir}/test/desttype.pdf], [AC_MSG_RESULT([no]) AC_PATH_PROG([PDFTEX], [pdftex]) AS_IF([test "x$PDFTEX" = x], [AC_MSG_WARN( [pdftex isn't found. Test PDFs cannot be generated.]) AC_MSG_WARN( [You cannot use `make check'.])], [AM_COND_IF([HAVE_GHOSTSCRIPT], [AC_MSG_NOTICE( [pdftex is found. Test PDFs will be generated.])], [AC_MSG_WARN( [pdftex is found but ghostscript isn't found.]) AC_MSG_WARN( [You cannot use `make check'.])])])], [AC_MSG_RESULT([yes])]) AC_SUBST([PDFTEX]) AC_MSG_CHECKING([for pre-generated expected PDFmark files]) AS_IF([test ! -e ${srcdir}/test/desttype-expected.pdfmark], [AC_MSG_RESULT([no]) AC_MSG_WARN( [PDFmark files will be generated.]) AC_MSG_WARN( [`make check' cannot compare with the correct expected results.])], [AC_MSG_RESULT([yes])]) # Checks for libraries. PKG_PROG_PKG_CONFIG AC_ARG_WITH([poppler], AS_HELP_STRING([--with-poppler=@<:@auto|glib|core|core-private@:>@], [Poppler I/F (default: auto)]), , [with_poppler=auto]) AS_CASE(["$with_poppler"], ["glib"], [AC_MSG_NOTICE([--with-poppler=glib requires poppler >= 0.48.0]) PKG_CHECK_MODULES([POPPLER_GLIB], [poppler-glib >= 0.48.0])], ["core"], [AC_MSG_NOTICE([--with-poppler=core requires poppler >= 0.48.0]) PKG_CHECK_MODULES([POPPLER], [poppler >= 0.48.0])], ["core-private"], [AC_MSG_NOTICE( [--with-poppler=core-private requires poppler >= 0.13.3]) PKG_CHECK_MODULES([POPPLER], [poppler >= 0.13.3])], ["auto"], [AC_MSG_NOTICE([selecting for --with-poppler=auto]) AC_MSG_NOTICE([ trying for glib (experiment)]) PKG_CHECK_MODULES( [POPPLER_GLIB], [poppler-glib >= 99.99.99], [with_poppler="glib"], [AC_MSG_NOTICE([ trying for core (poppler >= 0.48.0)]) PKG_CHECK_MODULES( [POPPLER], [poppler >= 0.48.0], [with_poppler="core"], [AC_MSG_NOTICE( [ trying for core-private (poppler >= 0.13.3)]) PKG_CHECK_MODULES([POPPLER], [poppler >= 0.13.3], [with_poppler="core-private"])])])] AC_MSG_NOTICE([use --with-poppler=$with_poppler]), [AC_MSG_ERROR([unrecognized --with-poppler argument: $with_poppler])]) AS_CASE(["$with_poppler"], ["glib"], [POPPLER_IF="poppler-glib" use_library="glib"], ["core"], [POPPLER_IF="poppler-core" use_library="core" AC_DEFINE([HAVE_POPPLER_CORE_IF], [1], [Define if poppler-core is selected])], ["core-private"], [POPPLER_IF="poppler-core private" use_library="core"], [AC_MSG_ERROR([programming error])]) AM_CONDITIONAL([USE_POPPLER_CORE], [test $use_library = core]) AM_CONDITIONAL([USE_POPPLER_GLIB], [test $use_library = glib]) AC_DEFINE_UNQUOTED([PACKAGE_STRING], ["$PACKAGE_STRING (with $POPPLER_IF)"], [Define to the full name and version, method of this package.]) # Checks for header files. AM_COND_IF([USE_POPPLER_CORE], [AC_LANG_PUSH([C++]) TEMP_CPPFLAGS=$CPPFLAGS CPPFLAGS="$CPPFLAGS $POPPLER_CFLAGS" AC_CHECK_HEADERS([Link.h PDFDoc.h PDFDocFactory.h], , [AC_MSG_ERROR([poppler xpdf headers are not found.])]) CPPFLAGS=$TMP_CPPFLAGS AC_LANG_POP]) AC_ARG_ENABLE([codecvt], [AS_HELP_STRING( [--disable-codecvt], [disable codecvt for UTF-8 checking (default is enable)])], , [enable_codecvt=yes]) AS_IF([test "x$enable_codecvt" != xno], [AC_LANG_PUSH([C++]) AC_CHECK_HEADERS([codecvt]) AC_LANG_POP]) AS_IF([test "x$ac_cv_header_codecvt" == xyes], [AC_DEFINE([USE_CODECVT], [1], [Define if codecvt is enabled.])]) AC_ARG_ENABLE([iconv], [AS_HELP_STRING( [--disable-iconv], [disable iconv for UTF-8 checking (default is enable)])], , [enable_iconv=yes]) # AM_ICONV does not seem to be able to put in IF block. AM_ICONV AM_CONDITIONAL([USE_ICONV], [test "x$enable_iconv" = xyes && \ test "x$am_cv_func_iconv" = xyes && \ test "x$ac_cv_header_codecvt" != xyes]) AM_COND_IF([USE_ICONV], [AC_DEFINE([USE_ICONV], [1], [Define if iconv is enabled.])], [AS_IF([test "x$ac_cv_header_codecvt" != xyes], [AC_MSG_WARN( [Some `make check' will fail since both codecvt and iconv are disabled.])])]) # Checks for typedefs, structures, and compiler characteristics. # Checks for library functions. AC_CONFIG_FILES([Makefile src/Makefile src/poppler-core/Makefile src/poppler-glib/Makefile man/Makefile test/Makefile]) AC_OUTPUT extractpdfmark-1.0.2/m4/000077500000000000000000000000001307470341200150525ustar00rootroot00000000000000extractpdfmark-1.0.2/m4/ax_compare_version.m4000066400000000000000000000146521307470341200212070ustar00rootroot00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_compare_version.html # =========================================================================== # # SYNOPSIS # # AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) # # DESCRIPTION # # This macro compares two version strings. Due to the various number of # minor-version numbers that can exist, and the fact that string # comparisons are not compatible with numeric comparisons, this is not # necessarily trivial to do in a autoconf script. This macro makes doing # these comparisons easy. # # The six basic comparisons are available, as well as checking equality # limited to a certain number of minor-version levels. # # The operator OP determines what type of comparison to do, and can be one # of: # # eq - equal (test A == B) # ne - not equal (test A != B) # le - less than or equal (test A <= B) # ge - greater than or equal (test A >= B) # lt - less than (test A < B) # gt - greater than (test A > B) # # Additionally, the eq and ne operator can have a number after it to limit # the test to that number of minor versions. # # eq0 - equal up to the length of the shorter version # ne0 - not equal up to the length of the shorter version # eqN - equal up to N sub-version levels # neN - not equal up to N sub-version levels # # When the condition is true, shell commands ACTION-IF-TRUE are run, # otherwise shell commands ACTION-IF-FALSE are run. The environment # variable 'ax_compare_version' is always set to either 'true' or 'false' # as well. # # Examples: # # AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8]) # AX_COMPARE_VERSION([3.15],[lt],[3.15.8]) # # would both be true. # # AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8]) # AX_COMPARE_VERSION([3.15],[gt],[3.15.8]) # # would both be false. # # AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8]) # # would be true because it is only comparing two minor versions. # # AX_COMPARE_VERSION([3.15.7],[eq0],[3.15]) # # would be true because it is only comparing the lesser number of minor # versions of the two values. # # Note: The characters that separate the version numbers do not matter. An # empty string is the same as version 0. OP is evaluated by autoconf, not # configure, so must be a string, not a variable. # # The author would like to acknowledge Guido Draheim whose advice about # the m4_case and m4_ifvaln functions make this macro only include the # portions necessary to perform the specific comparison specified by the # OP argument in the final configure script. # # LICENSE # # Copyright (c) 2008 Tim Toolan # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 11 dnl ######################################################################### AC_DEFUN([AX_COMPARE_VERSION], [ AC_REQUIRE([AC_PROG_AWK]) # Used to indicate true or false condition ax_compare_version=false # Convert the two version strings to be compared into a format that # allows a simple string comparison. The end result is that a version # string of the form 1.12.5-r617 will be converted to the form # 0001001200050617. In other words, each number is zero padded to four # digits, and non digits are removed. AS_VAR_PUSHDEF([A],[ax_compare_version_A]) A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ -e 's/[[^0-9]]//g'` AS_VAR_PUSHDEF([B],[ax_compare_version_B]) B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ -e 's/[[^0-9]]//g'` dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary dnl # then the first line is used to determine if the condition is true. dnl # The sed right after the echo is to remove any indented white space. m4_case(m4_tolower($2), [lt],[ ax_compare_version=`echo "x$A x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"` ], [gt],[ ax_compare_version=`echo "x$A x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"` ], [le],[ ax_compare_version=`echo "x$A x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"` ], [ge],[ ax_compare_version=`echo "x$A x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"` ],[ dnl Split the operator from the subversion count if present. m4_bmatch(m4_substr($2,2), [0],[ # A count of zero means use the length of the shorter version. # Determine the number of characters in A and B. ax_compare_version_len_A=`echo "$A" | $AWK '{print(length)}'` ax_compare_version_len_B=`echo "$B" | $AWK '{print(length)}'` # Set A to no more than B's length and B to no more than A's length. A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"` B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"` ], [[0-9]+],[ # A count greater than zero means use only that many subversions A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` ], [.+],[ AC_WARNING( [illegal OP numeric parameter: $2]) ],[]) # Pad zeros at end of numbers to make same length. ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`" B="$B`echo $A | sed 's/./0/g'`" A="$ax_compare_version_tmp_A" # Check for equality or inequality as necessary. m4_case(m4_tolower(m4_substr($2,0,2)), [eq],[ test "x$A" = "x$B" && ax_compare_version=true ], [ne],[ test "x$A" != "x$B" && ax_compare_version=true ],[ AC_WARNING([illegal OP parameter: $2]) ]) ]) AS_VAR_POPDEF([A])dnl AS_VAR_POPDEF([B])dnl dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE. if test "$ax_compare_version" = "true" ; then m4_ifvaln([$4],[$4],[:])dnl m4_ifvaln([$5],[else $5])dnl fi ]) dnl AX_COMPARE_VERSION extractpdfmark-1.0.2/m4/ax_cxx_compile_stdcxx.m4000066400000000000000000000330001307470341200217070ustar00rootroot00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html # =========================================================================== # # SYNOPSIS # # AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional]) # # DESCRIPTION # # Check for baseline language coverage in the compiler for the specified # version of the C++ standard. If necessary, add switches to CXX and # CXXCPP to enable support. VERSION may be '11' (for the C++11 standard) # or '14' (for the C++14 standard). # # The second argument, if specified, indicates whether you insist on an # extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. # -std=c++11). If neither is specified, you get whatever works, with # preference for an extended mode. # # The third argument, if specified 'mandatory' or if left unspecified, # indicates that baseline support for the specified C++ standard is # required and that the macro should error out if no mode with that # support is found. If specified 'optional', then configuration proceeds # regardless, after defining HAVE_CXX${VERSION} if and only if a # supporting mode is found. # # LICENSE # # Copyright (c) 2008 Benjamin Kosnik # Copyright (c) 2012 Zack Weinberg # Copyright (c) 2013 Roy Stogner # Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov # Copyright (c) 2015 Paul Norman # Copyright (c) 2015 Moritz Klammler # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 4 dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro dnl (serial version number 13). AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl m4_if([$1], [11], [], [$1], [14], [], [$1], [17], [m4_fatal([support for C++17 not yet implemented in AX_CXX_COMPILE_STDCXX])], [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl m4_if([$2], [], [], [$2], [ext], [], [$2], [noext], [], [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true], [$3], [mandatory], [ax_cxx_compile_cxx$1_required=true], [$3], [optional], [ax_cxx_compile_cxx$1_required=false], [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])]) AC_LANG_PUSH([C++])dnl ac_success=no AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, ax_cv_cxx_compile_cxx$1, [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], [ax_cv_cxx_compile_cxx$1=yes], [ax_cv_cxx_compile_cxx$1=no])]) if test x$ax_cv_cxx_compile_cxx$1 = xyes; then ac_success=yes fi m4_if([$2], [noext], [], [dnl if test x$ac_success = xno; then for switch in -std=gnu++$1 -std=gnu++0x; do cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, $cachevar, [ac_save_CXX="$CXX" CXX="$CXX $switch" AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], [eval $cachevar=yes], [eval $cachevar=no]) CXX="$ac_save_CXX"]) if eval test x\$$cachevar = xyes; then CXX="$CXX $switch" if test -n "$CXXCPP" ; then CXXCPP="$CXXCPP $switch" fi ac_success=yes break fi done fi]) m4_if([$2], [ext], [], [dnl if test x$ac_success = xno; then dnl HP's aCC needs +std=c++11 according to: dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf dnl Cray's crayCC needs "-h std=c++11" for switch in -std=c++$1 -std=c++0x +std=c++$1 "-h std=c++$1"; do cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, $cachevar, [ac_save_CXX="$CXX" CXX="$CXX $switch" AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], [eval $cachevar=yes], [eval $cachevar=no]) CXX="$ac_save_CXX"]) if eval test x\$$cachevar = xyes; then CXX="$CXX $switch" if test -n "$CXXCPP" ; then CXXCPP="$CXXCPP $switch" fi ac_success=yes break fi done fi]) AC_LANG_POP([C++]) if test x$ax_cxx_compile_cxx$1_required = xtrue; then if test x$ac_success = xno; then AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.]) fi fi if test x$ac_success = xno; then HAVE_CXX$1=0 AC_MSG_NOTICE([No compiler with C++$1 support was found]) else HAVE_CXX$1=1 AC_DEFINE(HAVE_CXX$1,1, [define if the compiler supports basic C++$1 syntax]) fi AC_SUBST(HAVE_CXX$1) ]) dnl Test body for checking C++11 support m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11], _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 ) dnl Test body for checking C++14 support m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 ) dnl Tests for new features in C++11 m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[ // If the compiler admits that it is not ready for C++11, why torture it? // Hopefully, this will speed up the test. #ifndef __cplusplus #error "This is not a C++ compiler" #elif __cplusplus < 201103L #error "This is not a C++11 compiler" #else namespace cxx11 { namespace test_static_assert { template struct check { static_assert(sizeof(int) <= sizeof(T), "not big enough"); }; } namespace test_final_override { struct Base { virtual void f() {} }; struct Derived : public Base { virtual void f() override {} }; } namespace test_double_right_angle_brackets { template < typename T > struct check {}; typedef check single_type; typedef check> double_type; typedef check>> triple_type; typedef check>>> quadruple_type; } namespace test_decltype { int f() { int a = 1; decltype(a) b = 2; return a + b; } } namespace test_type_deduction { template < typename T1, typename T2 > struct is_same { static const bool value = false; }; template < typename T > struct is_same { static const bool value = true; }; template < typename T1, typename T2 > auto add(T1 a1, T2 a2) -> decltype(a1 + a2) { return a1 + a2; } int test(const int c, volatile int v) { static_assert(is_same::value == true, ""); static_assert(is_same::value == false, ""); static_assert(is_same::value == false, ""); auto ac = c; auto av = v; auto sumi = ac + av + 'x'; auto sumf = ac + av + 1.0; static_assert(is_same::value == true, ""); static_assert(is_same::value == true, ""); static_assert(is_same::value == true, ""); static_assert(is_same::value == false, ""); static_assert(is_same::value == true, ""); return (sumf > 0.0) ? sumi : add(c, v); } } namespace test_noexcept { int f() { return 0; } int g() noexcept { return 0; } static_assert(noexcept(f()) == false, ""); static_assert(noexcept(g()) == true, ""); } namespace test_constexpr { template < typename CharT > unsigned long constexpr strlen_c_r(const CharT *const s, const unsigned long acc) noexcept { return *s ? strlen_c_r(s + 1, acc + 1) : acc; } template < typename CharT > unsigned long constexpr strlen_c(const CharT *const s) noexcept { return strlen_c_r(s, 0UL); } static_assert(strlen_c("") == 0UL, ""); static_assert(strlen_c("1") == 1UL, ""); static_assert(strlen_c("example") == 7UL, ""); static_assert(strlen_c("another\0example") == 7UL, ""); } namespace test_rvalue_references { template < int N > struct answer { static constexpr int value = N; }; answer<1> f(int&) { return answer<1>(); } answer<2> f(const int&) { return answer<2>(); } answer<3> f(int&&) { return answer<3>(); } void test() { int i = 0; const int c = 0; static_assert(decltype(f(i))::value == 1, ""); static_assert(decltype(f(c))::value == 2, ""); static_assert(decltype(f(0))::value == 3, ""); } } namespace test_uniform_initialization { struct test { static const int zero {}; static const int one {1}; }; static_assert(test::zero == 0, ""); static_assert(test::one == 1, ""); } namespace test_lambdas { void test1() { auto lambda1 = [](){}; auto lambda2 = lambda1; lambda1(); lambda2(); } int test2() { auto a = [](int i, int j){ return i + j; }(1, 2); auto b = []() -> int { return '0'; }(); auto c = [=](){ return a + b; }(); auto d = [&](){ return c; }(); auto e = [a, &b](int x) mutable { const auto identity = [](int y){ return y; }; for (auto i = 0; i < a; ++i) a += b--; return x + identity(a + b); }(0); return a + b + c + d + e; } int test3() { const auto nullary = [](){ return 0; }; const auto unary = [](int x){ return x; }; using nullary_t = decltype(nullary); using unary_t = decltype(unary); const auto higher1st = [](nullary_t f){ return f(); }; const auto higher2nd = [unary](nullary_t f1){ return [unary, f1](unary_t f2){ return f2(unary(f1())); }; }; return higher1st(nullary) + higher2nd(nullary)(unary); } } namespace test_variadic_templates { template struct sum; template struct sum { static constexpr auto value = N0 + sum::value; }; template <> struct sum<> { static constexpr auto value = 0; }; static_assert(sum<>::value == 0, ""); static_assert(sum<1>::value == 1, ""); static_assert(sum<23>::value == 23, ""); static_assert(sum<1, 2>::value == 3, ""); static_assert(sum<5, 5, 11>::value == 21, ""); static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); } // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function // because of this. namespace test_template_alias_sfinae { struct foo {}; template using member = typename T::member_type; template void func(...) {} template void func(member*) {} void test(); void test() { func(0); } } } // namespace cxx11 #endif // __cplusplus >= 201103L ]]) dnl Tests for new features in C++14 m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[ // If the compiler admits that it is not ready for C++14, why torture it? // Hopefully, this will speed up the test. #ifndef __cplusplus #error "This is not a C++ compiler" #elif __cplusplus < 201402L #error "This is not a C++14 compiler" #else namespace cxx14 { namespace test_polymorphic_lambdas { int test() { const auto lambda = [](auto&&... args){ const auto istiny = [](auto x){ return (sizeof(x) == 1UL) ? 1 : 0; }; const int aretiny[] = { istiny(args)... }; return aretiny[0]; }; return lambda(1, 1L, 1.0f, '1'); } } namespace test_binary_literals { constexpr auto ivii = 0b0000000000101010; static_assert(ivii == 42, "wrong value"); } namespace test_generalized_constexpr { template < typename CharT > constexpr unsigned long strlen_c(const CharT *const s) noexcept { auto length = 0UL; for (auto p = s; *p; ++p) ++length; return length; } static_assert(strlen_c("") == 0UL, ""); static_assert(strlen_c("x") == 1UL, ""); static_assert(strlen_c("test") == 4UL, ""); static_assert(strlen_c("another\0test") == 7UL, ""); } namespace test_lambda_init_capture { int test() { auto x = 0; const auto lambda1 = [a = x](int b){ return a + b; }; const auto lambda2 = [a = lambda1(x)](){ return a; }; return lambda2(); } } namespace test_digit_seperators { constexpr auto ten_million = 100'000'000; static_assert(ten_million == 100000000, ""); } namespace test_return_type_deduction { auto f(int& x) { return x; } decltype(auto) g(int& x) { return x; } template < typename T1, typename T2 > struct is_same { static constexpr auto value = false; }; template < typename T > struct is_same { static constexpr auto value = true; }; int test() { auto x = 0; static_assert(is_same::value, ""); static_assert(is_same::value, ""); return x; } } } // namespace cxx14 #endif // __cplusplus >= 201402L ]]) extractpdfmark-1.0.2/m4/ax_cxx_compile_stdcxx_11.m4000066400000000000000000000032121307470341200222120ustar00rootroot00000000000000# ============================================================================ # http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html # ============================================================================ # # SYNOPSIS # # AX_CXX_COMPILE_STDCXX_11([ext|noext], [mandatory|optional]) # # DESCRIPTION # # Check for baseline language coverage in the compiler for the C++11 # standard; if necessary, add switches to CXX and CXXCPP to enable # support. # # This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX # macro with the version set to C++11. The two optional arguments are # forwarded literally as the second and third argument respectively. # Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for # more information. If you want to use this macro, you also need to # download the ax_cxx_compile_stdcxx.m4 file. # # LICENSE # # Copyright (c) 2008 Benjamin Kosnik # Copyright (c) 2012 Zack Weinberg # Copyright (c) 2013 Roy Stogner # Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov # Copyright (c) 2015 Paul Norman # Copyright (c) 2015 Moritz Klammler # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 17 AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX]) AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [AX_CXX_COMPILE_STDCXX([11], [$1], [$2])]) extractpdfmark-1.0.2/man/000077500000000000000000000000001307470341200153055ustar00rootroot00000000000000extractpdfmark-1.0.2/man/Makefile.am000066400000000000000000000000651307470341200173420ustar00rootroot00000000000000man_MANS = extractpdfmark.1 EXTRA_DIST = $(man_MANS) extractpdfmark-1.0.2/man/extractpdfmark.1000066400000000000000000000036751307470341200204210ustar00rootroot00000000000000.TH EXTRACTPDFMARK 1 "December 11, 2016" .SH NAME extractpdfmark \- Extract page mode and named destinations as PDFmark from PDF .SH SYNOPSIS .B extractpdfmark .IR file.pdf " > " file.ps .SH DESCRIPTION This manual page documents briefly the .B extractpdfmark command. .PP When you create a PDF document using a TeX system, you may include many small PDF files in the main PDF file. It is common for each of those files to use the same fonts. .PP If the small PDF files contain embedded font subsets, the TeX system includes them as-is in the main PDF. As a result, several subsets of the same font are embedded in the main PDF. It is not possible to remove the duplicates since they are different subsets. This vastly increases the size of the main PDF file. .PP On the other hand, if the small PDF files contain embedded full font sets, the TeX system also includes all of them in the main PDF. This time, the main PDF contains duplicates of the same full sets of fonts. Therefore, Ghostscript can remove the duplicates. This may considerably reduce the main PDF\-file's size. .PP Finally, if the small PDF files contain some fonts that are not embedded, the TeX system outputs the main PDF file with some fonts missing. In this case, Ghostscript can embed the necessary fonts. It can significantly reduce the required disk size. .PP Either way, when Ghostscript reads the main PDF produced by the TeX system and outputs the final PDF it does not preserve PDF page\-mode and named\-destinations etc. As a result, when you open the final PDF, it is not displayed correctly. Also, remote PDF links will not work. .PP This program is able to extract page mode and named destinations as PDFmark from PDF. By using this you can get the small PDF files that have preserved them. .SH EXAMPLE .RS $ extractpdfmark TeX-System-Outputted.pdf > Extracted-PDFmark.ps .RE .RS $ gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=Final.pdf TeX-System-Outputted.pdf Extracted-PDFmark.ps .RE extractpdfmark-1.0.2/src/000077500000000000000000000000001307470341200153215ustar00rootroot00000000000000extractpdfmark-1.0.2/src/Makefile.am000066400000000000000000000015271307470341200173620ustar00rootroot00000000000000SUBDIRS = bin_PROGRAMS = extractpdfmark extractpdfmark_SOURCES = main.cc cmdlineparse.hh \ output-pdfmark.cc output-pdfmark.hh \ encodename.cc \ utf16.cc utf16.hh \ utf8.cc utf8.hh extractpdfmark_LDADD = extractpdfmark_LDFLAGS = extractpdfmark_DEPENDENCIES = if USE_POPPLER_CORE SUBDIRS += poppler-core extractpdfmark_LDADD += -lextractpdfmark-poppler-core $(POPPLER_LIBS) extractpdfmark_LDFLAGS += -L./poppler-core extractpdfmark_DEPENDENCIES += ./poppler-core/libextractpdfmark-poppler-core.a endif if USE_POPPLER_GLIB SUBDIRS += poppler-glib extractpdfmark_LDADD += -lextractpdfmark-poppler-glib $(POPPLER_GLIB_LIBS) extractpdfmark_LDFLAGS += -L./poppler-glib extractpdfmark_DEPENDENCIES += ./poppler-glib/libextractpdfmark-poppler-glib.a endif if USE_ICONV extractpdfmark_SOURCES += iconv_wrapper.hh extractpdfmark_LDADD += $(LIBICONV) endif extractpdfmark-1.0.2/src/cmdlineparse.hh000066400000000000000000000607201307470341200203150ustar00rootroot00000000000000// // One header file Commandline Parse for C++11 2017-01-29.01 GPL // https://github.com/trueroad/cmdlineparse/ // // Copyright (C) 2016, 2017 Masamichi Hosoda // // One header file Commandline Parse for C++11 is free software: // you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // One header file Commandline Parse for C++11 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with One header file Commandline Parse for C++11. // If not, see . // #ifndef INCLUDE_GUARD_CMDLINEPARSE_HH #define INCLUDE_GUARD_CMDLINEPARSE_HH #include #include #include #include #include #include // gettext macros #ifndef _ #define _(DUMMY) DUMMY #define CMDLINEPARSE_HH_DEFINE_DUMMY_GETTEXT #endif namespace cmdlineparse { enum class arg_mode { no_argument = 0, required_argument = 1, optional_argument = 2 }; enum class abort_reason { option_handler = -1, no_abort = 0, error_extra_arg, error_no_arg, error_ambiguous_option, error_unknown_option, error_no_arg_short, error_unknown_option_short, }; class parser { public: // Add an option handler bool add_handler (char short_name, const std::string &long_name, arg_mode has_arg, std::function option_handler, const std::string &description = "", const std::string &typestr = "", const std::string &header = "", const std::string &group = ""); // Add a flag option bool add_flag (char short_name, const std::string &long_name, bool *flag, const std::string &description = "", const std::string &group = ""); // Add a string option bool add_string (char short_name, const std::string &long_name, std::string *var, const std::string &defval, const std::string &description = "", const std::string &typestr = "STRING", const std::string &group = ""); // Add help description void add_description (char short_name, const std::string &long_name, arg_mode has_arg, const std::string &description, const std::string &typestr = "", const std::string &header = "", const std::string &group = ""); // Add default handler bool add_default_help (void); bool add_default_version (void); bool add_default (void) { if (!add_default_help ()) return false; return add_default_version (); } // Parse options bool parse (int argc, char const* const* argv, int optind = 1); // Build default strings std::string build_usage (void) const; std::string build_help (void) const; // Get version_string const std::string &get_version_string () const noexcept { return version_string; } // Set version_string void set_version_string (const std::string &s) { version_string = s; } // Get unamed_args const std::vector &get_unamed_args () const noexcept { return unamed_args; } // Set usage_unamed_opts void set_usage_unamed_opts (const std::string &s) { usage_unamed_opts = s; } // Get abort reason abort_reason get_abort_reason () const noexcept { return abort; } // Get abort option const std::string &get_abort_option () const noexcept { return abort_option; } // Set opterr void set_opterr (bool flag) noexcept { opterr = flag; } // Set long_only void set_long_only (bool flag) noexcept { long_only = flag; } // Set continue_on_error void set_continue_on_error (bool flag) noexcept { continue_on_error = flag; } // Set abbreviated_long_name void set_abbreviated_long_name (bool flag) noexcept { abbreviated_long_name = flag; } // Constructor parser (); // Const const std::string h_indent {" "}; const std::string h_space {" "}; const std::string d_indent {" "}; private: // Internal functions void add_short (char short_name, arg_mode has_arg, std::function option_handler); void add_long (const std::string &long_name, arg_mode has_arg, std::function option_handler); bool find_unique_long_name (const std::string &long_name, std::pair> *target, bool *ambiguous); bool parse_long_name (std::vector::const_iterator *it); bool parse_short_name (std::vector::const_iterator *it); // Error handlers std::function error_extra_arg { [this](const std::string &long_name, const std::string &)->bool { if (opterr) std::cerr << argvs[0] << _(": option doesn't take an argument -- ") << long_name << std::endl; return continue_on_error; } }; std::function error_no_arg { [this](const std::string &long_name)->bool { if (opterr) std::cerr << argvs[0] << _(": option requires an argument -- ") << long_name << std::endl; return continue_on_error; } }; std::function error_ambiguous_option { [this](const std::string &optchars)->bool { if (opterr) std::cerr << argvs[0] << _(": ambiguous option -- ") << optchars << std::endl; return continue_on_error; } }; std::function error_unknown_option { [this](const std::string &optchars)->bool { if (opterr) std::cerr << argvs[0] << _(": unknown option -- ") << optchars << std::endl; return continue_on_error; } }; std::function error_no_arg_short { [this](char optchar)->bool { if (opterr) std::cerr << argvs[0] << _(": option requires an argument -- ") << optchar << std::endl; return continue_on_error; } }; std::function error_unknown_option_short { [this](char optchar)->bool { if (opterr) std::cerr << argvs[0] << _(": unknown option -- ") << optchar << std::endl; return continue_on_error; } }; // Help strings std::string version_string; std::string usage_unamed_opts; // Flags bool opterr {true}; bool continue_on_error {false}; bool long_only {false}; bool abbreviated_long_name {true}; // Abort reason abort_reason abort {abort_reason::no_abort}; std::string abort_option; // Arguments std::vector argvs; std::vector unamed_args; // Maps std::map>> short_map; std::map>> long_map; std::map> help_map; }; inline parser::parser () { #ifdef PACKAGE_STRING // Build version_string std::stringstream ss; ss << PACKAGE_STRING << std::endl; #ifdef PACKAGE_COPYRIGHT ss << PACKAGE_COPYRIGHT << std::endl; #ifdef PACKAGE_LICENSE ss << PACKAGE_LICENSE << std::endl; #endif // PACKAGE_LICENSE #endif // PACKAGE_COPYRIGHT #ifdef PACKAGE_URL ss << std::endl << PACKAGE_URL << std::endl; #endif // PACKAGE_URL version_string = ss.str (); #endif // PACKAGE_STRING } inline void parser::add_short (char short_name, arg_mode has_arg, std::function option_handler) { if (short_name) { short_map[short_name] = std::pair> (has_arg, option_handler); } } inline void parser::add_long (const std::string &long_name, arg_mode has_arg, std::function option_handler) { if (!long_name.empty ()) { long_map[long_name] = std::pair> (has_arg, option_handler); } } inline void parser::add_description (char short_name, const std::string &long_name, arg_mode has_arg, const std::string &description, const std::string &typestr, const std::string &header, const std::string &group) { std::stringstream ss; if (short_name || !long_name.empty () || !header.empty ()) { ss << h_indent; if (short_name) { ss << "-" << short_name; if (long_name.empty () && !typestr.empty ()) ss << typestr; } if (!long_name.empty ()) { if (short_name) ss << ", "; ss << "--" << long_name; if (!typestr.empty ()) { switch (has_arg) { case arg_mode::no_argument: // Nothing to do break; case arg_mode::required_argument: ss << "=" << typestr; break; case arg_mode::optional_argument: ss << "[=" << typestr << "]"; break; } } } if (!header.empty ()) ss << header; ss << std::endl; } if (!description.empty ()) ss << description << std::endl; help_map[group].push_back (ss.str ()); } inline bool parser::add_handler (char short_name, const std::string &long_name, arg_mode has_arg, std::function option_handler, const std::string &description, const std::string &typestr, const std::string &header, const std::string &group) { if (short_name && short_map.find (short_name) != short_map.end ()) { // The short name is already registerd. return false; } if (!long_name.empty() && long_map.find (long_name) != long_map.end ()) { // The long name is already registerd. return false; } add_short (short_name, has_arg, option_handler); add_long (long_name, has_arg, option_handler); if (!description.empty () || !typestr.empty ()) add_description (short_name, long_name, has_arg, description, typestr, header, group); return true; } inline bool parser::add_flag (char short_name, const std::string &long_name, bool *flag, const std::string &description, const std::string &group) { *flag = false; return add_handler (short_name, long_name, arg_mode::no_argument, [flag](const std::string &)->bool { *flag = true; return true; }, description, "", "", group); } inline bool parser::add_string (char short_name, const std::string &long_name, std::string *var, const std::string &defval, const std::string &description, const std::string &typestr, const std::string &group) { *var = defval; std::string header; if(!defval.empty ()) { // Three spaces for separator (same as h_space) header = _(" (default=") + defval + ")"; } return add_handler (short_name, long_name, arg_mode::required_argument, [var](const std::string &optarg)->bool { *var = optarg; return true; }, description, typestr, header, group); } inline bool parser::add_default_help (void) { return add_handler ('h', "help", arg_mode::no_argument, [this](const std::string &)->bool { std::cout << build_help (); return false; }, // Four spaces for indent (same as d_indent) _(" Print help and exit")); } inline bool parser::add_default_version (void) { return add_handler ('V', "version", arg_mode::no_argument, [this](const std::string &)->bool { std::cout << version_string; return false; }, // Four spaces for indent (same as d_indent) _(" Print version and exit")); } inline bool parser::find_unique_long_name (const std::string &long_name, std::pair> *target, bool *ambiguous) { if (long_map.find (long_name) != long_map.end ()) { // Long option name found *target = long_map[long_name]; return true; } if (abbreviated_long_name) { // Search abbreviated long option name for (decltype (long_map.cbegin()) it = long_map.upper_bound (long_name); it != long_map.cend (); ++it) { if (it->first.substr (0, long_name.size ()) == long_name) { auto next_it = it; ++next_it; if (next_it != long_map.cend () && next_it->first.substr (0, long_name.size ()) == long_name) { // Failed: ambiguous option *ambiguous = true; return false; } // Unique abbreviated long option name fount *target = it->second; return true; } } } // Failed: unknown long option name *ambiguous = false; return false; } inline bool parser::parse_long_name (std::vector::const_iterator *it) { size_t optchars_pos = (*it)->at(1) == '-' ? 2: // Double hyphen (--long_name) style 1; // Single hyphen (-long_name) style auto delimiter_pos = (*it)->find ('='); std::string long_name = (*it)->substr (optchars_pos, delimiter_pos - optchars_pos); std::string optarg; if (delimiter_pos != std::string::npos) { // Option characters have an option argument // (something like --long_name=optarg) optarg = (*it)->substr (delimiter_pos + 1, std::string::npos); } std::pair> target; bool ambiguous; if (find_unique_long_name (long_name, &target, &ambiguous)) { // Long option name found switch (target.first) { case arg_mode::no_argument: if (delimiter_pos != std::string::npos) { if (!error_extra_arg (long_name, optarg)) { abort = abort_reason::error_extra_arg; abort_option = long_name; return false; } return true; } break; case arg_mode::required_argument: if (delimiter_pos == std::string::npos) { if ((*it + 1) != argvs.cend ()) { // Next argv-element is an option argument // (something like --long_name optarg) optarg = *(++(*it)); } else { if (!error_no_arg (long_name)) { abort = abort_reason::error_no_arg; abort_option = long_name; return false; } return true; } } break; case arg_mode::optional_argument: // Nothing to do break; } // Call option handler if (!target.second (optarg)) { abort = abort_reason::option_handler; abort_option = long_name; return false; } return true; } // Long option name did not find if (optchars_pos == 1) { // Fallback to short option name return parse_short_name (it); } if (ambiguous) { if (!error_ambiguous_option ((*it)->substr (optchars_pos, std::string::npos))) { abort = abort_reason::error_ambiguous_option; abort_option = long_name; return false; } return true; } if (!error_unknown_option ((*it)->substr (optchars_pos, std::string::npos))) { abort = abort_reason::error_unknown_option; abort_option = long_name; return false; } return true; } inline bool parser::parse_short_name (std::vector::const_iterator *it) { for (auto name_it = (*it)->cbegin () + 1; name_it != (*it)->cend (); ++name_it) { if (short_map.find (*name_it) != short_map.end()) { // Short option name found auto target = short_map[*name_it]; switch (target.first) { case arg_mode::no_argument: // Option characters doesn't have an option argument // (something like -o) if (!target.second ("")) // Call option handler { abort = abort_reason::option_handler; abort_option = *name_it; return false; } break; case arg_mode::required_argument: if ((name_it + 1) != (*it)->cend ()) { // Option characters have an option argument // (something like -ooptarg) std::string optarg (name_it + 1, (*it)->cend ()); if (!target.second (optarg)) // Call option handler { abort = abort_reason::option_handler; abort_option = *name_it; return false; } return true; } else if ((*it + 1) != argvs.cend ()) { // Next argv-element is an option argument // (something like -o optarg) std::string optarg = *(++(*it)); if (!target.second (optarg)) // Call option handler { abort = abort_reason::option_handler; abort_option = *name_it; return false; } return true; } else { if (!error_no_arg_short (*name_it)) { abort = abort_reason::error_no_arg_short; abort_option = *name_it; return false; } } break; case arg_mode::optional_argument: if ((name_it + 1) != (*it)->cend ()) { // Option characters have an option argument // (something like -ooptarg) std::string optarg (name_it + 1, (*it)->cend ()); if (!target.second (optarg)) // Call option handler { abort = abort_reason::option_handler; abort_option = *name_it; return false; } return true; } // Option characters doesn't have an option argument // (something like -o) if (!target.second ("")) // Call option handler { abort = abort_reason::option_handler; abort_option = *name_it; return false; } break; } } else { if (!error_unknown_option_short (*name_it)) { abort = abort_reason::error_unknown_option_short; abort_option = *name_it; return false; } } } return true; } inline bool parser::parse (int argc, char const* const* argv, int optind) { argvs.assign (argv, argv + argc); if (version_string.empty ()) version_string = argvs[0] + "\n"; bool all_skip = false; for (auto argv_it = argvs.cbegin () + optind; argv_it != argvs.cend (); ++argv_it) { // Check skip if (all_skip) { unamed_args.push_back (*argv_it); continue; } // Check "--" and "-" // They are not option element. if (*argv_it == "--") { all_skip = true; continue; } else if (*argv_it == "-") { unamed_args.push_back (*argv_it); continue; } // Check option element if (argv_it->substr (0, 2) == "--") { // Long option if (!parse_long_name (&argv_it)) return false; } else if (argv_it->substr (0, 1) == "-") { if (long_only) { // Long option if (!parse_long_name (&argv_it)) return false; } else { // Short option if (!parse_short_name (&argv_it)) return false; } } else { // It is not an option element. unamed_args.push_back (*argv_it); } } return true; } inline std::string parser::build_usage (void) const { std::stringstream ss; ss << _("Usage: ") << argvs[0] << _(" [options] "); if (!usage_unamed_opts.empty ()) ss << "[" << usage_unamed_opts << "] "; ss << "..." << std::endl; return ss.str (); } inline std::string parser::build_help (void) const { std::stringstream ss; ss << version_string << std::endl << build_usage () << std::endl; for (const auto &group: help_map) { if (!group.first.empty ()) ss << std::endl << group.first << ":" << std::endl; for (const auto &description: group.second) { ss << description; } } return ss.str (); } } #if defined (_) && defined (CMDLINEPARSE_HH_DEFINE_DUMMY_GETTEXT) #undef _ #undef CMDLINEPARSE_HH_DEFINE_DUMMY_GETTEXT #endif #endif extractpdfmark-1.0.2/src/encodename.cc000066400000000000000000000052731307470341200177350ustar00rootroot00000000000000// This file is part of Extract PDFmark. // // Copyright (C) 2016 Masamichi Hosoda // // Extract PDFmark is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Extract PDFmark 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Extract PDFmark. If not, see . #include "config.h" #include "output-pdfmark.hh" #include #include #include #include "utf16.hh" #include "utf8.hh" std::string output_pdfmark::encode_literal (const std::string &name) const { bool bflag = escape || is_utf16 (name) || !is_utf8 (name); std::stringstream encoded; for (auto c: name) { if (bflag || static_cast(c) < 0x20 || c == '(' || c == ')' || c == '\\' || c == 0x7f) { encoded << '\\' << std::oct << std::setw (3) << std::setfill ('0') << static_cast(static_cast(c)); } else { encoded << c; } } return encoded.str (); } std::string output_pdfmark::encode_hexadecimal (const std::string &name) const { std::stringstream encoded; encoded << std::hex << std::setw (2) << std::setfill ('0'); for (auto c: name) { encoded << static_cast(static_cast(c)); } return encoded.str (); } std::string output_pdfmark::encode_nameobject (const std::string &name) const { std::stringstream encoded; for (auto c: name) { if (escape || static_cast(c) < 0x21 || static_cast(c) > 0x7e || c == '(' || c == ')' || c == '<' || c == '>' || c == '[' || c == ']' || c == '{' || c == '}' || c == '/' || c == '%' || c == '#') { encoded << '#' << std::hex << std::uppercase << std::setw (2) << std::setfill ('0') << static_cast(static_cast(c)); } else { encoded << c; } } return encoded.str (); } std::string output_pdfmark::encode_name (const std::string &name) const { if (hexadecimal) return "<" + encode_hexadecimal (name) + ">"; if (nameobject) return "/" + encode_nameobject (name); return "(" + encode_literal (name) + ")"; } extractpdfmark-1.0.2/src/iconv_wrapper.hh000066400000000000000000000131701307470341200205220ustar00rootroot00000000000000// // One header file iconv wrapper for C++11 2016-10-19.22 GPL // https://github.com/trueroad/iconv_wrapper/ // // Copyright (C) 2016 Masamichi Hosoda. All rights reserved. // // One header file iconv wrapper for C++11 is free software: // you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // One header file iconv wrapper for C++11 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with One header file Commandline Parse for C++11. // If not, see . // #ifndef INCLUDE_GUARD_ICONV_WRAPPER_H #define INCLUDE_GUARD_ICONV_WRAPPER_H #include #include #include namespace iconv_wrapper { class iconv { public: // Open void open (const std::string &fromcode, const std::string &tocode); // Close void close () noexcept; // Convert std::string convert (const std::string &in); // Convert (with getting the incomplete input / output // when an exception occurs) std::string &convert (const std::string &in, std::string::size_type *pinpos, std::string *pout); // Get initial sequence std::string get_initial_sequence (void); // Get initial sequence std::string &get_initial_sequence (std::string *pout); // Reset conversion state void reset (void) const noexcept; // Constructor / destructor iconv () = default; iconv (const std::string &fromcode, const std::string &tocode) { open (fromcode, tocode); } ~iconv () noexcept { close (); } // Enable move iconv (iconv &&) = default; iconv& operator = (iconv &&) = default; private: // Internal class // There is two different implements for the second argument of iconv (). // `const char**' and `char **' // This class is for automatic type cast switching. class iconv_const_cast { public: iconv_const_cast (const char **in) noexcept: t (in) { } operator char** () const noexcept { return const_cast(t); } operator const char ** () const noexcept { return t; } private: const char ** t; }; // Internal function void do_iconv (std::string *pout, const char *inbuf, size_t *pinleft, std::string::size_type *pinpos = nullptr); // Disable copy // Since iconv_t cannot duplicate. iconv (iconv const &) = delete; iconv& operator = (iconv const &) = delete; // Const // Here is C cast instead of C++ cast. // C++ reinterpret_cast (pointer) and static_cast (integer) cannot be used. // Since it depends on the implementation of iconv_t. const iconv_t invalid_cd = (iconv_t)-1; // Conversion descriptor iconv_t convdesc = invalid_cd; }; inline void iconv::open (const std::string &fromcode, const std::string &tocode) { if (convdesc == invalid_cd) { close (); } convdesc = iconv_open (tocode.c_str (), fromcode.c_str ()); if (convdesc == invalid_cd) { throw std::system_error (errno, std::system_category ()); } } inline void iconv::close () noexcept { if (convdesc != invalid_cd) { iconv_close (convdesc); convdesc = invalid_cd; } } inline std::string iconv::convert (const std::string &in) { std::string out (in.size (), '\0'); convert (in, nullptr, &out); return out; } inline std::string &iconv::convert (const std::string &in, std::string::size_type *pinpos, std::string *pout) { size_t inleft {in.size ()}; do_iconv (pout, &in.at (0), &inleft, pinpos); return *pout; } inline std::string iconv::get_initial_sequence (void) { std::string out (1, '\0'); get_initial_sequence (&out); return out; } inline std::string &iconv::get_initial_sequence (std::string *pout) { do_iconv (pout, nullptr, nullptr); return *pout; } inline void iconv::reset (void) const noexcept { ::iconv (convdesc, nullptr, nullptr, nullptr, nullptr); } inline void iconv::do_iconv (std::string *pout, const char *inbuf, size_t *pinleft, std::string::size_type *pinpos) { if (pout->empty ()) { pout->resize (1); } const char *inbuf_tmp {inbuf}; char *outbuf {&pout->at (0)}; size_t outleft {pout->size ()}; size_t s; while ((s = ::iconv (convdesc, iconv_const_cast(&inbuf_tmp), pinleft, &outbuf, &outleft)) == static_cast(-1)) { if (errno != E2BIG) { if (pinpos && inbuf) { *pinpos = (inbuf_tmp - inbuf); } pout->resize (outbuf - &pout->at (0)); throw std::system_error (errno, std::system_category ()); } std::string::size_type pos = (outbuf - &pout->at (0)); pout->resize (pout->size () * 2); outbuf = &pout->at (pos); outleft = pout->size () - pos; } pout->resize (outbuf - &pout->at (0)); } } #endif // INCLUDE_GUARD_ICONV_WRAPPER_H extractpdfmark-1.0.2/src/main.cc000066400000000000000000000040231307470341200165530ustar00rootroot00000000000000// This file is part of Extract PDFmark. // // Copyright (C) 2016 Masamichi Hosoda // // Extract PDFmark is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Extract PDFmark 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Extract PDFmark. If not, see . #include "config.h" #include #include #include #include #include "cmdlineparse.hh" #include "output-pdfmark.hh" int main (int argc, char *argv[]) { cmdlineparse::parser cmd; std::unique_ptr opdfmark {create_output_pdfmark ()}; std::string output_filename; cmd.add_default (); cmd.add_string ('o', "output", &output_filename, "", " Output filename\n" " (Default: standard output)", "OUTPUT.ps"); opdfmark->add_options (&cmd); cmd.set_usage_unamed_opts ("INPUT.pdf"); if (!cmd.parse (argc, argv)) return 0; if (cmd.get_unamed_args ().empty ()) { std::cerr << cmd.get_version_string () << std::endl << cmd.build_usage () << std::endl; return 1; } std::ostream *pout; std::ofstream ofs; if (output_filename.empty () || output_filename == "-") { pout = &std::cout; } else { ofs.open (output_filename); pout = &ofs; } *pout << "% " << PACKAGE_STRING << std::endl << "% " << PACKAGE_URL << std::endl << std::endl; if (!opdfmark->open (cmd.get_unamed_args ().at (0))) return 1; opdfmark->parse_options (); *pout << opdfmark->pagemode (); *pout << opdfmark->destname (); return 0; } extractpdfmark-1.0.2/src/output-pdfmark.cc000066400000000000000000000032261307470341200206150ustar00rootroot00000000000000// This file is part of Extract PDFmark. // // Copyright (C) 2016 Masamichi Hosoda // // Extract PDFmark is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Extract PDFmark 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Extract PDFmark. If not, see . #include "config.h" #include "output-pdfmark.hh" #include #include #include "cmdlineparse.hh" void output_pdfmark::add_options (cmdlineparse::parser *cmd) { cmd->add_string (0, "style", &style, "literal", " Name style\n" " literal: literal strings\n" " hex: hexadecimal strings\n" " name: name object", "STYLE"); cmd->add_flag (0, "escape", &escape, " Escape all characters"); } void output_pdfmark::parse_options (void) { if (style == "literal") { hexadecimal = false; nameobject = false; } else if (style == "hex") { hexadecimal = true; nameobject = false; } else if (style == "name") { hexadecimal = false; nameobject = true; } else std::cerr << "unknown --style argument: " << style << std::endl; } extractpdfmark-1.0.2/src/output-pdfmark.hh000066400000000000000000000036001307470341200206230ustar00rootroot00000000000000// This file is part of Extract PDFmark. // // Copyright (C) 2016 Masamichi Hosoda // // Extract PDFmark is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Extract PDFmark 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Extract PDFmark. If not, see . #ifndef INCLUDE_GUARD_OUTPUT_PDFMARK_HH #define INCLUDE_GUARD_OUTPUT_PDFMARK_HH #include #include namespace cmdlineparse { class parser; } class output_pdfmark { public: virtual bool open (const std::string &pdf_filename) = 0; virtual std::string pagemode (void) = 0; virtual std::string destname (void) = 0; void add_options (cmdlineparse::parser *cmd); void parse_options (void); std::string encode_literal (const std::string &name) const; std::string encode_hexadecimal (const std::string &name) const; std::string encode_nameobject (const std::string &name) const; std::string encode_name (const std::string &name) const; output_pdfmark () = default; virtual ~output_pdfmark () = default; private: output_pdfmark (output_pdfmark const&) = delete; output_pdfmark (output_pdfmark&&) = delete; output_pdfmark& operator = (output_pdfmark const&) = delete; output_pdfmark& operator = (output_pdfmark&&) = delete; std::string style; bool escape = false; bool hexadecimal = false; bool nameobject = false; }; std::unique_ptr create_output_pdfmark (void); #endif // INCLUDE_GUARD_OUTPUT_PDFMARK_HH extractpdfmark-1.0.2/src/poppler-core/000077500000000000000000000000001307470341200177305ustar00rootroot00000000000000extractpdfmark-1.0.2/src/poppler-core/Makefile.am000066400000000000000000000003761307470341200217720ustar00rootroot00000000000000noinst_LIBRARIES = libextractpdfmark-poppler-core.a libextractpdfmark_poppler_core_a_SOURCES = poppler-core.cc poppler-core.hh \ pagemode.cc destname.cc destname-private.hh libextractpdfmark_poppler_core_a_CPPFLAGS = -I$(srcdir)/.. \ $(POPPLER_CFLAGS) extractpdfmark-1.0.2/src/poppler-core/destname-private.hh000066400000000000000000000035361307470341200235300ustar00rootroot00000000000000// This file is part of Extract PDFmark. // // Copyright (C) 2016 Masamichi Hosoda // // Extract PDFmark is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Extract PDFmark 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Extract PDFmark. If not, see . #ifndef INCLUDE_GUARD_DESTNAME_PRIVATE_HH #define INCLUDE_GUARD_DESTNAME_PRIVATE_HH #include // // *** FIX ME, UGLY *** // // poppler does not have destination name enumeration. // So forced to use a private member function. // // http://bloglitb.blogspot.jp/2010/07/access-to-private-members-thats-easy.html // https://gist.github.com/dabrahams/1528856 // template struct Accessor { static typename Tag::type value; }; template typename Tag::type Accessor::value; template struct Initializer { Initializer() { Accessor::value = p; } static Initializer instance; }; template Initializer Initializer::instance; struct Catalog_getDestNameTree { typedef NameTree* (Catalog::* type)(); }; template struct Initializer; inline NameTree *get_destnametree (Catalog *catalog) { return (catalog->*Accessor::value)(); } // // *** FIXME, UGLY *** // #endif // INCLUDE_GUARD_DESTNAME_PRIVATE_HH extractpdfmark-1.0.2/src/poppler-core/destname.cc000066400000000000000000000144751307470341200220520ustar00rootroot00000000000000// This file is part of Extract PDFmark. // // Copyright (C) 2016 Masamichi Hosoda // // Extract PDFmark is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Extract PDFmark 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Extract PDFmark. If not, see . #include "config.h" #include "poppler-core.hh" #include #include #include #include #include #include #ifndef HAVE_POPPLER_CORE_IF #include "destname-private.hh" #endif inline std::string goo_to_string (GooString *goo) { return std::string {goo->getCString (), static_cast(goo->getLength ())}; } inline void poppler_core::add_destname (GooString *name, LinkDest *link_dest) { std::string str = goo_to_string (name); add_destname (str, link_dest); } inline void poppler_core::add_destname (GooString *name) { std::string str = goo_to_string (name); std::unique_ptr link_dest {doc->findDest (name)}; add_destname (str, link_dest.get ()); } inline void poppler_core::add_destname (const char *name) { GooString goo {name}; std::unique_ptr link_dest {doc->findDest (&goo)}; add_destname (name, link_dest.get ()); } inline void poppler_core::add_destname (const std::string &name, LinkDest *link_dest) { if (link_dest) { name_map.insert (std::make_pair (name, *link_dest)); } } std::string poppler_core::build_destname (const std::string &name, LinkDest *link_dest) { std::stringstream ss; if (link_dest) { int pagenum; if (link_dest->isPageRef ()) { Ref page_ref = link_dest->getPageRef (); pagenum = doc->findPage (page_ref.num, page_ref.gen); } else { pagenum = link_dest->getPageNum (); } switch (link_dest->getKind ()) { case destXYZ: ss << "[ /Dest " << encode_name (name) << " /Page " << pagenum << " /View [/XYZ " << link_dest->getLeft () << " " << link_dest->getTop () << " " << link_dest->getZoom () << "] /DEST pdfmark" << std::endl; break; case destFit: ss << "[ /Dest " << encode_name (name) << " /Page " << pagenum << " /View [/Fit] /DEST pdfmark" << std::endl; break; case destFitH: ss << "[ /Dest " << encode_name (name) << " /Page " << pagenum << " /View [/FitH " << link_dest->getTop () << "] /DEST pdfmark" << std::endl; break; case destFitV: ss << "[ /Dest " << encode_name (name) << " /Page " << pagenum << " /View [/FitV " << link_dest->getLeft () << "] /DEST pdfmark" << std::endl; break; case destFitR: ss << "[ /Dest " << encode_name (name) << " /Page " << pagenum << " /View [/FitR " << link_dest->getLeft () << " " << link_dest->getBottom () << " " << link_dest->getRight () << " " << link_dest->getTop () << "] /DEST pdfmark" << std::endl; break; case destFitB: ss << "[ /Dest " << encode_name (name) << " /Page " << pagenum << " /View [/FitB] /DEST pdfmark" << std::endl; break; case destFitBH: ss << "[ /Dest " << encode_name (name) << " /Page " << pagenum << " /View [/FitBH " << link_dest->getTop () << "] /DEST pdfmark" << std::endl; break; case destFitBV: ss << "[ /Dest " << encode_name (name) << " /Page " << pagenum << " /View [/FitBV " << link_dest->getLeft () << "] /DEST pdfmark" << std::endl; break; default: ss << "% link_dest kind is unknown." << std::endl; break; } } else { ss << "% link_dest is null." << std::endl; } return ss.str (); } std::string poppler_core::build_destnames (void) { std::string str; for (auto &elm: name_map) { str += build_destname (elm.first, &elm.second); } return str; } #ifdef HAVE_POPPLER_CORE_IF // Use poppler-core interface std::string poppler_core::destname (void) { Catalog *catalog = doc->getCatalog (); name_map.clear (); if (catalog && catalog->isOk ()) { int len = catalog->numDestNameTree (); for (int i=0; igetDestNameTreeName (i), catalog->getDestNameTreeDest (i)); } len = catalog->numDests (); for (int i=0; igetDestsName (i), catalog->getDestsDest (i)); } } else std::cerr << "Catalog is not OK" << std::endl; return build_destnames (); } #else // HAVE_POPPLER_CORE_IF // Use poppler-core private access std::string poppler_core::destname (void) { Catalog *catalog = doc->getCatalog (); name_map.clear (); if (catalog && catalog->isOk ()) { NameTree *destnametree = get_destnametree (catalog); if (destnametree) { int len = destnametree->numEntries (); for (int i=0; igetName (i)); } } Object *obj = catalog->getDests (); if (obj && obj->isDict ()) { int len = obj->dictGetLength (); for (int i=0; idictGetKey (i)); } } } else std::cerr << "Catalog is not OK" << std::endl; return build_destnames (); } #endif // HAVE_POPPLER_CORE_IF extractpdfmark-1.0.2/src/poppler-core/pagemode.cc000066400000000000000000000034721307470341200220260ustar00rootroot00000000000000// This file is part of Extract PDFmark. // // Copyright (C) 2016 Masamichi Hosoda // // Extract PDFmark is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Extract PDFmark 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Extract PDFmark. If not, see . #include "config.h" #include "poppler-core.hh" #include #include std::string poppler_core::pagemode (void) { std::stringstream ss; Catalog *catalog = doc->getCatalog (); if (catalog && catalog->isOk ()) { switch (catalog->getPageMode ()) { case Catalog::pageModeOutlines: ss << "[ /PageMode /UseOutlines /DOCVIEW pdfmark" << std::endl; break; case Catalog::pageModeThumbs: ss << "[ /PageMode /UseThumbs /DOCVIEW pdfmark" << std::endl; break; case Catalog::pageModeFullScreen: ss << "[ /PageMode /FullScreen /DOCVIEW pdfmark" << std::endl; break; case Catalog::pageModeOC: ss << "% pageModeOC" << std::endl; break; case Catalog::pageModeAttach: ss << "% pageModeAttach" << std::endl; break; case Catalog::pageModeNone: default: ss << "[ /PageMode /UseNone /DOCVIEW pdfmark" << std::endl; break; } } else ss << "% PageMode unset" << std::endl; return ss.str (); } extractpdfmark-1.0.2/src/poppler-core/poppler-core.cc000066400000000000000000000027431307470341200226540ustar00rootroot00000000000000// This file is part of Extract PDFmark. // // Copyright (C) 2016 Masamichi Hosoda // // Extract PDFmark is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Extract PDFmark 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Extract PDFmark. If not, see . #include "config.h" #include "poppler-core.hh" #include #include #include #include std::unique_ptr create_output_pdfmark (void) { return std::unique_ptr (new poppler_core ()); } bool poppler_core::open (const std::string &pdf_filename) { std::unique_ptr fileName {new GooString {pdf_filename.c_str (), static_cast (pdf_filename.length ())}}; doc = std::unique_ptr {PDFDocFactory ().createPDFDoc (*fileName, NULL, NULL)}; if (!doc) { std::cerr << "open failed." << std::endl; return false; } if (!doc->isOk ()) { std::cerr << "file is not OK." << std::endl; return false; } return true; } extractpdfmark-1.0.2/src/poppler-core/poppler-core.hh000066400000000000000000000030141307470341200226560ustar00rootroot00000000000000// This file is part of Extract PDFmark. // // Copyright (C) 2016 Masamichi Hosoda // // Extract PDFmark is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Extract PDFmark 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Extract PDFmark. If not, see . #ifndef INCLUDE_GUARD_POPPLER_CORE_HH #define INCLUDE_GUARD_POPPLER_CORE_HH #include #include #include #include #include "output-pdfmark.hh" class PDFDoc; class poppler_core : public output_pdfmark { public: bool open (const std::string &pdf_filename); std::string pagemode (void); std::string destname (void); private: std::string build_destname (const std::string &name, LinkDest *link_dest); std::string build_destnames (void); void add_destname (const std::string &name, LinkDest *link_dest); void add_destname (GooString *name, LinkDest *link_dest); void add_destname (GooString *name); void add_destname (const char *name); std::unique_ptr doc; std::map name_map; }; #endif // INCLUDE_GUARD_POPPLER_CORE_HH extractpdfmark-1.0.2/src/poppler-glib/000077500000000000000000000000001307470341200177155ustar00rootroot00000000000000extractpdfmark-1.0.2/src/poppler-glib/Makefile.am000066400000000000000000000003711307470341200217520ustar00rootroot00000000000000noinst_LIBRARIES = libextractpdfmark-poppler-glib.a libextractpdfmark_poppler_glib_a_SOURCES = poppler-glib.cc poppler-glib.hh \ pagemode-glib.cc destname-glib.cc libextractpdfmark_poppler_glib_a_CPPFLAGS = -I$(srcdir)/.. \ $(POPPLER_GLIB_CFLAGS) extractpdfmark-1.0.2/src/poppler-glib/destname-glib.cc000066400000000000000000000101561307470341200227420ustar00rootroot00000000000000// This file is part of Extract PDFmark. // // Copyright (C) 2016 Masamichi Hosoda // // Extract PDFmark is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Extract PDFmark 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Extract PDFmark. If not, see . #include "config.h" #include "poppler-glib.hh" #include #include #include #include gboolean poppler_glib::walk_entry (gpointer key, gpointer value, gpointer user_data) { GBytes *name = static_cast (key); PopplerDest *dest = static_cast (value); poppler_glib *pg = static_cast (user_data); return pg->walk (name, dest); } bool poppler_glib::walk (GBytes *name, PopplerDest *dest) { std::string n {static_cast (g_bytes_get_data (name, nullptr)), static_cast (g_bytes_get_size (name))}; std::stringstream ss; if (dest) { switch (dest->type) { case POPPLER_DEST_XYZ: ss << "[ /Dest " << encode_name (n) << " /Page " << dest->page_num << " /View [/XYZ " << dest->left << " " << dest->top << " " << dest->zoom << "] /DEST pdfmark" << std::endl; break; case POPPLER_DEST_FIT: ss << "[ /Dest " << encode_name (n) << " /Page " << dest->page_num << " /View [/Fit] /DEST pdfmark" << std::endl; break; case POPPLER_DEST_FITH: ss << "[ /Dest " << encode_name (n) << " /Page " << dest->page_num << " /View [/FitH " << dest->top << "] /DEST pdfmark" << std::endl; break; case POPPLER_DEST_FITV: ss << "[ /Dest " << encode_name (n) << " /Page " << dest->page_num << " /View [/FitV " << dest->left << "] /DEST pdfmark" << std::endl; break; case POPPLER_DEST_FITR: ss << "[ /Dest " << encode_name (n) << " /Page " << dest->page_num << " /View [/FitR " << dest->left << " " << dest->bottom << " " << dest->right << " " << dest->top << "] /DEST pdfmark" << std::endl; break; case POPPLER_DEST_FITB: ss << "[ /Dest " << encode_name (n) << " /Page " << dest->page_num << " /View [/FitB] /DEST pdfmark" << std::endl; break; case POPPLER_DEST_FITBH: ss << "[ /Dest " << encode_name (n) << " /Page " << dest->page_num << " /View [/FitBH " << dest->top << "] /DEST pdfmark" << std::endl; break; case POPPLER_DEST_FITBV: ss << "[ /Dest " << encode_name (n) << " /Page " << dest->page_num << " /View [/FitBV " << dest->left << "] /DEST pdfmark" << std::endl; break; default: ss << "% dest type is unknown." << std::endl; break; } } else { ss << "% dest is null." << std::endl; } dests += ss.str (); // return value is used for GTraverseFunc ()'s return value. // false means to continue the travarsal (true means to stop) return false; } std::string poppler_glib::destname (void) { std::unique_ptr tree {poppler_document_build_dests_tree (document), g_tree_destroy}; dests.clear (); g_tree_foreach (tree.get (), walk_entry, this); std::string tmp {std::move(dests)}; dests.clear (); return tmp; } extractpdfmark-1.0.2/src/poppler-glib/pagemode-glib.cc000066400000000000000000000036311307470341200227230ustar00rootroot00000000000000// This file is part of Extract PDFmark. // // Copyright (C) 2016 Masamichi Hosoda // // Extract PDFmark is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Extract PDFmark 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Extract PDFmark. If not, see . #include "config.h" #include "poppler-glib.hh" #include #include #include #include std::string poppler_glib::pagemode (void) { std::stringstream ss; if (!document) { std::cerr << "% document is null" << std::endl; return ""; } switch (poppler_document_get_page_mode (document)) { case POPPLER_PAGE_MODE_UNSET: case POPPLER_PAGE_MODE_NONE: ss << "[ /PageMode /UseNone /DOCVIEW pdfmark" << std::endl; break; case POPPLER_PAGE_MODE_USE_OUTLINES: ss << "[ /PageMode /UseOutlines /DOCVIEW pdfmark" << std::endl; break; case POPPLER_PAGE_MODE_USE_THUMBS: ss << "[ /PageMode /UseThumbs /DOCVIEW pdfmark" << std::endl; break; case POPPLER_PAGE_MODE_FULL_SCREEN: ss << "[ /PageMode /FullScreen /DOCVIEW pdfmark" << std::endl; break; case POPPLER_PAGE_MODE_USE_OC: ss << "% PageMode POPPLER_MODE_USE_OC" << std::endl; break; case POPPLER_PAGE_MODE_USE_ATTACHMENTS: ss << "% PageMode POPPLER_MODE_USE_ATTACHMENTS" << std::endl; break; default: ss << "% PageMode unknown" << std::endl; break; } return ss.str (); } extractpdfmark-1.0.2/src/poppler-glib/poppler-glib.cc000066400000000000000000000047571307470341200226350ustar00rootroot00000000000000// This file is part of Extract PDFmark. // // Copyright (C) 2016 Masamichi Hosoda // // Extract PDFmark is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Extract PDFmark 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Extract PDFmark. If not, see . #include "config.h" #include "poppler-glib.hh" #include #include #include #include std::unique_ptr create_output_pdfmark (void) { return std::unique_ptr (new poppler_glib ()); } namespace { std::string get_uri (const std::string &filename) { std::string abs_filename; if (g_path_is_absolute (filename.c_str ())) abs_filename = filename; else { std::unique_ptr dir {g_get_current_dir (), g_free}; std::unique_ptr abs {g_build_filename (dir.get (), filename.c_str (), nullptr), g_free}; abs_filename = abs.get (); } GError *error {nullptr}; std::unique_ptr uri {g_filename_to_uri (abs_filename.c_str (), nullptr, &error), g_free}; if (!uri) { std::cerr << "g_filename_to_uri failed: " << abs_filename; if (error) { std::cerr << ": " << error->message << std::endl; g_error_free (error); } else { std::cerr << std::endl; } return ""; } return uri.get (); } } bool poppler_glib::open (const std::string &pdf_filename) { GError *error {nullptr}; document = poppler_document_new_from_file (get_uri (pdf_filename).c_str (), nullptr, &error); if (!document) { std::cerr << "poppler_document_new_from_file failed: " << pdf_filename; if (error) { std::cerr << ": " << error->message << std::endl; g_error_free (error); } else { std::cerr << std::endl; } return false; } return true; } extractpdfmark-1.0.2/src/poppler-glib/poppler-glib.hh000066400000000000000000000026061307470341200226360ustar00rootroot00000000000000// This file is part of Extract PDFmark. // // Copyright (C) 2016 Masamichi Hosoda // // Extract PDFmark is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Extract PDFmark 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Extract PDFmark. If not, see . #ifndef INCLUDE_GUARD_POPPLER_GLIB_HH #define INCLUDE_GUARD_POPPLER_GLIB_HH #include #include #include "output-pdfmark.hh" class poppler_glib : public output_pdfmark { public: bool open (const std::string &pdf_filename); std::string pagemode (void); std::string destname (void); ~poppler_glib () { g_clear_object (&document); } private: static gboolean walk_entry (gpointer key, gpointer value, gpointer user_data); bool walk (GBytes *name, PopplerDest *dest); PopplerDocument *document = nullptr; std::string dests; }; #endif // INCLUDE_GUARD_POPPLER_GLIB_HH extractpdfmark-1.0.2/src/utf16.cc000066400000000000000000000016251307470341200166010ustar00rootroot00000000000000// This file is part of Extract PDFmark. // // Copyright (C) 2016 Masamichi Hosoda // // Extract PDFmark is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Extract PDFmark 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Extract PDFmark. If not, see . #include "config.h" #include "utf16.hh" #include bool is_utf16 (const std::string &str) { return (str.length () >= 2) && str[0] == '\xfe' && str[1] == '\xff'; } extractpdfmark-1.0.2/src/utf16.hh000066400000000000000000000016021307470341200166060ustar00rootroot00000000000000// This file is part of Extract PDFmark. // // Copyright (C) 2016 Masamichi Hosoda // // Extract PDFmark is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Extract PDFmark 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Extract PDFmark. If not, see . #ifndef INCLUDE_GUARD_UTF16_HH #define INCLUDE_GUARD_UTF16_HH #include bool is_utf16 (const std::string &str); #endif // INCLUDE_GUARD_UTF16_HH extractpdfmark-1.0.2/src/utf8.cc000066400000000000000000000033161307470341200165210ustar00rootroot00000000000000// This file is part of Extract PDFmark. // // Copyright (C) 2016 Masamichi Hosoda // // Extract PDFmark is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Extract PDFmark 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Extract PDFmark. If not, see . #include "config.h" #include "utf8.hh" #ifdef USE_CODECVT #include #include #endif #include #ifdef USE_ICONV #include "iconv_wrapper.hh" #endif #ifdef USE_CODECVT bool is_utf8 (const std::string &str) { std::codecvt_utf8 cvt; auto mb {std::mbstate_t ()}; return (cvt.length (mb, &str.front (), &str.front () + str.length (), std::string::npos) == str.length ()); } #else // USE_CODECVT #ifdef USE_ICONV bool is_utf8 (const std::string &str) { try { iconv_wrapper::iconv cvt8to16 {"UTF-8", "UTF-16"}; std::string utf16 {cvt8to16.convert (str)}; iconv_wrapper::iconv cvt16to8 {"UTF-16", "UTF-8"}; std::string utf8 {cvt16to8.convert (utf16)}; return (str == utf8); } catch (std::system_error &error) { return false; } return false; } #else // USE_ICONV bool is_utf8 (const std::string &str) { return false; } #endif // USE_ICONV #endif // USE_CODECVT extractpdfmark-1.0.2/src/utf8.hh000066400000000000000000000015761307470341200165410ustar00rootroot00000000000000// This file is part of Extract PDFmark. // // Copyright (C) 2016 Masamichi Hosoda // // Extract PDFmark is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Extract PDFmark 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Extract PDFmark. If not, see . #ifndef INCLUDE_GUARD_UTF8_HH #define INCLUDE_GUARD_UTF8_HH #include bool is_utf8 (const std::string &str); #endif // INCLUDE_GUARD_UTF8_HH extractpdfmark-1.0.2/test/000077500000000000000000000000001307470341200155115ustar00rootroot00000000000000extractpdfmark-1.0.2/test/Makefile.am000066400000000000000000000117011307470341200175450ustar00rootroot00000000000000TESTS = $(TESTMARKS) $(TESTROUNDS) TEST_EXTENSIONS = .pdfmark .ps PDFMARK_LOG_COMPILER = $(srcdir)/test-expected-pdfmark.sh PS_LOG_COMPILER = $(srcdir)/test-round.sh TESTS_ENVIRONMENT = top_builddir=$(top_builddir) \ srcdir=$(srcdir) \ GREP=$(GREP) \ DIFF=$(DIFF) \ GHOSTSCRIPT=$(GHOSTSCRIPT) # Source files for test PDFs TESTTEXS = binary.tex destonly.tex desttype.tex nodest.tex \ pdfdocencoding.tex utf16.tex utf8.tex special-chars.tex \ pagemode-usenone.tex pagemode-thumbs.tex pagemode-fullscreen.tex # Test PDFs TESTPDFS = $(TESTTEXS:.tex=.pdf) namedict.pdf # Expected PDFmark for expected pdf test TESTMARKS = $(TESTPDFS:.pdf=-expected.pdfmark) \ destonly-expected-literal-escape.pdfmark \ destonly-expected-hex.pdfmark \ destonly-expected-name.pdfmark \ destonly-expected-name-escape.pdfmark \ utf8-expected-literal-escape.pdfmark \ utf8-expected-hex.pdfmark \ utf8-expected-name.pdfmark \ utf8-expected-name-escape.pdfmark \ special-chars-expected-literal-escape.pdfmark \ special-chars-expected-hex.pdfmark \ special-chars-expected-name.pdfmark \ special-chars-expected-name-escape.pdfmark # Extracted PDFmark for round test TESTROUNDS = $(TESTPDFS:.pdf=-round.ps) \ destonly-round-literal-escape.ps \ destonly-round-hex.ps \ destonly-round-name.ps \ utf8-round-literal-escape.ps \ utf8-round-hex.ps \ special-chars-round-literal-escape.ps \ special-chars-round-hex.ps # TESTROUNDS should not be contained. EXTRA_DIST = test-round.sh test-expected-pdfmark.sh addnamedict.ps \ $(TESTTEXS) $(TESTPDFS) $(TESTMARKS) # For `make clean' CLEANFILES = $(TESTMARKS:-expected.pdfmark=-expected-test.pdfmark) \ $(TESTMARKS:-expected-literal-escape.pdfmark=-expected-literal-escape-test.pdfmark) \ $(TESTMARKS:-expected-hex.pdfmark=-expected-hex-test.pdfmark) \ $(TESTMARKS:-expected-name.pdfmark=-expected-name-test.pdfmark) \ $(TESTMARKS:-expected-name-escape.pdfmark=-expected-name-escape-test.pdfmark) \ $(TESTROUNDS:-round.ps=-round-test.pdf) \ $(TESTROUNDS:-round.ps=-round-test.ps) \ $(TESTROUNDS:-round-literal-escape.ps=-round-literal-escape-test.pdf) \ $(TESTROUNDS:-round-literal-escape.ps=-round-literal-escape-test.ps) \ $(TESTROUNDS:-round-hex.ps=-round-hex-test.pdf) \ $(TESTROUNDS:-round-hex.ps=-round-hex-test.ps) \ $(TESTROUNDS:-round-name.ps=-round-name-test.pdf) \ $(TESTROUNDS:-round-name.ps=-round-name-test.ps) \ $(TESTROUNDS:-round-name-escape.ps=-round-name-escape-test.pdf) \ $(TESTROUNDS:-round-name-escape.ps=-round-name-escape-test.ps) if HAVE_GHOSTSCRIPT # For name object (PDF 1.1) handling test # PDF 1.2+ uses name tree intead of name object. # So most PDFs use name tree for named destination. namedict.pdf: nodest.pdf addnamedict.ps $(GHOSTSCRIPT) -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=$@ \ -dCompatibilityLevel=1.1 $^ else namedict.pdf: touch $@ endif # Generate test PDFs # Tarball contains them for convenience. %.pdf: %.tex $(PDFTEX) $< # Generate expected PDFmark # Tarball should contain them for checking outputs. %-expected.pdfmark: %.pdf $(top_builddir)/src/extractpdfmark $< | \ $(GREP) -v "^%\|^$$" > $@ # Generate expected PDFmark with hexadecimal style # Tarball should contain them for checking outputs. %-expected-hex.pdfmark: %.pdf $(top_builddir)/src/extractpdfmark --style=hex $< | \ $(GREP) -v "^%\|^$$" > $@ # Generate expected PDFmark with literal style full escaped # Tarball should contain them for checking outputs. %-expected-literal-escape.pdfmark: %.pdf $(top_builddir)/src/extractpdfmark --style=literal --escape $< | \ $(GREP) -v "^%\|^$$" > $@ # Generate expected PDFmark with name style # Tarball should contain them for checking outputs. %-expected-name.pdfmark: %.pdf $(top_builddir)/src/extractpdfmark --style=name $< | \ $(GREP) -v "^%\|^$$" > $@ # Generate expected PDFmark with name style full escaped # Tarball should contain them for checking outputs. %-expected-name-escape.pdfmark: %.pdf $(top_builddir)/src/extractpdfmark --style=name --escape $< | \ $(GREP) -v "^%\|^$$" > $@ # Generate extracted PDFmark # Tarball should not contain them for checking building environment. %-round.ps: %.pdf $(top_builddir)/src/extractpdfmark -o $@ $< # Generate extracted PDFmark with hexadecimal style # Tarball should not contain them for checking building environment. %-round-hex.ps: %.pdf $(top_builddir)/src/extractpdfmark --style=hex -o $@ $< # Generate extracted PDFmark with literal style full escaped # Tarball should not contain them for checking building environment. %-round-literal-escape.ps: %.pdf $(top_builddir)/src/extractpdfmark --style=literal --escape -o $@ $< # Generate extracted PDFmark with name style # Tarball should not contain them for checking building environment. %-round-name.ps: %.pdf $(top_builddir)/src/extractpdfmark --style=name -o $@ $< # Generate extracted PDFmark with name style full escaped # Tarball should not contain them for checking building environment. %-round-name-escape.ps: %.pdf $(top_builddir)/src/extractpdfmark --style=name --escape -o $@ $< extractpdfmark-1.0.2/test/addnamedict.ps000066400000000000000000000001701307470341200203100ustar00rootroot00000000000000[ /Dest /one /Page 1 /View [/XYZ 72 769.89 0] /DEST pdfmark [ /Dest /two /Page 2 /View [/XYZ 72 769.89 0] /DEST pdfmark extractpdfmark-1.0.2/test/binary.tex000066400000000000000000000012471307470341200175230ustar00rootroot00000000000000% Check for binary (broken UTF-16) destination names %\pdfobjcompresslevel=0 \pdfcatalog{/PageMode /UseOutlines} \catcode0=12 % US-ASCII for title \def\furonetitle{fur one} \def\furtwotitle{fur two} % binary (broken UTF-16) for destination name \def\furonename{^^ff^^fe^^00f^^00^^fc^^00r^^00 ^^00o^^00n^^00e} \def\furtwoname{^^ff^^fe^^00f^^00^^fc^^00r^^00 ^^00t^^00w^^00o} % Destination name could be binary. % title shuld be PDFDocEncoding (also US-ASCII) or UTF-16. \pdfoutline goto name{\furonename} {\furonetitle} \pdfoutline goto name{\furtwoname} {\furtwotitle} \pdfdest name{\furonename} xyz page 1 \vfill \eject \pdfdest name{\furtwoname} xyz page 2 \vfill \end extractpdfmark-1.0.2/test/destonly.tex000066400000000000000000000002361307470341200200750ustar00rootroot00000000000000% Check for no links, destination only PDF %\pdfobjcompresslevel=0 \pdfdest name{one} xyz page 1 \vfill \eject \pdfdest name{two} xyz page 2 \vfill \end extractpdfmark-1.0.2/test/desttype.tex000066400000000000000000000021341307470341200200740ustar00rootroot00000000000000% Check for some destination types %\pdfobjcompresslevel=0 \pdfcatalog{/PageMode /UseOutlines} \pdfoutline goto name{fit} {fit} \pdfoutline goto name{fith} {fith} \pdfoutline goto name{fitv} {fitv} \pdfoutline goto name{fitr} {fitr} \pdfoutline goto name{fitb} {fitb} \pdfoutline goto name{fitbh} {fitbh} \pdfoutline goto name{fitbv} {fitbv} \pdfoutline goto name{xyz} {xyz} \pdfoutline goto name{xyz zoom 1000} {xyz zoom 1000} \pdfoutline goto name{xyz zoom 500} {xyz zoom 500} \pdfoutline goto name{xyz zoom 2000} {xyz zoom 2000} \pdfdest name{fit} fit fit \vfill \eject \pdfdest name{fith} fith fith \vfill \eject \pdfdest name{fitv} fitv fitv \vfill \eject \pdfdest name{fitr} fitr fitr \vfill \eject \pdfdest name{fitb} fitb fitb \vfill \eject \pdfdest name{fitbh} fitbh fitbh \vfill \eject \pdfdest name{fitbv} fitbv fitbv \vfill \eject \pdfdest name{xyz} xyz xyz \vfill \eject \pdfdest name{xyz zoom 1000} xyz zoom 1000 xyz zoom 1000 \vfill \eject \pdfdest name{xyz zoom 500} xyz zoom 500 xyz zoom 500 \vfill \eject \pdfdest name{xyz zoom 2000} xyz zoom 2000 xyz zoom 2000 \vfill \end extractpdfmark-1.0.2/test/nodest.tex000066400000000000000000000001401307470341200175220ustar00rootroot00000000000000% Check for no destination %\pdfobjcompresslevel=0 page 1 \vfill \eject page 2 \vfill \end extractpdfmark-1.0.2/test/pagemode-fullscreen.tex000066400000000000000000000002101307470341200221450ustar00rootroot00000000000000% Check for pagemode FullScreen %\pdfobjcompresslevel=0 \pdfcatalog{/PageMode /FullScreen} page 1 \vfill \eject page 2 \vfill \end extractpdfmark-1.0.2/test/pagemode-thumbs.tex000066400000000000000000000002061307470341200213120ustar00rootroot00000000000000% Check for pagemode UseThumbs %\pdfobjcompresslevel=0 \pdfcatalog{/PageMode /UseThumbs} page 1 \vfill \eject page 2 \vfill \end extractpdfmark-1.0.2/test/pagemode-usenone.tex000066400000000000000000000002021307470341200214600ustar00rootroot00000000000000% Check for pagemode UseNone %\pdfobjcompresslevel=0 \pdfcatalog{/PageMode /UseNone} page 1 \vfill \eject page 2 \vfill \end extractpdfmark-1.0.2/test/pdfdocencoding.tex000066400000000000000000000007121307470341200212010ustar00rootroot00000000000000% Check for PDFDocEncoding destination names %\pdfobjcompresslevel=0 \pdfcatalog{/PageMode /UseOutlines} % PDFDocEncoding (nearly Latin-1) \def\furone{f^^fcr one}% f\"ur one \def\furtwo{f^^fcr two}% f\"ur two % PDFDocEncoding can be used for both destination name and title. \pdfoutline goto name{\furone} {\furone} \pdfoutline goto name{\furtwo} {\furtwo} \pdfdest name{\furone} xyz page 1 \vfill \eject \pdfdest name{\furtwo} xyz page 2 \vfill \end extractpdfmark-1.0.2/test/special-chars.tex000066400000000000000000000035351307470341200207570ustar00rootroot00000000000000% Check for special character destination names %\pdfobjcompresslevel=0 \pdfcatalog{/PageMode /UseOutlines} \catcode`\@=0 @catcode`@\=11 @def@bs{\} @catcode`@\=0 \catcode`@=12 % Destination name could be binary. % title shuld be PDFDocEncoding (also US-ASCII) or UTF-16. \pdfoutline goto name{^^20} {U+0020 SPACE} \pdfoutline goto name{\bs 050} {U+0028 LEFT PARENTHESIS} \pdfoutline goto name{\bs 051} {U+0029 RIGHT PARENTHESIS} \pdfoutline goto name{<} {U+003C LESS-THAN SIGN} \pdfoutline goto name{>} {U+003E GREATER-THAN SIGN} \pdfoutline goto name{[} {U+005B LEFT SQUARE BRACKET} \pdfoutline goto name{]} {U+005D RIGHT SQUARE BRACKET} \pdfoutline goto name{\bs 173} {U+007B LEFT CURLY BRACKET} \pdfoutline goto name{\bs 175} {U+007D RIGHT CURLY BRACKET} \pdfoutline goto name{/} {U+002F SOLIDUS} \pdfoutline goto name{\bs 134} {U+005C REVERSE SOLIDUS} \pdfoutline goto name{\bs 045} {U+0025 PERCENT SIGN} \pdfoutline goto name{\bs 043} {U+0023 NUMBER SIGN} \pdfoutline goto name{\bs 177} {U+007F DELETE} \pdfdest name{^^20} xyz U+0020 SPACE \vfill \eject \pdfdest name{\bs 050} xyz U+0028 LEFT PARENTHESIS \vfill \eject \pdfdest name{\bs 051} xyz U+0029 RIGHT PARENTHESIS \vfill \eject \pdfdest name{<} xyz U+003C LESS-THAN SIGN \vfill \eject \pdfdest name{>} xyz U+003E GRATER-THAN SIGN \vfill \eject \pdfdest name{[} xyz U+005B LEFT SQUARE BRACKET \vfill \eject \pdfdest name{]} xyz U+005D RIGHT SQUARE BRACKET \vfill \eject \pdfdest name{\bs 173} xyz U+007B LEFT CURLY BRACKET \vfill \eject \pdfdest name{\bs 175} xyz U+007D RIGHT CURLY BRACKET \vfill \eject \pdfdest name{/} xyz U+002F SOLIDUS \vfill \eject \pdfdest name{\bs 134} xyz U+005C REVERSE SOLIDUS \vfill \eject \pdfdest name{\bs 045} xyz U+0025 PERCENT SIGN \vfill \eject \pdfdest name{\bs 043} xyz U+0023 NUMBER SIGN \vfill \eject \pdfdest name{\bs 177} xyz U+007F DELETE \vfill \end extractpdfmark-1.0.2/test/test-expected-pdfmark.sh000077500000000000000000000020071307470341200222470ustar00rootroot00000000000000#!/bin/sh EXPECTEDPDFMARK=$1 BASENAME=`basename ${EXPECTEDPDFMARK} | sed -e "s/-expected\(-.\+\)\?\.pdfmark$//"` OPTSUFFIX=`echo ${EXPECTEDPDFMARK} | sed -e "s/^\(.*-expected\)\(-.\+\)\?\.pdfmark$/\2/"` PDF="${BASENAME}.pdf" EXTRACTEDPDFMARK="${BASENAME}-expected${OPTSUFFIX}-test.pdfmark" if [ ! -e ${EXPECTEDPDFMARK} ]; then EXPEXTEDPDFMARK="${srcdir}/${BASENAME}-expected${OPTSUFFIX}.pdfmark" fi if [ ! -e ${PDF} ]; then PDF="${srcdir}/${BASENAME}.pdf" fi if [ ! -s ${PDF} ]; then # skip exit 77 fi case "$OPTSUFFIX" in "-literal" ) OPTION="--style=literal" ;; "-literal-escape" ) OPTION="--style=literal --escape" ;; "-hex" ) OPTION="--style=hex" ;; "-name" ) OPTION="--style=name" ;; "-name-escape" ) OPTION="--style=name --escape" ;; * ) OPTION="" ;; esac ${top_builddir}/src/extractpdfmark ${OPTION} ${PDF} | \ ${GREP} -v "^%\|^$" > ${EXTRACTEDPDFMARK} if test x"$DIFF" = x; then # skip exit 77 fi ${DIFF} -ubwBE ${EXPECTEDPDFMARK} ${EXTRACTEDPDFMARK} extractpdfmark-1.0.2/test/test-round.sh000077500000000000000000000020721307470341200201550ustar00rootroot00000000000000#!/bin/sh EXTRACTEDPDFMARK=$1 BASENAME=`basename ${EXTRACTEDPDFMARK} | sed -e "s/-round\(-.\+\)\?\.ps$//"` OPTSUFFIX=`echo ${EXTRACTEDPDFMARK} | sed -e "s/^\(.*-round\)\(-.\+\)\?\.ps$/\2/"` PDF="${BASENAME}.pdf" PDF2="${BASENAME}-round${OPTSUFFIX}-test.pdf" EXTRACTEDPDFMARK2="${BASENAME}-round${OPTSUFFIX}-test.ps" if [ ! -e ${PDF} ]; then PDF="${srcdir}/${BASENAME}.pdf" fi if [ ! -s ${PDF} ]; then # skip exit 77 fi case "$OPTSUFFIX" in "-literal" ) OPTION="--style=literal" ;; "-literal-escape" ) OPTION="--style=literal --escape" ;; "-hex" ) OPTION="--style=hex" ;; "-name" ) OPTION="--style=name" ;; "-name-escape" ) OPTION="--style=name --escape" ;; * ) OPTION="" ;; esac if test x"$GHOSTSCRIPT" = x; then # skip exit 77 fi ${GHOSTSCRIPT} -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=${PDF2} \ ${PDF} ${EXTRACTEDPDFMARK} ${top_builddir}/src/extractpdfmark ${OPTION} -o ${EXTRACTEDPDFMARK2} ${PDF2} if test x"$DIFF" = x; then # skip exit 77 fi ${DIFF} -u ${EXTRACTEDPDFMARK} ${EXTRACTEDPDFMARK2} extractpdfmark-1.0.2/test/utf16.tex000066400000000000000000000007671307470341200172120ustar00rootroot00000000000000% Check for UTF-16 destination names %\pdfobjcompresslevel=0 \pdfcatalog{/PageMode /UseOutlines} \catcode0=12 % UTF-16 \def\furone{^^fe^^ff^^00f^^00^^fc^^00r^^00 ^^00o^^00n^^00e}% f\"ur one \def\furtwo{^^fe^^ff^^00f^^00^^fc^^00r^^00 ^^00t^^00w^^00o}% f\"ur two % UTF-16 can be used for both destination name and title. \pdfoutline goto name{\furone} {\furone} \pdfoutline goto name{\furtwo} {\furtwo} \pdfdest name{\furone} xyz page 1 \vfill \eject \pdfdest name{\furtwo} xyz page 2 \vfill \end extractpdfmark-1.0.2/test/utf8.tex000066400000000000000000000012721307470341200171230ustar00rootroot00000000000000% Check for UTF-8 destination names %\pdfobjcompresslevel=0 \pdfcatalog{/PageMode /UseOutlines} \catcode0=12 % UTF-16 for title \def\furonetitle{^^fe^^ff^^00f^^00^^fc^^00r^^00 ^^00o^^00n^^00e}% f\"ur one \def\furtwotitle{^^fe^^ff^^00f^^00^^fc^^00r^^00 ^^00t^^00w^^00o}% f\"ur two % UTF-8 for destination name \def\furonename{f^^c3^^bcr one}% f\"ur one \def\furtwoname{f^^c3^^bcr two}% f\"ur two % Destination name could be binary (also UTF-8). % title shuld be PDFDocEncoding or UTF-16. \pdfoutline goto name{\furonename} {\furonetitle} \pdfoutline goto name{\furtwoname} {\furtwotitle} \pdfdest name{\furonename} xyz page 1 \vfill \eject \pdfdest name{\furtwoname} xyz page 2 \vfill \end