├── LICENSE ├── README.md ├── Screenshots ├── Screenshot_1.png └── Screenshot_2.png ├── code ├── README.md ├── pdfguiUtils.py ├── pdfguiWindows.py └── pdfgui_tools.py ├── designer ├── README.md ├── about.ui └── pdfgui_tools.ui ├── desktop └── pdfgui_tools.desktop ├── icons └── pdfguitools.svg ├── install.py ├── man └── pdfgui_tools.1 └── styles └── styles.css /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | [![GitHub release](https://img.shields.io/github/release/TheWatcherMultiversal/pdfgui_tools.svg)](https://github.com/TheWatcherMultiversal/pdfgui_tools/releases) 5 | [![GitHub last commit](https://img.shields.io/github/last-commit/TheWatcherMultiversal/pdfgui_tools)](https://github.com/TheWatcherMultiversal/pdfgui_tools/) 6 | [![GitHub license](https://img.shields.io/badge/license-GPLv3.0-brown)](https://github.com/TheWatcherMultiversal/pdfgui_tools/blob/main/LICENSE) 7 | [![Poppler version](https://img.shields.io/badge/poppler--utils-23.08-orange)](https://poppler.freedesktop.org/) 8 | [![PySide6 version](https://img.shields.io/badge/PySide6-6.6.0-green)](https://pypi.org/project/PySide6/) 9 | [![PyPDF2 version](https://img.shields.io/badge/PyPDF2-1.26.0-red)](https://pypi.org/project/PyPDF2/) 10 | [![PyMuPDF version](https://img.shields.io/badge/PyMuPDF-1.23.5-0b8c2c)](https://pypi.org/project/PyMuPDF/) 11 | 12 | --- 13 | 14 |
15 |

Technologies used:

16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 |
25 |

pdfgui_tools 26 |

27 |
28 | 29 |
30 | 31 | **pdfgui_tools** is a user interface tool developed in Qt and Python that integrates with **poppler-utils** and **PyPDF2** for PDF document management. It's a **simple** and **user-friendly** tool that includes various utilities such as merging PDFs, splitting PDFs, converting them to multimedia files like PNG or SVG, encrypting or decrypting, among other utilities included in pdfgui_tools. 32 | 33 |
34 |

pdfgui_tools 35 |

36 | 37 | ![1](./Screenshots/Screenshot_1.png?raw=true) 38 | 39 | # Sections 40 | ### Install pdfgui_tools: 41 | - [Debian-based distributions](#install-via-deb-package) 42 | - [Arch-based distributions (AUR) - Unofficial](#install-from-aur-yay) 43 | - [Install using a script](#install-using-a-script) 44 | 45 | ### Using pdfgui_tools: 46 | - [Start using pdfgui_tools](#start-using-pdfgui_tools) 47 | 48 | ### Important: 49 | - [Dependencies](#dependencies) 50 | - [Report bugs or give suggestions](#report-bugs-or-give-suggestions) 51 | 52 | ## Install via deb package 53 | To install pdfgui_tools, you will first need to download the **Debian package**, which can be found at the following link: 54 | 55 | 📦 Download deb package 56 | 57 | > Note: This will download the default version with the `amd64` **architecture**. If you want to install the version with `all` architectures, it is recommended to read the [Dependencies](#dependencies) section. 58 | 59 | Once we have our **Debian package** installed, simply execute the following command, and it will be downloaded to our system: 60 | 61 | sudo dpkg -i pdfgui_tools_stable-release_2.0.0_amd64.deb 62 | 63 | > Note: If we find any missing dependencies, it's just a matter of installing them with the `sudo apt install -f` command 64 | 65 | Now we just need to check if the program was installed correctly, for this we execute the following: 66 | 67 | pdfgui_tools 68 | 69 | ## Install from AUR (yay) - Unofficial 70 | In case you are using an **Arch-based** distribution, you can download pdfgui_tools from **AUR** using `yay`: 71 | 72 | yay -S pdfgui_tools-bin 73 | 74 |

You can find the package at this link, thanks to begin-theadventure.

75 | 76 | ## Install using a script 77 | If you don't have a **Debian-based** distribution or don't want to install from the **AUR**, you can install **pdfgui_tools** using the installation script `./install.py`. Before starting, first install **python3-colorama** to avoid import conflicts 78 | 79 | To do this, first make sure that the `./install.py` script have the necessary permissions to run on the system: 80 | 81 | chmod 755 ./install.py 82 | 83 | Now we can install pdfgui_tools by running the installation script: 84 | 85 | ./install.py 86 | 87 | If you want to install the version for **all architectures**, use the `--arch-all` option. 88 | 89 | > Note: This will install the default version with the `x86_64` **architecture**. If you need to install the `all` **architecture** version, which contains the unpacked Python packages, you will need to install the dependencies. Refer to the [Dependencies](#dependencies) section for more information. 90 | 91 | To **uninstall pdfgui_tools**, simply use the argument `-u` or `--uninstall` to perform this action. 92 | 93 | ### poppler-utils 94 | 95 | In a special case where your distribution doesn't include the **poppler-utils** package in its repositories, use the `--all` parameter of the installation script to include **poppler-utils** in the installation: 96 | 97 | ./install.py --all 98 | 99 | -

The poppler-utils package included in the installation script is designed for the amd64 architecture. If you need this package for a different architecture, we recommend checking the official poppler-utils page and obtaining the source code.

100 | - If you need to uninstall everything, run `./install.py` again with the `--remove-all` parameter. 101 | 102 | Now we just need to check if the program was installed correctly, for this we execute the following: 103 | 104 | pdfgui_tools 105 | 106 | In case you encounter any errors while running the script, please read the error messages provided by the script. Additionally, you will need to install the necessary dependencies to run pdfgui_tools correctly. 107 | 108 | ## Start using pdfgui_tools 109 | To start using pdfgui_tools, run the `pdfgui_tools` command, and a window like the following should appear: 110 | 111 | ![1](./Screenshots/Screenshot_2.png?raw=true) 112 | 113 | If you need help or assistance navigating PDF GUI Tools, use the `F1` key to display the help window. 114 | 115 | ## Dependencies 116 | Before being able to use pdfgui_tools, you need to have the following **dependencies** installed on your system for the program to function properly: 117 | 118 | #### Dependencies 119 | 120 | 124 | 125 | #### Optional dependencies 126 | 127 | 130 | 131 | > Note: A default **icon theme** that works with **Qt** is required to properly display the **pdfgui_tools interface**. In some distributions like **KDE**, this dependency is not necessary. 132 | 133 | #### Python dependencies 134 | 135 | 140 | 141 | > Note: Starting from version `2.0.0` of **pdfgui_tools**, for versions with the `amd64` or `x86_64` **architecture**, it is not necessary to install **Python-related dependencies** separately. pdfgui_tools is bundled with pyinstaller along with **all the necessary dependencies** to run. It will only require those dependencies that are not part of Python. 142 | 143 | ## Report bugs or give suggestions 144 | To notify errors in the program or give suggestions for it, write your request in the following email: 145 | -------------------------------------------------------------------------------- /Screenshots/Screenshot_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheWatcherMultiversal/pdfgui_tools/4760a66243d96020bf6206c2fe1b32783105bfe4/Screenshots/Screenshot_1.png -------------------------------------------------------------------------------- /Screenshots/Screenshot_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheWatcherMultiversal/pdfgui_tools/4760a66243d96020bf6206c2fe1b32783105bfe4/Screenshots/Screenshot_2.png -------------------------------------------------------------------------------- /code/README.md: -------------------------------------------------------------------------------- 1 | # Code 2 | 3 | Here is where the code and program logic are stored. Modify the files only if you know what you're doing; the code is documented to enhance readability. If you intend to modify something, I recommend reading this first: https://doc.qt.io/qtforpython-6/ 4 | 5 | # Sections 6 | ### File `pdfgui_tools.py` 7 | - [Description](#pdfgui_toolspy) 8 | - [class pdfguiMainWindow](#class-pdfguimainwindowui_mainwindow) 9 | - [class aboutWindow](#class-aboutwindowui_aboutwindow) 10 | 11 | ### File `pdfguiUtils.py` 12 | - [Description](#pdfguiutilspy) 13 | - [class PyPDF2utils](#class-pypdf2utils) 14 | - [class PyMuPDF_Utils](#class-pymupdf_utilsobject) 15 | 16 | ### File `pdfguiWindows.py` 17 | - [Description](#pdfguiwindowspy) 18 | - [class Ui_MainWindow](#class-ui_mainwindowobject) 19 | - [class class Ui_AboutWindow](#class-ui_aboutwindowobject) 20 | --- 21 | 22 | ## `pdfgui_tools.py`: 23 | This is the main file to run **pdfgui_tools**; it is the Python code that **connects to the logic** in `pdfguiUtils.py` and the **interface** in `Ui_Windows.py`. It links **user interactions** in the pdfgui_tools interface to the functions it includes for working with PDF documents. 24 | 25 | ### Classes from the file: 26 | 27 | #### `class pdfguiMainWindow(Ui_MainWindow)` 28 | This class inherits from the **main window** class of **pdfgui_tools**. It solely connects **user interactions** with the app and makes a few modifications depending on user interactions. If you want to modify the interface, go to the `designer` directory of this repository 29 | 30 | - Methods: 31 | ```python 32 | # Methods: # Arguments: # Description: 33 | def __init__ (self): # -> Set up the main window and connect user interactions to the rest of the app's functions 34 | def click_listWidget (self): # -> Make changes when an item in the QListWidget is touched 35 | def click_checkBox_range (self): # -> Detects the change in the range checkbox and stores it in the value of the self.dictPDFs dictionary 36 | def spinbox_initial_changed (self): # -> Detects the change in the initial range spinbox, and stores it in the self.dictPDFs dictionary 37 | def spinbox_final_changed (self): # -> Detects the change in the final range spinbox, and stores it in the self.dictPDFs dictionary 38 | def click_view (self): # -> Open the PDF document in the default PDF viewer using xdg-open 39 | def click_add (self): # -> Add the PDF documents to the QListWidget from their paths 40 | def click_delete (self): # -> Delete the currently selected item from the QListWidget 41 | def move_up (self): # -> Move the currently selected item one position up in the QListWidget 42 | def move_down (self): # -> Move the currently selected item one position down in the QListWidget 43 | def merge_pdf (self): # -> Merge all the PDF documents from the QListWidget into a single PDF 44 | def encrypt_decrypt (self, encrypt:bool, icon_file:str): # -> Encrypt or decrypt the PDF documents from the QListWidget 45 | def separate_pdf (self): # -> Split the selected PDF document into parts in the QListWidget 46 | def convert (self): # -> Convert the selected document in the QListWidget into a selected multimedia file 47 | def _help (self): # -> Display a help window 48 | def _about (self): # -> Show the 'About' window 49 | def inf_messages (self, title, message): # -> Function to call in case of an information or error message 50 | ``` 51 | 52 | #### `class aboutWindow(Ui_AboutWindow)` 53 | 54 | This class inherits from the **Ui_AboutWindow** window class. If you need to make modifications, use the design file from the `designer` directory of this repository. 55 | 56 | - Methods: 57 | ```python 58 | # Methods: # Arguments: # Description: 59 | def __init__ (self, aboutWin): # -> Set up the About window and connect the OK button to a lambda function. 60 | ``` 61 | 62 | --- 63 | 64 | ## `pdfguiUtils.py`: 65 | This is the main utilities file for **pdfgui_tools**, where all the application's utilities are included and will continue to be included. This file will contain variables and classes with their respective functions that will provide functionality to **pdfgui_tools**. Any module can be used as long as it is **stable**. 66 | 67 | ### Classes from the file: 68 | 69 | #### `class PyPDF2utils` 70 | It contains methods for the utilities included in the `PyPDF2` module. These methods return a value depending on the state and integrity of the **PDF document**. They should return a **tuple** with information for the **QMessageBox** window in case of an **error** or **informational** message regarding the **PDF documents**. 71 | 72 | - Methods: 73 | ```python 74 | # Methods: # Arguments: # Description: 75 | def merge_pdf (name_file:str, pdfs:list, pages:list): # -> Combine the PDFs from the list. 76 | def separate_pdf (pdf:str, dest:str): # -> Split a PDF document into multiple parts, which are saved in a directory. 77 | def extract_text (name_file:str, pdf:str): # -> Extract the text from a PDF per page. 78 | def encrypt_pdf (pdf:str, password:str): # -> Encrypt a PDF 79 | def decrypt_pdf (pdf:str, password:str): # -> Decrypt a PDF 80 | def fileEncrypted (pdf): # -> Determines if a file is encrypted, to prevent importing the PyPDF2 module twice. 81 | ``` 82 | #### `class PyMuPDF_Utils(object)` 83 | This contains the utilities included in `PyMuPDF`. Currently, its functionality is not extensive within pdfgui_tools, more features from this Python module will be added. 84 | 85 | This class takes a path to a PDF document as an argument, opens the document, and checks if it is encrypted to work with it. 86 | 87 | - Methods: 88 | ```python 89 | # Methods: # Arguments: # Description: 90 | def __init__ (self, pdf:str): # -> It takes a PDF path as an argument and opens the document with fitz 91 | def getSize (self): # -> Obtains the dimensions of the PDF document 92 | def documentScale (self): # -> Obtains the scale of the PDF document 93 | ``` 94 | 95 | --- 96 | 97 | ## `pdfguiWindows.py`: 98 | This file contains the configuration of the **pdfgui_tools interface**. This Python file is generated by the corresponding design file in the `designer` directory of this repository, and it encompasses a combination of all the interfaces created in **Qt Designer**. 99 | 100 | ### Classes from the file: 101 | 102 | #### `class Ui_MainWindow(object)` 103 | This class contains the code generated by the `pdfgui_tools.ui` file in the `designer` directory. It constructs the main interface of **pdfgui_tools**. 104 | 105 | - Methods: 106 | ```python 107 | # Methods: # Arguments: # Description: 108 | def setupUi (self, MainWindow, icon): # -> File to generate the main interface, it takes two arguments, the window and the icon of pdfgui_tools 109 | def retranslateUi (self, MainWindow): # -> Generated by pyside6-uic, this file for translations and setting text 110 | ``` 111 | 112 | #### `class Ui_AboutWindow(object):` 113 | This contains the code generated by `about.ui` from the `designer` directory, generating an **About window** with information about **pdfgui_tools**. 114 | 115 | - Methods: 116 | ```python 117 | # Methods: # Arguments: # Description: 118 | def setupUi (self, AboutWindow, icon, version_app): # -> This generates the About window, taking three arguments: the About window, the pdfgui_tools icon, and its version 119 | def retranslateUi (self, AboutWindow, version_app): # -> Generated by pyside6-uic, this file for translations and setting text 120 | ``` -------------------------------------------------------------------------------- /code/pdfguiUtils.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python3 2 | # 3 | # PDF GUI TOOLS - pdfguiUtils 4 | # 5 | # pdfguiUtils - Utilities file. 6 | # Author: Angel Gabriel Mortera Gual 7 | # License: GNU GENERAL PUBLIC LICENSE v3 8 | # 9 | # Project: https://github.com/TheWatcherMultiversal/pdfgui_tools/ 10 | # 11 | # ----------------------------------------------------------------------------------- 12 | 13 | from PyPDF2 import PdfFileMerger, PdfFileReader, PdfFileWriter # <--- PyPDF2 v1.26.0 14 | import os, subprocess, fitz # <-------------------------------------- PyMuPDF v1.23.5 15 | 16 | # Variables and Paths 17 | title_app = "PDF GUI Tools"#-------------------> Title app 18 | version_app = "2.0.0"#---------------------------> Version pdfgui_tools 19 | path_pdfgui_tools = ("/usr/share/pdfgui_tools")#-------> Path pdfgui_tools 20 | spinBox_range = (1, 1000)#-------------------------> Allowed spinbox range 21 | repeat_symbol = "*"#-------------------------------> Symbol of repeated PDFs in the list (avoids conflicts in the self.dictPDFs dictionary) 22 | maxSizeDocument = 300#-------------------------------> Maximum document display size. 23 | icon_pdf = "application-pdf"#-----------------> Qt icon name for PDF document 24 | icon_pdfEncrypt = "encrypted"#-----------------------> Qt icon name for encrypted files 25 | 26 | 27 | Paths = { 28 | "icon_app" : (f"{path_pdfgui_tools}/assets/pdfguitools.svg"), 29 | "styles" : (f"{path_pdfgui_tools}/styles/styles.css"), 30 | } 31 | 32 | # ---------------------------% PyPDF2 Utils %----------------------------------# 33 | 34 | class PyPDF2utils: 35 | 36 | # >> Merge PDFs: 37 | def merge_pdf(name_file:str, pdfs:list): 38 | """PDF Merger using the `PyPDF2` module` 39 | 40 | :param name_file: Name of the document where the PDFs will be merged 41 | 42 | :param pdfs: Receives a `list` with the paths of the PDFs to merge""" 43 | 44 | try: 45 | pdf_merger = PdfFileMerger() 46 | 47 | try: 48 | for pdf in pdfs: 49 | path_pdf = pdf[2]; checkRangeBox = pdf[0]; pdf_range = (pdf[1][0], pdf[1][1]) 50 | 51 | if PyPDF2utils.fileEncrypted(path_pdf): 52 | return("Info", f"The document {path_pdf} is encrypted, decrypt it to perform this action") 53 | 54 | if checkRangeBox: ran_page = pdf_range 55 | else: ran_page = None 56 | 57 | pdf_merger.append(open(path_pdf, 'rb'), pages=ran_page) 58 | 59 | except IndexError: return("Error", f"Index error in the file {path_pdf}, please enter a valid value") 60 | except: return("Error", f"The document {path_pdf} could not be processed, please check the integrity of the document") 61 | 62 | with open(name_file, 'wb') as f: 63 | pdf_merger.write(f) 64 | 65 | except: return("Error", "The documents could not be processed") 66 | return True 67 | 68 | 69 | # >> Separate PDFs: 70 | def separate_pdf(pdf:str, dest:str): 71 | """PDF Splitter using the `PyPDF2` module 72 | 73 | :param pdf: PDF Document Path 74 | 75 | :param dest: Path to the directory to create, where the separated PDF documents will be stored""" 76 | 77 | try: 78 | pdf_reader = PdfFileReader(pdf) 79 | dest_name = os.path.basename(dest) 80 | 81 | try: 82 | subprocess.run([f'mkdir {dest}'], check=True, shell=True) 83 | except subprocess.CalledProcessError: 84 | return("Error", f"The directory {dest} could not be created.") 85 | 86 | for i in range(pdf_reader.numPages): 87 | pdf_writer = PdfFileWriter() 88 | pdf_writer.addPage(pdf_reader.getPage(i)) 89 | 90 | with open(f"{dest}/{dest_name}_{i + 1}.pdf", 'wb') as f: 91 | pdf_writer.write(f) 92 | except: return("Error", "The document could not be processed, please check the integrity of the file.") 93 | return True 94 | 95 | 96 | # >> Extract Text: 97 | def extract_text(name_file:str, pdf:str): 98 | """Text Extractor using the `PyPDF2` module. 99 | 100 | :param name_file: PDF Document Name in Text 101 | 102 | :param pdf: PDF Document Path""" 103 | 104 | try: 105 | pdf_reader = PdfFileReader(pdf) 106 | extract_content = "" 107 | 108 | for i in range(pdf_reader.numPages): 109 | text_page = pdf_reader.getPage(i).extractText().replace("\n", " ") 110 | extract_content += f'{text_page}\r\n \r\n' 111 | 112 | with open(name_file, "w", encoding="utf-8") as f: 113 | f.write(extract_content) 114 | except: return("Error", "The document could not be processed, please check the text format and the integrity of the document") 115 | return True 116 | 117 | 118 | # >> Encrypt PDFs: 119 | def encrypt_pdf(pdf:str, password:str): 120 | """Encrypt PDF documents using the `PyPDF2` module 121 | 122 | :param pdf: PDF Document Path 123 | 124 | :param password: Gets the password to use for encrypting the document""" 125 | 126 | try: 127 | pdf_writer = PdfFileWriter() 128 | pdf_reader = PdfFileReader(pdf) 129 | 130 | if pdf_reader.isEncrypted: 131 | return("Info", f"The document {pdf} is already encrypted") 132 | 133 | for i in range(pdf_reader.numPages): 134 | page = pdf_reader.getPage(i) 135 | pdf_writer.addPage(page) 136 | 137 | pdf_writer.encrypt(password) 138 | 139 | with open(pdf, "wb") as f: 140 | pdf_writer.write(f) 141 | 142 | except: return("Error", "The file could not be encrypted, please check the document's integrity") 143 | return True 144 | 145 | 146 | # >> Decrypt PDFs: 147 | def decrypt_pdf(pdf:str, password:str): 148 | """Decrypt PDF documents using the `PyPDF2` module 149 | 150 | :param pdf: PDF Document Path 151 | 152 | :param password: Gets the password to use for decrypting the file""" 153 | 154 | try: 155 | pdf_writer = PdfFileWriter() 156 | pdf_reader = PdfFileReader(pdf) 157 | 158 | if not pdf_reader.isEncrypted: 159 | return("Info", f"The document {pdf} is already decrypted.") 160 | 161 | returncode = pdf_reader.decrypt(password) 162 | if returncode == 0: 163 | return("Info", f"Incorrect password for the document {pdf}, please try another password") 164 | 165 | for i in range(pdf_reader.numPages): 166 | page = pdf_reader.getPage(i) 167 | pdf_writer.addPage(page) 168 | 169 | with open(pdf, "wb") as f: 170 | pdf_writer.write(f) 171 | 172 | except: return("Error", "The file could not be encrypted, please check the document's integrity") 173 | return True 174 | 175 | 176 | # >> PDF id Encrypted: 177 | def fileEncrypted(pdf): 178 | try: return PdfFileReader(pdf).isEncrypted 179 | except: return False 180 | 181 | 182 | 183 | class PyMuPDF_Utils(object): 184 | 185 | def __init__(self, pdf:str): 186 | """Utilities included in the `fitz` module of PyMuPDF""" 187 | 188 | self.document = fitz.open(pdf) 189 | self.isEncrypted = PyPDF2utils.fileEncrypted(pdf) 190 | 191 | 192 | # Obtains the dimensions of the PDF document 193 | def getSize(self): 194 | """Obtains the dimensions of the PDF document""" 195 | 196 | if not self.isEncrypted: 197 | firts_page = self.document[0] 198 | return (firts_page.rect.width, firts_page.rect.height) 199 | 200 | 201 | # Obtains the scale of the PDF document 202 | def documentScale(self): 203 | """Obtains the scale of the PDF document""" 204 | 205 | if not self.isEncrypted: 206 | documentSize = self.getSize() 207 | if documentSize is None: return 208 | return round(documentSize[1] / documentSize[0], 2) 209 | -------------------------------------------------------------------------------- /code/pdfguiWindows.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python3 2 | # 3 | # PDF GUI TOOLS - Ui_Windows 4 | # 5 | # PDF GUI Tools app - Main QT windows file 6 | # 7 | # Author: Angel Gabriel Mortera Gual 8 | # License: GNU GENERAL PUBLIC LICENSE v3 9 | # 10 | # Project: https://github.com/TheWatcherMultiversal/pdfgui_tools/ 11 | # 12 | # This file is only generated by the files in the project's 13 | # designer directory, change its aspects from there. 14 | # 15 | # ----------------------------------------------------------------------------------- 16 | 17 | from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale, 18 | QMetaObject, QObject, QPoint, QRect, 19 | QSize, QTime, QUrl, Qt) 20 | from PySide6.QtGui import (QAction, QBrush, QColor, QConicalGradient, 21 | QCursor, QFont, QFontDatabase, QGradient, 22 | QIcon, QImage, QKeySequence, QLinearGradient, 23 | QPainter, QPalette, QPixmap, QRadialGradient, 24 | QTransform) 25 | from PySide6.QtWidgets import (QAbstractItemView, QApplication, QCheckBox, QComboBox, 26 | QDockWidget, QGridLayout, QGroupBox, QHBoxLayout, 27 | QLabel, QLineEdit, QListWidget, QListWidgetItem, 28 | QMainWindow, QMenu, QMenuBar, QPushButton, 29 | QScrollArea, QSizePolicy, QSpacerItem, QSpinBox, 30 | QStatusBar, QVBoxLayout, QWidget) 31 | 32 | class Ui_MainWindow(object): 33 | def setupUi(self, MainWindow, icon): 34 | if not MainWindow.objectName(): 35 | MainWindow.setObjectName(u"MainWindow") 36 | MainWindow.resize(1176, 827) 37 | MainWindow.setWindowIcon(icon) 38 | self.actionAdd_File = QAction(MainWindow) 39 | self.actionAdd_File.setObjectName(u"actionAdd_File") 40 | self.actionDelete = QAction(MainWindow) 41 | self.actionDelete.setObjectName(u"actionDelete") 42 | self.actionUp = QAction(MainWindow) 43 | self.actionUp.setObjectName(u"actionUp") 44 | self.actionDown = QAction(MainWindow) 45 | self.actionDown.setObjectName(u"actionDown") 46 | self.actionMerge = QAction(MainWindow) 47 | self.actionMerge.setObjectName(u"actionMerge") 48 | self.actionEncrypt = QAction(MainWindow) 49 | self.actionEncrypt.setObjectName(u"actionEncrypt") 50 | self.actionDecrypt = QAction(MainWindow) 51 | self.actionDecrypt.setObjectName(u"actionDecrypt") 52 | self.actionExit = QAction(MainWindow) 53 | self.actionExit.setObjectName(u"actionExit") 54 | self.actionHelp = QAction(MainWindow) 55 | self.actionHelp.setObjectName(u"actionHelp") 56 | self.actionAbout = QAction(MainWindow) 57 | self.actionAbout.setObjectName(u"actionAbout") 58 | self.actionView_Utils = QAction(MainWindow) 59 | self.actionView_Utils.setObjectName(u"actionView_Utils") 60 | self.centralwidget = QWidget(MainWindow) 61 | self.centralwidget.setObjectName(u"centralwidget") 62 | self.horizontalLayout_4 = QHBoxLayout(self.centralwidget) 63 | self.horizontalLayout_4.setObjectName(u"horizontalLayout_4") 64 | self.scrollArea_2 = QScrollArea(self.centralwidget) 65 | self.scrollArea_2.setObjectName(u"scrollArea_2") 66 | self.scrollArea_2.setWidgetResizable(True) 67 | self.scrollAreaWidgetContents_2 = QWidget() 68 | self.scrollAreaWidgetContents_2.setObjectName(u"scrollAreaWidgetContents_2") 69 | self.scrollAreaWidgetContents_2.setGeometry(QRect(0, 0, 823, 763)) 70 | self.gridLayout = QGridLayout(self.scrollAreaWidgetContents_2) 71 | self.gridLayout.setObjectName(u"gridLayout") 72 | self.groupBox = QGroupBox(self.scrollAreaWidgetContents_2) 73 | self.groupBox.setObjectName(u"groupBox") 74 | self.gridLayout_2 = QGridLayout(self.groupBox) 75 | self.gridLayout_2.setSpacing(20) 76 | self.gridLayout_2.setObjectName(u"gridLayout_2") 77 | self.gridLayout_2.setContentsMargins(20, 35, 20, 20) 78 | self.listWidget = QListWidget(self.groupBox) 79 | self.listWidget.setObjectName(u"listWidget") 80 | self.listWidget.setAcceptDrops(True) 81 | self.listWidget.setStyleSheet(u"") 82 | self.listWidget.setDragDropMode(QAbstractItemView.InternalMove) 83 | self.listWidget.setDefaultDropAction(Qt.MoveAction) 84 | self.listWidget.setIconSize(QSize(60, 60)) 85 | self.listWidget.setSpacing(20) 86 | 87 | self.gridLayout_2.addWidget(self.listWidget, 0, 0, 1, 1) 88 | 89 | self.verticalLayout_3 = QVBoxLayout() 90 | self.verticalLayout_3.setObjectName(u"verticalLayout_3") 91 | self.verticalLayout_4 = QVBoxLayout() 92 | self.verticalLayout_4.setSpacing(20) 93 | self.verticalLayout_4.setObjectName(u"verticalLayout_4") 94 | self.verticalLayout_4.setContentsMargins(-1, 5, -1, 5) 95 | self.button_add = QPushButton(self.groupBox) 96 | self.button_add.setObjectName(u"button_add") 97 | icon = QIcon(QIcon.fromTheme(u"document-new")) 98 | self.button_add.setIcon(icon) 99 | 100 | self.verticalLayout_4.addWidget(self.button_add) 101 | 102 | self.button_delete = QPushButton(self.groupBox) 103 | self.button_delete.setObjectName(u"button_delete") 104 | icon1 = QIcon(QIcon.fromTheme(u"edit-delete")) 105 | self.button_delete.setIcon(icon1) 106 | 107 | self.verticalLayout_4.addWidget(self.button_delete) 108 | 109 | self.button_up = QPushButton(self.groupBox) 110 | self.button_up.setObjectName(u"button_up") 111 | icon2 = QIcon(QIcon.fromTheme(u"go-up")) 112 | self.button_up.setIcon(icon2) 113 | 114 | self.verticalLayout_4.addWidget(self.button_up) 115 | 116 | self.button_down = QPushButton(self.groupBox) 117 | self.button_down.setObjectName(u"button_down") 118 | icon3 = QIcon(QIcon.fromTheme(u"go-down")) 119 | self.button_down.setIcon(icon3) 120 | 121 | self.verticalLayout_4.addWidget(self.button_down) 122 | 123 | self.button_utils = QPushButton(self.groupBox) 124 | self.button_utils.setObjectName(u"button_utils") 125 | icon4 = QIcon(QIcon.fromTheme(u"window-new")) 126 | self.button_utils.setIcon(icon4) 127 | 128 | self.verticalLayout_4.addWidget(self.button_utils) 129 | 130 | 131 | self.verticalLayout_3.addLayout(self.verticalLayout_4) 132 | 133 | self.verticalLayout_6 = QVBoxLayout() 134 | self.verticalLayout_6.setObjectName(u"verticalLayout_6") 135 | self.button_merge = QPushButton(self.groupBox) 136 | self.button_merge.setObjectName(u"button_merge") 137 | 138 | self.verticalLayout_6.addWidget(self.button_merge) 139 | 140 | self.button_encrypt = QPushButton(self.groupBox) 141 | self.button_encrypt.setObjectName(u"button_encrypt") 142 | 143 | self.verticalLayout_6.addWidget(self.button_encrypt) 144 | 145 | self.button_decrypt = QPushButton(self.groupBox) 146 | self.button_decrypt.setObjectName(u"button_decrypt") 147 | 148 | self.verticalLayout_6.addWidget(self.button_decrypt) 149 | 150 | 151 | self.verticalLayout_3.addLayout(self.verticalLayout_6) 152 | 153 | self.label_notice = QLabel(self.groupBox) 154 | self.label_notice.setObjectName(u"label_notice") 155 | 156 | self.verticalLayout_3.addWidget(self.label_notice) 157 | 158 | 159 | self.gridLayout_2.addLayout(self.verticalLayout_3, 0, 1, 1, 1) 160 | 161 | 162 | self.gridLayout.addWidget(self.groupBox, 0, 0, 1, 1) 163 | 164 | self.scrollArea_2.setWidget(self.scrollAreaWidgetContents_2) 165 | 166 | self.horizontalLayout_4.addWidget(self.scrollArea_2) 167 | 168 | MainWindow.setCentralWidget(self.centralwidget) 169 | self.menubar = QMenuBar(MainWindow) 170 | self.menubar.setObjectName(u"menubar") 171 | self.menubar.setGeometry(QRect(0, 0, 1176, 22)) 172 | self.menuFile = QMenu(self.menubar) 173 | self.menuFile.setObjectName(u"menuFile") 174 | self.menuHelp = QMenu(self.menubar) 175 | self.menuHelp.setObjectName(u"menuHelp") 176 | MainWindow.setMenuBar(self.menubar) 177 | self.statusbar = QStatusBar(MainWindow) 178 | self.statusbar.setObjectName(u"statusbar") 179 | MainWindow.setStatusBar(self.statusbar) 180 | self.dockWidget = QDockWidget(MainWindow) 181 | self.dockWidget.setObjectName(u"dockWidget") 182 | self.dockWidget.setMinimumSize(QSize(327, 108)) 183 | self.dockWidget.setContextMenuPolicy(Qt.DefaultContextMenu) 184 | self.dockWidget.setFloating(False) 185 | self.dockWidget.setFeatures(QDockWidget.DockWidgetClosable|QDockWidget.DockWidgetFloatable|QDockWidget.DockWidgetMovable) 186 | self.dockWidget.setAllowedAreas(Qt.LeftDockWidgetArea|Qt.RightDockWidgetArea) 187 | self.dockWidgetContents = QWidget() 188 | self.dockWidgetContents.setObjectName(u"dockWidgetContents") 189 | self.horizontalLayout_3 = QHBoxLayout(self.dockWidgetContents) 190 | self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") 191 | self.scrollArea = QScrollArea(self.dockWidgetContents) 192 | self.scrollArea.setObjectName(u"scrollArea") 193 | self.scrollArea.setWidgetResizable(True) 194 | self.scrollAreaWidgetContents = QWidget() 195 | self.scrollAreaWidgetContents.setObjectName(u"scrollAreaWidgetContents") 196 | self.scrollAreaWidgetContents.setGeometry(QRect(0, 0, 307, 744)) 197 | self.verticalLayout = QVBoxLayout(self.scrollAreaWidgetContents) 198 | self.verticalLayout.setObjectName(u"verticalLayout") 199 | self.groupBox_2 = QGroupBox(self.scrollAreaWidgetContents) 200 | self.groupBox_2.setObjectName(u"groupBox_2") 201 | self.gridLayout_3 = QGridLayout(self.groupBox_2) 202 | self.gridLayout_3.setObjectName(u"gridLayout_3") 203 | self.gridLayout_3.setHorizontalSpacing(2) 204 | self.gridLayout_3.setVerticalSpacing(20) 205 | self.gridLayout_3.setContentsMargins(20, 35, 20, 20) 206 | self.scrollArea_3 = QScrollArea(self.groupBox_2) 207 | self.scrollArea_3.setObjectName(u"scrollArea_3") 208 | self.scrollArea_3.setWidgetResizable(True) 209 | self.scrollAreaWidgetContents_3 = QWidget() 210 | self.scrollAreaWidgetContents_3.setObjectName(u"scrollAreaWidgetContents_3") 211 | self.scrollAreaWidgetContents_3.setGeometry(QRect(0, 0, 239, 68)) 212 | self.verticalLayout_8 = QVBoxLayout(self.scrollAreaWidgetContents_3) 213 | self.verticalLayout_8.setObjectName(u"verticalLayout_8") 214 | self.label = QLabel(self.scrollAreaWidgetContents_3) 215 | self.label.setObjectName(u"label") 216 | font = QFont() 217 | font.setPointSize(11) 218 | font.setBold(True) 219 | self.label.setFont(font) 220 | self.label.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignVCenter) 221 | 222 | self.verticalLayout_8.addWidget(self.label) 223 | 224 | self.scrollArea_3.setWidget(self.scrollAreaWidgetContents_3) 225 | 226 | self.gridLayout_3.addWidget(self.scrollArea_3, 0, 0, 1, 1) 227 | 228 | self.verticalLayout_5 = QVBoxLayout() 229 | self.verticalLayout_5.setSpacing(20) 230 | self.verticalLayout_5.setObjectName(u"verticalLayout_5") 231 | self.verticalLayout_5.setContentsMargins(-1, -1, 0, 20) 232 | self.verticalSpacer = QSpacerItem(20, 2000000000, QSizePolicy.Minimum, QSizePolicy.Expanding) 233 | 234 | self.verticalLayout_5.addItem(self.verticalSpacer) 235 | 236 | self.checkBox_range = QCheckBox(self.groupBox_2) 237 | self.checkBox_range.setObjectName(u"checkBox_range") 238 | self.checkBox_range.setFont(font) 239 | 240 | self.verticalLayout_5.addWidget(self.checkBox_range) 241 | 242 | self.gridLayout_4 = QGridLayout() 243 | self.gridLayout_4.setSpacing(20) 244 | self.gridLayout_4.setObjectName(u"gridLayout_4") 245 | self.spinBox_range_final = QSpinBox(self.groupBox_2) 246 | self.spinBox_range_final.setObjectName(u"spinBox_range_final") 247 | self.spinBox_range_final.setMaximum(1000) 248 | 249 | self.gridLayout_4.addWidget(self.spinBox_range_final, 0, 1, 1, 1) 250 | 251 | self.label_3 = QLabel(self.groupBox_2) 252 | self.label_3.setObjectName(u"label_3") 253 | self.label_3.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop) 254 | self.label_3.setMargin(3) 255 | 256 | self.gridLayout_4.addWidget(self.label_3, 1, 1, 1, 1) 257 | 258 | self.label_2 = QLabel(self.groupBox_2) 259 | self.label_2.setObjectName(u"label_2") 260 | self.label_2.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop) 261 | self.label_2.setMargin(3) 262 | 263 | self.gridLayout_4.addWidget(self.label_2, 1, 0, 1, 1) 264 | 265 | self.spinBox_range_initial = QSpinBox(self.groupBox_2) 266 | self.spinBox_range_initial.setObjectName(u"spinBox_range_initial") 267 | self.spinBox_range_initial.setMaximum(1000) 268 | 269 | self.gridLayout_4.addWidget(self.spinBox_range_initial, 0, 0, 1, 1) 270 | 271 | 272 | self.verticalLayout_5.addLayout(self.gridLayout_4) 273 | 274 | self.verticalLayout_7 = QVBoxLayout() 275 | self.verticalLayout_7.setSpacing(20) 276 | self.verticalLayout_7.setObjectName(u"verticalLayout_7") 277 | self.verticalLayout_7.setContentsMargins(-1, -1, 0, 20) 278 | self.label_4 = QLabel(self.groupBox_2) 279 | self.label_4.setObjectName(u"label_4") 280 | self.label_4.setFont(font) 281 | 282 | self.verticalLayout_7.addWidget(self.label_4) 283 | 284 | self.lineEdit_password = QLineEdit(self.groupBox_2) 285 | self.lineEdit_password.setObjectName(u"lineEdit_password") 286 | self.lineEdit_password.setAcceptDrops(False) 287 | self.lineEdit_password.setInputMethodHints(Qt.ImhHiddenText|Qt.ImhNoAutoUppercase|Qt.ImhNoPredictiveText|Qt.ImhSensitiveData) 288 | self.lineEdit_password.setText(u"") 289 | self.lineEdit_password.setEchoMode(QLineEdit.Password) 290 | self.lineEdit_password.setPlaceholderText(u"") 291 | 292 | self.verticalLayout_7.addWidget(self.lineEdit_password) 293 | 294 | 295 | self.verticalLayout_5.addLayout(self.verticalLayout_7) 296 | 297 | self.button_view = QPushButton(self.groupBox_2) 298 | self.button_view.setObjectName(u"button_view") 299 | icon5 = QIcon(QIcon.fromTheme(u"document-open")) 300 | self.button_view.setIcon(icon5) 301 | 302 | self.verticalLayout_5.addWidget(self.button_view) 303 | 304 | self.button_separate = QPushButton(self.groupBox_2) 305 | self.button_separate.setObjectName(u"button_separate") 306 | 307 | self.verticalLayout_5.addWidget(self.button_separate) 308 | 309 | self.horizontalLayout_2 = QHBoxLayout() 310 | self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") 311 | self.button_convert = QPushButton(self.groupBox_2) 312 | self.button_convert.setObjectName(u"button_convert") 313 | 314 | self.horizontalLayout_2.addWidget(self.button_convert) 315 | 316 | self.combo_filetype = QComboBox(self.groupBox_2) 317 | self.combo_filetype.addItem("") 318 | self.combo_filetype.addItem("") 319 | self.combo_filetype.addItem("") 320 | self.combo_filetype.addItem("") 321 | self.combo_filetype.addItem("") 322 | self.combo_filetype.addItem("") 323 | self.combo_filetype.addItem("") 324 | self.combo_filetype.setObjectName(u"combo_filetype") 325 | 326 | self.horizontalLayout_2.addWidget(self.combo_filetype) 327 | 328 | 329 | self.verticalLayout_5.addLayout(self.horizontalLayout_2) 330 | 331 | 332 | self.gridLayout_3.addLayout(self.verticalLayout_5, 2, 0, 1, 2) 333 | 334 | 335 | self.verticalLayout.addWidget(self.groupBox_2) 336 | 337 | self.scrollArea_4 = QScrollArea(self.scrollAreaWidgetContents) 338 | self.scrollArea_4.setObjectName(u"scrollArea_4") 339 | self.scrollArea_4.setMaximumSize(QSize(16777215, 16777215)) 340 | self.scrollArea_4.setWidgetResizable(True) 341 | self.scrollArea_4.setAlignment(Qt.AlignCenter) 342 | self.scrollVerticalLayout_DocPreview = QWidget() 343 | self.scrollVerticalLayout_DocPreview.setObjectName(u"scrollVerticalLayout_DocPreview") 344 | self.scrollVerticalLayout_DocPreview.setGeometry(QRect(0, 0, 287, 144)) 345 | self.scrollVerticalLayout_DocPreview.setMaximumSize(QSize(300, 387)) 346 | self.horizontalLayout = QHBoxLayout(self.scrollVerticalLayout_DocPreview) 347 | self.horizontalLayout.setObjectName(u"horizontalLayout") 348 | self.label_doc_view = QLabel(self.scrollVerticalLayout_DocPreview) 349 | self.label_doc_view.setObjectName(u"label_doc_view") 350 | self.label_doc_view.setMaximumSize(QSize(16777215, 16777215)) 351 | self.label_doc_view.setScaledContents(True) 352 | self.label_doc_view.setAlignment(Qt.AlignCenter) 353 | 354 | self.horizontalLayout.addWidget(self.label_doc_view) 355 | 356 | self.scrollArea_4.setWidget(self.scrollVerticalLayout_DocPreview) 357 | 358 | self.verticalLayout.addWidget(self.scrollArea_4) 359 | 360 | self.verticalLayout.setStretch(0, 1) 361 | self.verticalLayout.setStretch(1, 2) 362 | self.scrollArea.setWidget(self.scrollAreaWidgetContents) 363 | 364 | self.horizontalLayout_3.addWidget(self.scrollArea) 365 | 366 | self.dockWidget.setWidget(self.dockWidgetContents) 367 | MainWindow.addDockWidget(Qt.LeftDockWidgetArea, self.dockWidget) 368 | 369 | self.menubar.addAction(self.menuFile.menuAction()) 370 | self.menubar.addAction(self.menuHelp.menuAction()) 371 | self.menuFile.addAction(self.actionAdd_File) 372 | self.menuFile.addAction(self.actionDelete) 373 | self.menuFile.addAction(self.actionUp) 374 | self.menuFile.addAction(self.actionDown) 375 | self.menuFile.addAction(self.actionView_Utils) 376 | self.menuFile.addAction(self.actionMerge) 377 | self.menuFile.addAction(self.actionEncrypt) 378 | self.menuFile.addAction(self.actionDecrypt) 379 | self.menuFile.addAction(self.actionExit) 380 | self.menuHelp.addAction(self.actionHelp) 381 | self.menuHelp.addAction(self.actionAbout) 382 | 383 | self.retranslateUi(MainWindow) 384 | 385 | QMetaObject.connectSlotsByName(MainWindow) 386 | # setupUi 387 | 388 | def retranslateUi(self, MainWindow): 389 | MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"PDF GUI Tools", None)) 390 | self.actionAdd_File.setText(QCoreApplication.translate("MainWindow", u"Add File", None)) 391 | #if QT_CONFIG(statustip) 392 | self.actionAdd_File.setStatusTip(QCoreApplication.translate("MainWindow", u"Add File", None)) 393 | #endif // QT_CONFIG(statustip) 394 | #if QT_CONFIG(shortcut) 395 | self.actionAdd_File.setShortcut(QCoreApplication.translate("MainWindow", u"Ctrl+A", None)) 396 | #endif // QT_CONFIG(shortcut) 397 | self.actionDelete.setText(QCoreApplication.translate("MainWindow", u"Delete", None)) 398 | #if QT_CONFIG(statustip) 399 | self.actionDelete.setStatusTip(QCoreApplication.translate("MainWindow", u"Delete File", None)) 400 | #endif // QT_CONFIG(statustip) 401 | #if QT_CONFIG(shortcut) 402 | self.actionDelete.setShortcut(QCoreApplication.translate("MainWindow", u"Backspace", None)) 403 | #endif // QT_CONFIG(shortcut) 404 | self.actionUp.setText(QCoreApplication.translate("MainWindow", u"Up", None)) 405 | #if QT_CONFIG(statustip) 406 | self.actionUp.setStatusTip(QCoreApplication.translate("MainWindow", u"Up list", None)) 407 | #endif // QT_CONFIG(statustip) 408 | #if QT_CONFIG(shortcut) 409 | self.actionUp.setShortcut(QCoreApplication.translate("MainWindow", u"Up", None)) 410 | #endif // QT_CONFIG(shortcut) 411 | self.actionDown.setText(QCoreApplication.translate("MainWindow", u"Down", None)) 412 | #if QT_CONFIG(statustip) 413 | self.actionDown.setStatusTip(QCoreApplication.translate("MainWindow", u"Down list", None)) 414 | #endif // QT_CONFIG(statustip) 415 | #if QT_CONFIG(shortcut) 416 | self.actionDown.setShortcut(QCoreApplication.translate("MainWindow", u"Down", None)) 417 | #endif // QT_CONFIG(shortcut) 418 | self.actionMerge.setText(QCoreApplication.translate("MainWindow", u"Merge", None)) 419 | #if QT_CONFIG(statustip) 420 | self.actionMerge.setStatusTip(QCoreApplication.translate("MainWindow", u"Merge PDFs", None)) 421 | #endif // QT_CONFIG(statustip) 422 | #if QT_CONFIG(shortcut) 423 | self.actionMerge.setShortcut(QCoreApplication.translate("MainWindow", u"Ctrl+S", None)) 424 | #endif // QT_CONFIG(shortcut) 425 | self.actionEncrypt.setText(QCoreApplication.translate("MainWindow", u"Encrypt", None)) 426 | #if QT_CONFIG(statustip) 427 | self.actionEncrypt.setStatusTip(QCoreApplication.translate("MainWindow", u"Encrypt PDFs", None)) 428 | #endif // QT_CONFIG(statustip) 429 | #if QT_CONFIG(shortcut) 430 | self.actionEncrypt.setShortcut(QCoreApplication.translate("MainWindow", u"Ctrl+E", None)) 431 | #endif // QT_CONFIG(shortcut) 432 | self.actionDecrypt.setText(QCoreApplication.translate("MainWindow", u"Decrypt", None)) 433 | #if QT_CONFIG(statustip) 434 | self.actionDecrypt.setStatusTip(QCoreApplication.translate("MainWindow", u"Decrypt PDFs", None)) 435 | #endif // QT_CONFIG(statustip) 436 | #if QT_CONFIG(shortcut) 437 | self.actionDecrypt.setShortcut(QCoreApplication.translate("MainWindow", u"Ctrl+D", None)) 438 | #endif // QT_CONFIG(shortcut) 439 | self.actionExit.setText(QCoreApplication.translate("MainWindow", u"Exit", None)) 440 | #if QT_CONFIG(statustip) 441 | self.actionExit.setStatusTip(QCoreApplication.translate("MainWindow", u"Exit app", None)) 442 | #endif // QT_CONFIG(statustip) 443 | #if QT_CONFIG(shortcut) 444 | self.actionExit.setShortcut(QCoreApplication.translate("MainWindow", u"Esc", None)) 445 | #endif // QT_CONFIG(shortcut) 446 | self.actionHelp.setText(QCoreApplication.translate("MainWindow", u"Help", None)) 447 | #if QT_CONFIG(statustip) 448 | self.actionHelp.setStatusTip(QCoreApplication.translate("MainWindow", u"Help", None)) 449 | #endif // QT_CONFIG(statustip) 450 | #if QT_CONFIG(shortcut) 451 | self.actionHelp.setShortcut(QCoreApplication.translate("MainWindow", u"F1", None)) 452 | #endif // QT_CONFIG(shortcut) 453 | self.actionAbout.setText(QCoreApplication.translate("MainWindow", u"About", None)) 454 | #if QT_CONFIG(statustip) 455 | self.actionAbout.setStatusTip(QCoreApplication.translate("MainWindow", u"About", None)) 456 | #endif // QT_CONFIG(statustip) 457 | self.actionView_Utils.setText(QCoreApplication.translate("MainWindow", u"View Utils", None)) 458 | #if QT_CONFIG(statustip) 459 | self.actionView_Utils.setStatusTip(QCoreApplication.translate("MainWindow", u"View Utilities", None)) 460 | #endif // QT_CONFIG(statustip) 461 | #if QT_CONFIG(shortcut) 462 | self.actionView_Utils.setShortcut(QCoreApplication.translate("MainWindow", u"Ctrl+Q", None)) 463 | #endif // QT_CONFIG(shortcut) 464 | self.groupBox.setTitle(QCoreApplication.translate("MainWindow", u"List PDFs", None)) 465 | self.button_add.setText(QCoreApplication.translate("MainWindow", u" Add File", None)) 466 | self.button_delete.setText(QCoreApplication.translate("MainWindow", u" Delete", None)) 467 | self.button_up.setText("") 468 | self.button_down.setText("") 469 | self.button_utils.setText(QCoreApplication.translate("MainWindow", u" View Utils", None)) 470 | self.button_merge.setText(QCoreApplication.translate("MainWindow", u"Merge", None)) 471 | self.button_encrypt.setText(QCoreApplication.translate("MainWindow", u"Encrypt", None)) 472 | self.button_decrypt.setText(QCoreApplication.translate("MainWindow", u"Decrypt", None)) 473 | self.label_notice.setText("") 474 | self.menuFile.setTitle(QCoreApplication.translate("MainWindow", u"File", None)) 475 | self.menuHelp.setTitle(QCoreApplication.translate("MainWindow", u"Help", None)) 476 | self.groupBox_2.setTitle(QCoreApplication.translate("MainWindow", u"Utilities", None)) 477 | self.label.setText(QCoreApplication.translate("MainWindow", u"Select a document", None)) 478 | #if QT_CONFIG(statustip) 479 | self.checkBox_range.setStatusTip(QCoreApplication.translate("MainWindow", u"Document page range", None)) 480 | #endif // QT_CONFIG(statustip) 481 | self.checkBox_range.setText(QCoreApplication.translate("MainWindow", u"Page Range", None)) 482 | self.label_3.setText(QCoreApplication.translate("MainWindow", u"Final", None)) 483 | self.label_2.setText(QCoreApplication.translate("MainWindow", u"Initial", None)) 484 | self.label_4.setText(QCoreApplication.translate("MainWindow", u"Password", None)) 485 | #if QT_CONFIG(statustip) 486 | self.lineEdit_password.setStatusTip(QCoreApplication.translate("MainWindow", u"Set an encryption or decryption password", None)) 487 | #endif // QT_CONFIG(statustip) 488 | self.button_view.setText(QCoreApplication.translate("MainWindow", u" View PDF", None)) 489 | self.button_separate.setText(QCoreApplication.translate("MainWindow", u"Separate PDF", None)) 490 | self.button_convert.setText(QCoreApplication.translate("MainWindow", u"Convert PDF", None)) 491 | self.combo_filetype.setItemText(0, QCoreApplication.translate("MainWindow", u"PNG", None)) 492 | self.combo_filetype.setItemText(1, QCoreApplication.translate("MainWindow", u"JPEG", None)) 493 | self.combo_filetype.setItemText(2, QCoreApplication.translate("MainWindow", u"PS", None)) 494 | self.combo_filetype.setItemText(3, QCoreApplication.translate("MainWindow", u"EPS", None)) 495 | self.combo_filetype.setItemText(4, QCoreApplication.translate("MainWindow", u"SVG", None)) 496 | self.combo_filetype.setItemText(5, QCoreApplication.translate("MainWindow", u"HTML", None)) 497 | self.combo_filetype.setItemText(6, QCoreApplication.translate("MainWindow", u"TXT", None)) 498 | 499 | #if QT_CONFIG(statustip) 500 | self.scrollArea_4.setStatusTip(QCoreApplication.translate("MainWindow", u"Document Preview", None)) 501 | #endif // QT_CONFIG(statustip) 502 | self.label_doc_view.setText("") 503 | # retranslateUi 504 | 505 | # =====================================================| About Window |============================================================= 506 | 507 | class Ui_AboutWindow(object): 508 | def setupUi(self, AboutWindow, icon, version_app): 509 | if not AboutWindow.objectName(): 510 | AboutWindow.setObjectName(u"AboutWindow") 511 | AboutWindow.resize(534, 328) 512 | AboutWindow.setMinimumSize(QSize(491, 302)) 513 | AboutWindow.setMaximumSize(QSize(534, 328)) 514 | self.centralwidget = QWidget(AboutWindow) 515 | self.centralwidget.setObjectName(u"centralwidget") 516 | self.gridLayout = QGridLayout(self.centralwidget) 517 | self.gridLayout.setObjectName(u"gridLayout") 518 | self.gridLayout.setHorizontalSpacing(20) 519 | self.gridLayout.setVerticalSpacing(15) 520 | self.gridLayout.setContentsMargins(20, 20, 20, 20) 521 | self.verticalLayout_3 = QVBoxLayout() 522 | self.verticalLayout_3.setSpacing(20) 523 | self.verticalLayout_3.setObjectName(u"verticalLayout_3") 524 | self.verticalLayout_3.setContentsMargins(-1, 20, -1, -1) 525 | self.label_6 = QLabel(self.centralwidget) 526 | self.label_6.setObjectName(u"label_6") 527 | self.label_6.setPixmap(QPixmap(icon)) 528 | self.label_6.setAlignment(Qt.AlignCenter) 529 | 530 | self.verticalLayout_3.addWidget(self.label_6) 531 | 532 | self.label_7 = QLabel(self.centralwidget) 533 | self.label_7.setObjectName(u"label_7") 534 | self.label_7.setAlignment(Qt.AlignHCenter|Qt.AlignTop) 535 | self.label_7.setOpenExternalLinks(True) 536 | 537 | self.verticalLayout_3.addWidget(self.label_7) 538 | 539 | 540 | self.gridLayout.addLayout(self.verticalLayout_3, 0, 0, 2, 1) 541 | 542 | self.label = QLabel(self.centralwidget) 543 | self.label.setObjectName(u"label") 544 | font = QFont() 545 | font.setPointSize(16) 546 | font.setBold(True) 547 | self.label.setFont(font) 548 | 549 | self.gridLayout.addWidget(self.label, 0, 1, 1, 1) 550 | 551 | self.verticalLayout = QVBoxLayout() 552 | self.verticalLayout.setSpacing(15) 553 | self.verticalLayout.setObjectName(u"verticalLayout") 554 | self.label_3 = QLabel(self.centralwidget) 555 | self.label_3.setObjectName(u"label_3") 556 | 557 | self.verticalLayout.addWidget(self.label_3) 558 | 559 | self.label_2 = QLabel(self.centralwidget) 560 | self.label_2.setObjectName(u"label_2") 561 | self.label_2.setTextFormat(Qt.AutoText) 562 | self.label_2.setWordWrap(True) 563 | 564 | self.verticalLayout.addWidget(self.label_2) 565 | 566 | self.label_4 = QLabel(self.centralwidget) 567 | self.label_4.setObjectName(u"label_4") 568 | 569 | self.verticalLayout.addWidget(self.label_4) 570 | 571 | self.label_5 = QLabel(self.centralwidget) 572 | self.label_5.setObjectName(u"label_5") 573 | 574 | self.verticalLayout.addWidget(self.label_5) 575 | 576 | 577 | self.gridLayout.addLayout(self.verticalLayout, 1, 1, 1, 1) 578 | 579 | self.button_ok = QPushButton(self.centralwidget) 580 | self.button_ok.setObjectName(u"button_ok") 581 | 582 | self.gridLayout.addWidget(self.button_ok, 2, 1, 1, 1) 583 | 584 | AboutWindow.setCentralWidget(self.centralwidget) 585 | self.menubar = QMenuBar(AboutWindow) 586 | self.menubar.setObjectName(u"menubar") 587 | self.menubar.setGeometry(QRect(0, 0, 534, 22)) 588 | AboutWindow.setMenuBar(self.menubar) 589 | self.statusbar = QStatusBar(AboutWindow) 590 | self.statusbar.setObjectName(u"statusbar") 591 | AboutWindow.setStatusBar(self.statusbar) 592 | 593 | self.retranslateUi(AboutWindow, version_app) 594 | 595 | QMetaObject.connectSlotsByName(AboutWindow) 596 | # setupUi 597 | 598 | def retranslateUi(self, AboutWindow, version_app): 599 | AboutWindow.setWindowTitle(QCoreApplication.translate("AboutWindow", u"About", None)) 600 | self.label_6.setText("") 601 | self.label_7.setText(QCoreApplication.translate("AboutWindow", u"

Web Page

", None)) 602 | self.label.setText(QCoreApplication.translate("AboutWindow", u"PDF GUI Tools", None)) 603 | self.label_3.setText(QCoreApplication.translate("AboutWindow", f"Version {version_app}", None)) 604 | self.label_2.setText(QCoreApplication.translate("AboutWindow", u"PDF GUI Tools is a graphical interface tool that integrates several utilities for managing PDF documents.", None)) 605 | self.label_4.setText(QCoreApplication.translate("AboutWindow", u"Developed by: Angel M.", None)) 606 | self.label_5.setText(QCoreApplication.translate("AboutWindow", u"GNU GENERAL PUBLIC LICENSE v3", None)) 607 | self.button_ok.setText(QCoreApplication.translate("AboutWindow", u"Ok", None)) 608 | # retranslateUi -------------------------------------------------------------------------------- /code/pdfgui_tools.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python3 2 | # 3 | # PDF GUI TOOLS - pdfgui_tools 4 | # 5 | # PDF GUI Tools app - Main file of pdfgui_tools 6 | # Utilities are found in another file: pdfguiUtils 7 | # 8 | # Author: Angel Gabriel Mortera Gual 9 | # License: GNU GENERAL PUBLIC LICENSE v3 10 | # 11 | # Project: https://github.com/TheWatcherMultiversal/pdfgui_tools/ 12 | # 13 | # ----------------------------------------------------------------------------------- 14 | 15 | from pdfguiWindows import (Ui_MainWindow, Ui_AboutWindow, QApplication, QMainWindow, QListWidgetItem, QSize, QCoreApplication, QIcon, QFont, QPixmap) 16 | from pdfguiUtils import (Paths, version_app, repeat_symbol, icon_pdf, icon_pdfEncrypt, spinBox_range, maxSizeDocument, PyPDF2utils, PyMuPDF_Utils) 17 | from PySide6.QtWidgets import (QMessageBox, QFileDialog)# <---| 18 | from PySide6.QtCore import (Qt)# <-------------------------| PySide6 v6.6.0 19 | import sys, os, subprocess, argparse 20 | 21 | # ---------------------------------------------------------------------------------------------------------------- 22 | # | 23 | # | 24 | # °-- Arguments: 25 | 26 | parser = argparse.ArgumentParser() 27 | parser.add_argument('-m', '--man', action='store_true', help='man page') 28 | parser.add_argument('-v', '--version', action='store_true', help='print version') 29 | args = parser.parse_args() 30 | 31 | if args.man is True : os.system('man pdfgui_tools') ; sys.exit() 32 | elif args.version is True : print(f'PDF GUI Tools v{version_app}') ; sys.exit() 33 | 34 | # ---------------------------------------------------------------------------------------------------------------- 35 | # | 36 | # | 37 | # °-- Code pdfgui_tools: 38 | 39 | 40 | # Class for the main window 41 | class pdfguiMainWindow(Ui_MainWindow): 42 | 43 | # Setting values for the main window 44 | def __init__(self): 45 | # -> Icon app 46 | icon_app = QIcon(); icon_app.addPixmap(QPixmap(Paths["icon_app"]), QIcon.Normal, QIcon.Off) 47 | 48 | # -> Build the main window interface 49 | self.setupUi(MainWindow, icon_app) 50 | 51 | # -> Dictionary of PDF Information 52 | self.dictPDFs = {} 53 | 54 | # -> Dictionary type of document conversion 55 | self.dictConvert = { 56 | "HTML" : ("pdftohtml" , False), 57 | "TXT" : ("pdftotext" , False), 58 | "PNG" : ("pdftocairo -png" , True), 59 | "JPEG" : ("pdftocairo -jpeg", True), 60 | } 61 | for pdftocairo in ("PS", "EPS", "SVG"): 62 | self.dictConvert[pdftocairo] = (f'pdftocairo -{pdftocairo.lower()}', False) 63 | 64 | # -> Disable Elements 65 | self.checkBox_range.setEnabled(False) 66 | self.spinBox_range_initial.setEnabled(False) 67 | self.spinBox_range_final.setEnabled(False) 68 | self.button_view.setEnabled(False) 69 | self.button_separate.setEnabled(False) 70 | self.button_convert.setEnabled(False) 71 | 72 | # -> Actions 73 | self.actionAdd_File.triggered.connect(self.click_add) 74 | self.actionDelete.triggered.connect(self.click_delete) 75 | self.actionUp.triggered.connect(self.move_up) 76 | self.actionDown.triggered.connect(self.move_down) 77 | self.actionView_Utils.triggered.connect(lambda: self.dockWidget.show()) 78 | self.actionMerge.triggered.connect(self.merge_pdf) 79 | self.actionHelp.triggered.connect(self._help) 80 | self.actionAbout.triggered.connect(self._about) 81 | self.actionExit.triggered.connect(lambda: MainWindow.close()) 82 | self.actionEncrypt.triggered.connect(lambda: self.encrypt_decrypt(True, icon_pdfEncrypt)) 83 | self.actionDecrypt.triggered.connect(lambda: self.encrypt_decrypt(False, icon_pdf)) 84 | 85 | # -> checkBox 86 | self.checkBox_range.stateChanged.connect(self.click_checkBox_range) 87 | 88 | # spinBox 89 | # --> Min range: 90 | self.spinBox_range_initial.setMinimum(spinBox_range[0]) 91 | self.spinBox_range_final.setMinimum(spinBox_range[0]) 92 | # --> Max range: 93 | self.spinBox_range_initial.setMaximum(spinBox_range[1]) 94 | self.spinBox_range_final.setMaximum(spinBox_range[1]) 95 | # --> Change range: 96 | self.spinBox_range_initial.valueChanged.connect(self.spinbox_initial_changed) 97 | self.spinBox_range_final.valueChanged.connect(self.spinbox_final_changed) 98 | 99 | # -> Buttons 100 | self.button_view.clicked.connect(self.click_view) 101 | self.button_add.clicked.connect(self.click_add) 102 | self.button_delete.clicked.connect(self.click_delete) 103 | self.button_up.clicked.connect(self.move_up) 104 | self.button_down.clicked.connect(self.move_down) 105 | self.button_utils.clicked.connect(lambda: self.dockWidget.show()) 106 | self.button_merge.clicked.connect(self.merge_pdf) 107 | self.button_encrypt.clicked.connect(lambda: self.encrypt_decrypt(True, icon_pdfEncrypt)) 108 | self.button_decrypt.clicked.connect(lambda: self.encrypt_decrypt(False, icon_pdf)) 109 | self.button_separate.clicked.connect(self.separate_pdf) 110 | self.button_convert.clicked.connect(self.convert) 111 | 112 | # -> listWidget: 113 | self.listWidget.selectionModel().selectionChanged.connect(self.click_listWidget) 114 | 115 | 116 | # Click listWidget 117 | def click_listWidget(self): 118 | # -> The index of the selected item is obtained 119 | selected_item = self.listWidget.selectionModel().selectedIndexes() 120 | 121 | if not self.dictPDFs: 122 | # --> Disabled buttons 123 | self.label.setText("Select a document") 124 | self.checkBox_range.setDisabled(True) 125 | self.spinBox_range_initial.setDisabled(True) 126 | self.spinBox_range_final.setDisabled(True) 127 | self.button_view.setDisabled(True) 128 | self.button_separate.setDisabled(True) 129 | self.button_convert.setDisabled(True) 130 | self.button_convert.setDisabled(True) 131 | # -> View Document: 132 | self.label_doc_view.setPixmap(QPixmap("")) 133 | return 134 | 135 | # -> Current item data 136 | item = selected_item[0].data() 137 | 138 | # -> Enabled buttons 139 | self.checkBox_range.setEnabled(True) 140 | self.spinBox_range_initial.setEnabled(True) 141 | self.spinBox_range_final.setEnabled(True) 142 | self.button_view.setEnabled(True) 143 | self.button_separate.setEnabled(True) 144 | self.button_convert.setEnabled(True) 145 | self.button_convert.setEnabled(True) 146 | 147 | # -> Gets the state of the elements 148 | self.checkBox_range.setChecked(self.dictPDFs[item][0]) 149 | self.spinBox_range_initial.setValue(self.dictPDFs[item][1][0]) 150 | self.spinBox_range_final.setValue(self.dictPDFs[item][1][1]) 151 | self.label.setText(item) 152 | 153 | # -> Gets the scale and size of the document 154 | try: 155 | scale = PyMuPDF_Utils(self.dictPDFs[item][2]).documentScale() 156 | if scale is None: scale = 1 157 | self.scrollVerticalLayout_DocPreview.setMaximumSize(QSize(maxSizeDocument, int(maxSizeDocument * scale))) 158 | except: 159 | self.scrollVerticalLayout_DocPreview.setMaximumSize(QSize(maxSizeDocument, maxSizeDocument)) 160 | 161 | # -> View Document: 162 | self.label_doc_view.setPixmap(QPixmap(self.dictPDFs[item][2])) 163 | 164 | 165 | # Click checkBox 'Page Range' 166 | def click_checkBox_range(self): 167 | check_state = self.checkBox_range.checkState().value > 0 168 | selected_item = self.listWidget.selectionModel().selectedIndexes() 169 | item = selected_item[0].data() 170 | self.dictPDFs[item][0] = check_state 171 | 172 | 173 | # Gets the change from the spinBox 174 | def spinbox_initial_changed(self): 175 | get_value = self.spinBox_range_initial.value() 176 | selected_item = self.listWidget.selectionModel().selectedIndexes() 177 | item = selected_item[0].data() 178 | self.dictPDFs[item][1][0] = get_value 179 | 180 | 181 | def spinbox_final_changed(self): 182 | get_value = self.spinBox_range_final.value() 183 | selected_item = self.listWidget.selectionModel().selectedIndexes() 184 | item = selected_item[0].data() 185 | self.dictPDFs[item][1][1] = get_value 186 | 187 | 188 | def click_view(self): 189 | selected_item = self.listWidget.selectionModel().selectedIndexes() 190 | item = selected_item[0].data() 191 | view_doc = self.dictPDFs[item][2] 192 | try: 193 | subprocess.run(f"xdg-open '{view_doc}'", shell=True, check=True) 194 | except subprocess.CalledProcessError: 195 | self.inf_messages(*("Error", 'The selected document could not be viewed')) 196 | 197 | 198 | # Function to add a file to 'self.listWidget' 199 | def click_add(self): 200 | options = QFileDialog.Options() 201 | options |= QFileDialog.DontUseNativeDialog 202 | files, _ = QFileDialog.getOpenFileNames(MainWindow, "Select PDF Files", "", "PDF Files (*.pdf);;All Files (*)", options=options) 203 | if files: 204 | for pdf in files: 205 | path_file = pdf 206 | pdf = os.path.basename(pdf) 207 | # ---> While loop in case a path is repeated 208 | while self.dictPDFs.get(pdf) is not None: 209 | pdf += repeat_symbol 210 | 211 | # ---> Set the icon type 212 | if PyPDF2utils.fileEncrypted(path_file): icon_file = icon_pdfEncrypt 213 | else: icon_file = icon_pdf 214 | icon = QIcon(QIcon.fromTheme(icon_file)) 215 | font = QFont(); font.setPointSize(11); font.setBold(True) 216 | 217 | __qlistwidgetitem = QListWidgetItem(self.listWidget); __qlistwidgetitem.setTextAlignment(Qt.AlignCenter) 218 | __qlistwidgetitem.setFont(font) ; __qlistwidgetitem.setIcon(icon) 219 | __qlistwidgetitem.setText(QCoreApplication.translate("MainWindow", pdf, None)); 220 | 221 | self.dictPDFs[pdf] = [False, [1,1], path_file, __qlistwidgetitem] 222 | 223 | 224 | # Function to delete the selected item from the 'self.listWidget' widget 225 | def click_delete(self): 226 | selected_item = self.listWidget.currentItem() 227 | if selected_item: 228 | item = selected_item.text() 229 | del self.dictPDFs[item]#-------------------> Remove the element from the PDF Dictionary 230 | row = self.listWidget.row(selected_item) 231 | self.listWidget.takeItem(row) 232 | 233 | 234 | # Move the position of an item in the list 235 | def move_up(self): 236 | selected_item = self.listWidget.currentItem() 237 | if selected_item: 238 | row = self.listWidget.row(selected_item) 239 | if row > 0: 240 | self.listWidget.takeItem(row) 241 | self.listWidget.insertItem(row - 1, selected_item) 242 | self.listWidget.setCurrentItem(selected_item) 243 | 244 | 245 | def move_down(self): 246 | selected_item = self.listWidget.currentItem() 247 | if selected_item: 248 | row = self.listWidget.row(selected_item) 249 | if row < self.listWidget.count() - 1: 250 | self.listWidget.takeItem(row) 251 | self.listWidget.insertItem(row + 1, selected_item) 252 | self.listWidget.setCurrentItem(selected_item) 253 | 254 | 255 | # -------------------------------------| Utility Functions of pdfgui_tools |-------------------------------------------------------- 256 | 257 | # Merge PDFs 258 | def merge_pdf(self): 259 | if self.listWidget.count() < 2: 260 | self.inf_messages(*("Info", 'Add at least two files')) 261 | 262 | # -> Concatenate the paths of the files stored in the list to the 'self.command' command 263 | else: 264 | # --> Notice 265 | self.label_notice.setText("Merge PDFs, please wait..."); pdfs = [] 266 | 267 | for row in range(self.listWidget.count()): 268 | item = self.listWidget.item(row).text() 269 | pdfs.append(self.dictPDFs[item]) 270 | 271 | options = QFileDialog.Options() 272 | 273 | # --> Asks where to save and how to name the file, obtains the path 274 | file_name, _ = QFileDialog.getSaveFileName(MainWindow, "Save File", ".pdf", "PDF Files (*.pdf)", options=options) 275 | 276 | if file_name: 277 | status = PyPDF2utils.merge_pdf(name_file=file_name, pdfs=pdfs) 278 | if status is not True: self.inf_messages(*status); self.label_notice.setText(""); return 279 | self.inf_messages("Info", "The process has completed") 280 | 281 | self.label_notice.setText("") 282 | 283 | 284 | # Encrypt or Decrypt PDFs: 285 | def encrypt_decrypt(self, encrypt:bool, icon_file:str): 286 | if self.listWidget.count() < 1: 287 | self.inf_messages(*("Info", 'Add at least one file')) 288 | 289 | # -> Concatenate the paths of the files stored in the list to the 'self.command' command 290 | else: 291 | if encrypt: notice = "Encrypting Files..." 292 | else: notice = "Decrypting Files..." 293 | 294 | # --> Notice 295 | self.label_notice.setText(notice) 296 | 297 | # --> Get Values 298 | pdfs = self.dictPDFs.values() 299 | 300 | # --> Confirm the action of encrypting or decrypting 301 | confirm_dialog = QMessageBox.question(MainWindow, "Confirm the action", "Are you sure you want to perform the action?", QMessageBox.Yes | QMessageBox.No) 302 | if confirm_dialog == QMessageBox.No: self.label_notice.setText(""); return 303 | 304 | # --> The 'Password' field is empty 305 | if not self.lineEdit_password.text(): self.inf_messages("Info", "Enter a password"); self.label_notice.setText(""); return 306 | 307 | for pdf in pdfs: 308 | doc_pdf = pdf[2]; itemListWidget = pdf[3] 309 | if encrypt: status = PyPDF2utils.encrypt_pdf(doc_pdf, self.lineEdit_password.text()) 310 | else: status = PyPDF2utils.decrypt_pdf(doc_pdf, self.lineEdit_password.text()) 311 | if status is not True: self.inf_messages(*status); continue 312 | 313 | # Change Icon Item 314 | itemListWidget.setIcon(QIcon(QIcon.fromTheme(icon_file))) 315 | 316 | self.inf_messages("Info", "The process has completed"); self.label_notice.setText("") 317 | 318 | 319 | # Separate PDF 320 | def separate_pdf(self): 321 | 322 | if self.listWidget.count() < 1: 323 | self.inf_messages("Info", 'You need to add file') 324 | 325 | # -> Concatenate the paths of the files stored in the list to the 'self.command' command 326 | else: 327 | # --> Command 328 | self.command = "pdfseparate" 329 | 330 | # --> Notice 331 | self.label_notice.setText("Separate pdf, please wait...") 332 | 333 | # --> Get Current Item 334 | selected_item = self.listWidget.selectionModel().selectedIndexes() ; item = selected_item[0].data() 335 | path_pdf = self.dictPDFs[item][2] ; checkRangeState = self.dictPDFs[item][0] 336 | 337 | # --> File encrypted 338 | if PyPDF2utils.fileEncrypted(path_pdf): 339 | self.inf_messages("Info", f"The document {item} is encrypted, decrypt it to perform this action") 340 | self.label_notice.setText(""); return 341 | 342 | # --> Compare the status of the checkboxes 343 | if checkRangeState: 344 | ran_pages = self.dictPDFs[item][1] 345 | self.command += ' ' + f'-f {ran_pages[0]}' 346 | self.command += ' ' + f'-l {ran_pages[1]}' 347 | 348 | # --> Add the path to the command 349 | self.command += ' "' + path_pdf + '"' 350 | 351 | # --> Asks where to save and how to name the file, obtains the path 352 | options = QFileDialog.Options() 353 | options |= QFileDialog.ShowDirsOnly 354 | options |= QFileDialog.DontUseNativeDialog 355 | directory, _ = QFileDialog.getSaveFileName(MainWindow, "Create Directory", "", "", options=options) 356 | directory_name = str(os.path.basename(directory)) 357 | 358 | if directory: 359 | # ---> An attempt is made to create the directory 360 | try: 361 | subprocess.run([f'mkdir "{directory}"'], check=True, shell=True) 362 | except subprocess.CalledProcessError: 363 | self.inf_messages("Error", 'Error while creating the directory, please try with another name') 364 | self.label_notice.setText(""); return 365 | 366 | self.command += " " + str(f'"{directory}/{directory_name}%d.pdf"') 367 | 368 | # ---> Run the 'pdfseparate' command in the system 369 | try: 370 | subprocess.run([self.command], check=True, shell=True) 371 | self.inf_messages("Info", "The process has completed") 372 | except subprocess.CalledProcessError: 373 | self.inf_messages("Error", 'Verify the options and file integrity, use the F1 key for help') 374 | 375 | self.label_notice.setText("") 376 | 377 | 378 | # Convert PDF 379 | def convert(self): 380 | 381 | if self.listWidget.count() < 1: 382 | self.inf_messages("Info", 'You need to add file') 383 | 384 | # -> Concatenate the paths of the files stored in the list to the 'self.command' command 385 | else: 386 | # --> Get the value of the ComboBox 387 | filetype = str(self.combo_filetype.currentText()) 388 | lower_filetype = filetype.lower() 389 | 390 | # --> Get Current Item 391 | selected_item = self.listWidget.selectionModel().selectedIndexes(); item = selected_item[0].data() 392 | path_pdf = self.dictPDFs[item][2] 393 | 394 | # --> Notice 395 | self.label_notice.setText(f"Convert pdf to {lower_filetype}, please wait...") 396 | 397 | # --> File encrypted 398 | if PyPDF2utils.fileEncrypted(path_pdf): 399 | self.inf_messages("Info", f"The document {item} is encrypted, decrypt it to perform this action") 400 | self.label_notice.setText(""); return 401 | 402 | # --> Obtains the type of conversion and command 403 | self.command = self.dictConvert[filetype][0] 404 | 405 | # --> Add the path to the command 406 | self.command += ' "' + path_pdf + '"' 407 | 408 | # --> Asks where to save and how to name the file, obtains the path 409 | options = QFileDialog.Options() 410 | file_name, _ = QFileDialog.getSaveFileName(MainWindow, "Save File", f".{lower_filetype}", f"{filetype} Files (*.{lower_filetype})", options=options) 411 | 412 | if file_name: 413 | if self.dictConvert[filetype][1]: self.command += " " + (f'"{file_name[:- len(filetype) - 1]}"') 414 | else: self.command += " " + (f'"{file_name}"') 415 | print(self.command) 416 | print("Save file:", file_name) 417 | 418 | # ---> Run the command in the system 419 | try: 420 | subprocess.run([self.command], check=True, shell=True) 421 | self.inf_messages("Info", "The process has completed") 422 | except subprocess.CalledProcessError: 423 | self.label_notice.setText("") 424 | self.inf_messages("Error", 'Error Executing the command, please verify the name and integrity of the document') 425 | 426 | self.label_notice.setText("") 427 | 428 | 429 | # --------------------------------------| About and Help window |----------------------------------------------------------------------------------- 430 | 431 | # Function Help 432 | def _help(self): 433 | 434 | # Help Message: 435 | QMessageBox.about(MainWindow, "Help", """Controls: 436 | - Add files to the list: Ctrl+A (Two files needed to merge) 437 | - Delete an item: Backspace 438 | - Move an item to another position: Use the 'up' and 'down' keys 439 | - Merge the PDFs: Ctrl+S 440 | - Encrypt PDFs: Ctrl+E (Requires the 'Password' field to have a password) 441 | - Decrypt PDFs: Ctrl+D (Requires the 'Password' field to have a password) 442 | 443 | Advance Options: 444 | - Page Range: CheckBox in case you require a PDF document to use a range of pages to combine with others and not the entire document. 445 | - Initial: Page of the document where it will start merging the PDFs with the other PDF documents. 446 | - Final: Final page of the document where it will finish merging with the other PDF documents. 447 | - Password: Field for setting an encryption or decryption password. 448 | - View PDF: Open the PDF document in your default PDF document viewer using xdg-open. 449 | - Separate PDF: Splits the PDF document into multiple pages, can be used in conjunction with the page range. 450 | - Convert PDF: It will convert the document to the selected format. 451 | """) 452 | 453 | def _about(self): 454 | aboutWin = QMainWindow(MainWindow); aboutWindow(aboutWin) 455 | aboutWin.show() 456 | 457 | # ------------------------------------------------------------------------------------------------------------------------------------------------------- 458 | 459 | # Messages 460 | def inf_messages(self, title, message): 461 | if title == "Error" : QMessageBox.critical (MainWindow, title, message, QMessageBox.Ok) 462 | elif title == "Info" : QMessageBox.information(MainWindow, title, message, QMessageBox.Ok) 463 | 464 | 465 | 466 | # Class for the Ui_AboutWindow window 467 | class aboutWindow(Ui_AboutWindow): 468 | 469 | # Setting values for the about window 470 | def __init__(self, aboutWin): 471 | self.setupUi(aboutWin, Paths["icon_app"], version_app) 472 | self.button_ok.clicked.connect(lambda: aboutWin.close()) 473 | 474 | 475 | 476 | if __name__ == "__main__": 477 | app = QApplication(sys.argv) ; MainWindow = QMainWindow() 478 | pdfguiMainWindow() ; MainWindow.show() 479 | with open(Paths["styles"], "r") as f:#-------------> Window style file 480 | _style = f.read() 481 | app.setStyleSheet(_style) 482 | sys.exit(app.exec()) -------------------------------------------------------------------------------- /designer/README.md: -------------------------------------------------------------------------------- 1 | ## Designer 2 | 3 | Here the UI files are stored to work directly with Qt 5 Designer. Each file must be converted to a Python file in order to be used and apply the programming logic in the program. Use the following command to perform this action: 4 | 5 | pyuic5 -x file.ui -o file.py -------------------------------------------------------------------------------- /designer/about.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | AboutWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 534 10 | 328 11 | 12 | 13 | 14 | 15 | 491 16 | 302 17 | 18 | 19 | 20 | 21 | 534 22 | 328 23 | 24 | 25 | 26 | About 27 | 28 | 29 | 30 | 31 | 20 32 | 33 | 34 | 20 35 | 36 | 37 | 20 38 | 39 | 40 | 20 41 | 42 | 43 | 20 44 | 45 | 46 | 15 47 | 48 | 49 | 50 | 51 | 20 52 | 53 | 54 | 20 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | ../icons/pdfguitools.svg 63 | 64 | 65 | Qt::AlignCenter 66 | 67 | 68 | 69 | 70 | 71 | 72 | <html><head/><body><p><a href="https://github.com/TheWatcherMultiversal/pdfgui_tools"><span style=" text-decoration: underline; color:#3484e2;">Web Page</span></a></p></body></html> 73 | 74 | 75 | Qt::AlignHCenter|Qt::AlignTop 76 | 77 | 78 | true 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 16 89 | true 90 | 91 | 92 | 93 | PDF GUI Tools 94 | 95 | 96 | 97 | 98 | 99 | 100 | 15 101 | 102 | 103 | 104 | 105 | Version {version_app} 106 | 107 | 108 | 109 | 110 | 111 | 112 | PDF GUI Tools is a graphical interface tool that integrates several utilities for managing PDF documents. 113 | 114 | 115 | Qt::AutoText 116 | 117 | 118 | true 119 | 120 | 121 | 122 | 123 | 124 | 125 | Developed by: Angel M. 126 | 127 | 128 | 129 | 130 | 131 | 132 | GNU GENERAL PUBLIC LICENSE v3 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | Ok 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 0 151 | 0 152 | 534 153 | 22 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /designer/pdfgui_tools.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 1176 10 | 827 11 | 12 | 13 | 14 | PDF GUI Tools 15 | 16 | 17 | 18 | 19 | 20 | 21 | true 22 | 23 | 24 | 25 | 26 | 0 27 | 0 28 | 823 29 | 763 30 | 31 | 32 | 33 | 34 | 35 | 36 | List PDFs 37 | 38 | 39 | 40 | 20 41 | 42 | 43 | 35 44 | 45 | 46 | 20 47 | 48 | 49 | 20 50 | 51 | 52 | 20 53 | 54 | 55 | 56 | 57 | true 58 | 59 | 60 | 61 | 62 | 63 | QAbstractItemView::InternalMove 64 | 65 | 66 | Qt::MoveAction 67 | 68 | 69 | 70 | 60 71 | 60 72 | 73 | 74 | 75 | 20 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 20 85 | 86 | 87 | 5 88 | 89 | 90 | 5 91 | 92 | 93 | 94 | 95 | Add File 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | Delete 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | View Utils 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | Merge 150 | 151 | 152 | 153 | 154 | 155 | 156 | Encrypt 157 | 158 | 159 | 160 | 161 | 162 | 163 | Decrypt 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 0 191 | 0 192 | 1176 193 | 22 194 | 195 | 196 | 197 | 198 | File 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | Help 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 327 225 | 108 226 | 227 | 228 | 229 | Qt::DefaultContextMenu 230 | 231 | 232 | false 233 | 234 | 235 | QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable 236 | 237 | 238 | Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea 239 | 240 | 241 | 1 242 | 243 | 244 | 245 | 246 | 247 | 248 | true 249 | 250 | 251 | 252 | 253 | 0 254 | 0 255 | 307 256 | 744 257 | 258 | 259 | 260 | 261 | 262 | 263 | Utilities 264 | 265 | 266 | 267 | 20 268 | 269 | 270 | 35 271 | 272 | 273 | 20 274 | 275 | 276 | 20 277 | 278 | 279 | 2 280 | 281 | 282 | 20 283 | 284 | 285 | 286 | 287 | true 288 | 289 | 290 | 291 | 292 | 0 293 | 0 294 | 239 295 | 68 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 11 304 | true 305 | 306 | 307 | 308 | Select a document 309 | 310 | 311 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 20 323 | 324 | 325 | 0 326 | 327 | 328 | 20 329 | 330 | 331 | 332 | 333 | Qt::Vertical 334 | 335 | 336 | 337 | 20 338 | 2000000000 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 11 348 | true 349 | 350 | 351 | 352 | Document page range 353 | 354 | 355 | Page Range 356 | 357 | 358 | 359 | 360 | 361 | 362 | 20 363 | 364 | 365 | 366 | 367 | 1000 368 | 369 | 370 | 371 | 372 | 373 | 374 | Final 375 | 376 | 377 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop 378 | 379 | 380 | 3 381 | 382 | 383 | 384 | 385 | 386 | 387 | Initial 388 | 389 | 390 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop 391 | 392 | 393 | 3 394 | 395 | 396 | 397 | 398 | 399 | 400 | 1000 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 20 410 | 411 | 412 | 0 413 | 414 | 415 | 20 416 | 417 | 418 | 419 | 420 | 421 | 11 422 | true 423 | 424 | 425 | 426 | Password 427 | 428 | 429 | 430 | 431 | 432 | 433 | false 434 | 435 | 436 | Set an encryption or decryption password 437 | 438 | 439 | Qt::ImhHiddenText|Qt::ImhNoAutoUppercase|Qt::ImhNoPredictiveText|Qt::ImhSensitiveData 440 | 441 | 442 | 443 | 444 | 445 | QLineEdit::Password 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | View PDF 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | Separate PDF 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | Convert PDF 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | PNG 485 | 486 | 487 | 488 | 489 | JPEG 490 | 491 | 492 | 493 | 494 | PS 495 | 496 | 497 | 498 | 499 | EPS 500 | 501 | 502 | 503 | 504 | SVG 505 | 506 | 507 | 508 | 509 | HTML 510 | 511 | 512 | 513 | 514 | TXT 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 16777215 531 | 16777215 532 | 533 | 534 | 535 | Document Preview 536 | 537 | 538 | true 539 | 540 | 541 | Qt::AlignCenter 542 | 543 | 544 | 545 | 546 | 0 547 | 0 548 | 287 549 | 144 550 | 551 | 552 | 553 | 554 | 300 555 | 387 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 16777215 564 | 16777215 565 | 566 | 567 | 568 | 569 | 570 | 571 | true 572 | 573 | 574 | Qt::AlignCenter 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | Add File 592 | 593 | 594 | Add File 595 | 596 | 597 | Ctrl+A 598 | 599 | 600 | 601 | 602 | Delete 603 | 604 | 605 | Delete File 606 | 607 | 608 | Backspace 609 | 610 | 611 | 612 | 613 | Up 614 | 615 | 616 | Up list 617 | 618 | 619 | Up 620 | 621 | 622 | 623 | 624 | Down 625 | 626 | 627 | Down list 628 | 629 | 630 | Down 631 | 632 | 633 | 634 | 635 | Merge 636 | 637 | 638 | Merge PDFs 639 | 640 | 641 | Ctrl+S 642 | 643 | 644 | 645 | 646 | Encrypt 647 | 648 | 649 | Encrypt PDFs 650 | 651 | 652 | Ctrl+E 653 | 654 | 655 | 656 | 657 | Decrypt 658 | 659 | 660 | Decrypt PDFs 661 | 662 | 663 | Ctrl+D 664 | 665 | 666 | 667 | 668 | Exit 669 | 670 | 671 | Exit app 672 | 673 | 674 | Esc 675 | 676 | 677 | 678 | 679 | Help 680 | 681 | 682 | Help 683 | 684 | 685 | F1 686 | 687 | 688 | 689 | 690 | About 691 | 692 | 693 | About 694 | 695 | 696 | 697 | 698 | View Utils 699 | 700 | 701 | View Utilities 702 | 703 | 704 | Ctrl+Q 705 | 706 | 707 | 708 | 709 | 710 | 711 | -------------------------------------------------------------------------------- /desktop/pdfgui_tools.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=PDF GUI Tools 3 | GenericName=PDF GUI Tools 4 | Comment=PDF GUI Tools 5 | TryExec=pdfgui_tools 6 | Exec=pdfgui_tools 7 | Icon=/usr/share/pdfgui_tools/assets/pdfguitools.svg 8 | Type=Application 9 | Terminal=false 10 | Categories=Office;Presentation; 11 | StartupNotify=true 12 | Keywords=pdf;pdfgui;tools 13 | -------------------------------------------------------------------------------- /icons/pdfguitools.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 20 | Logo PDF GUI Tools 22 | 41 | 43 | 49 | 52 | 56 | 57 | 60 | 64 | 65 | 68 | 72 | 76 | 77 | 84 | 92 | 96 | 100 | 101 | 109 | 113 | 117 | 118 | 125 | 129 | 133 | 134 | 143 | 150 | 151 | 155 | 163 | 166 | 174 | 182 | PDF 193 | 196 | 201 | 204 | 209 | 215 | 220 | 226 | 231 | 234 | 238 | 239 | 244 | 249 | 254 | 259 | 264 | 270 | 275 | 280 | 285 | 292 | 297 | 302 | 309 | 314 | 319 | 324 | 329 | 334 | 339 | 344 | 345 | 355 | 356 | 357 | 358 | 359 | 361 | 362 | 364 | Logo PDF GUI Tools 365 | 23 August 2023 366 | 367 | 368 | Angel Gual 369 | 370 | 371 | 373 | 374 | 375 | CC BY-SA 4.0 376 | 377 | 378 | 379 | 380 | Angel Gual 381 | 382 | 383 | 384 | 386 | 388 | 390 | 392 | 394 | 396 | 398 | 399 | 400 | 401 | 402 | -------------------------------------------------------------------------------- /install.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python3 2 | # 3 | # Installer pdfgui_tools 4 | # 5 | # PDF GUI Tools | pdfgui_tools installation script 6 | # GitHub: https://github.com/TheWatcherMultiversal/pdfgui_tools 7 | # 8 | # License: GPLv3 (GNU/General Public License version 3.0) 9 | # 10 | # ------------------------------------------------------------------ (*) 11 | # | 12 | # | 13 | # °-- Include modules: 14 | 15 | import subprocess 16 | import argparse 17 | import sys 18 | try: 19 | from colorama import Fore 20 | except ImportError: 21 | print("Install python3-colorama to be able to run the installation script.") 22 | 23 | # ---------------------------------------------------------------------------------------------------------------- 24 | # | 25 | # | 26 | # °-- Argument: 27 | parser = argparse.ArgumentParser() 28 | parser.add_argument('-a', '--all', action='store_true', help='Incorporate poppler-utils into the installation script') 29 | parser.add_argument('-A', '--arch-all', action='store_true', help='Install the pdfgui_tools version for all architectures') 30 | parser.add_argument('-u', '--uninstall', action='store_true', help='Uninstall the installed pdfgui_tools packages') 31 | parser.add_argument('-r', '--remove-all', action='store_true', help='Remove all installed pdfgui_tools packages, including poppler-utils') 32 | args = parser.parse_args() 33 | 34 | 35 | # ----------------------------------------------------------------------------------------------------------------- 36 | # | 37 | # | 38 | # °-- Defining the variable names: 39 | 40 | # pdfgui_tools: 41 | version = '2.0.0' 42 | if args.arch_all : arch_pdfgui_tools = 'all' 43 | else : arch_pdfgui_tools = 'x86_64' 44 | package_pdfgui = (f'pdfgui_tools_stable-release_{version}_{arch_pdfgui_tools}.tar.gz') 45 | url_package_pdfgui = (f'https://github.com/TheWatcherMultiversal/pdfgui_tools/releases/download/v{version}/{package_pdfgui}') 46 | paths_pdfgui = ["/usr/bin/pdfgui_tools", "/usr/share/pdfgui_tools/", "/usr/share/applications/pdfgui_tools.desktop", "/usr/share/doc/pdfgui_tools/", "/usr/share/man/man1/pdfgui_tools.1.gz", "/usr/bin/pdfguiUtils.py", "/usr/bin/pdfguiWindows.py"] 47 | 48 | # poppler-utils: 49 | version_poppler = '23.08' 50 | package_poppler = (f'poppler-utils_{version_poppler}_amd64.tar.gz') 51 | url_package_poppler = (f'https://github.com/TheWatcherMultiversal/pdfgui_tools/releases/download/v{version}/{package_poppler}') 52 | 53 | bin_packages_poppler = ['pdfattach', 'pdfdetach', 'pdffonts', 'pdfimages', 'pdfinfo', 'pdfseparate', 'pdfsig', 'pdftocairo', 'pdftohtml', 'pdftoppm', 'pdftops', 'pdftotext', 'pdfunite'] 54 | paths_poppler = ["/usr/share/doc/poppler-utils"] 55 | for bin_package in bin_packages_poppler: 56 | paths_poppler.append(f"/usr/bin/{bin_package}") 57 | paths_poppler.append(f"/usr/share/man/man1/{bin_package}.1.gz") 58 | 59 | # ------------------------------------------------------------------------------------------------------------------------------ 60 | 61 | 62 | def install_targz(package : str, url : str, paths : list): 63 | # ----> Download tar.gz from the specified URL <---- # 64 | 65 | print(Fore.GREEN + f"\r\nInstall {package}\r\n" + Fore.RESET) 66 | 67 | try: 68 | subprocess.run([f'wget {url}'], check=True, shell=True) 69 | 70 | except subprocess.CalledProcessError: 71 | print(Fore.RED + 'Error:' + Fore.RESET + ' command wget or source not found.') 72 | sys.exit(1) 73 | 74 | # ---> Extract the tar.gz file <---- # 75 | 76 | print(Fore.GREEN + 'Extracting content...\r\n' + Fore.RESET) 77 | 78 | try: 79 | subprocess.run([f'tar -xvzf {package}'], check=True, shell=True) 80 | 81 | except subprocess.CalledProcessError: 82 | subprocess.run([f'rm {package}'], check=True, shell=True) 83 | print(Fore.RED + 'Error:' + Fore.RESET + ' the package could not be extracted.') 84 | sys.exit(2) 85 | 86 | # ----> Remove package if it's previously installed <---- # 87 | 88 | print(Fore.GREEN + '\r\nRemoving existing files and installing new ones...' + Fore.RESET) 89 | uninstall_targz(package, paths) 90 | 91 | # ----> Build the package on the system <---- 92 | 93 | print(Fore.YELLOW + '\r\nThe following command requires superuser privileges:' + Fore.RESET + ' sudo cp -R -n\r\n') 94 | print(Fore.GREEN + 'Copying files to their corresponding paths...' + Fore.RESET) 95 | 96 | try: 97 | subprocess.run([f'sudo cp -R -n {package[:-7]}/usr/ /'], check=True, shell=True) 98 | 99 | except subprocess.CalledProcessError: 100 | subprocess.run([f'rm -r {package} {package[:-7]}'], check=True, shell=True) 101 | print(Fore.RED + 'Error:' + Fore.RESET + ' error copying files to the corresponding paths.') 102 | sys.exit(3) 103 | 104 | # Remove the files generated during the installation 105 | subprocess.run(f'rm -r {package[:-7]} {package}', shell=True) 106 | print(Fore.GREEN + '\r\nInstallation complete' + Fore.RESET + ', run ' + Fore.YELLOW + './uninstall.py' + Fore.RESET + f' to remove {package}\r\n') 107 | 108 | 109 | 110 | def uninstall_targz(package : str, paths : list): 111 | # ----> Remove packages <---- # 112 | 113 | print(Fore.RED + f"\r\nRemove {package[:-7]}" + Fore.RESET) 114 | print(Fore.YELLOW + '\r\nThe following command requires superuser privileges:' + Fore.RESET + ' sudo rm -r\r\n') 115 | print(Fore.GREEN + 'Removing existing files' + Fore.RESET) 116 | 117 | for path_ in paths: 118 | subprocess.run(f"sudo rm -r {path_}", shell=True) 119 | 120 | print(Fore.GREEN + f"\r\nPackage {package} removed successfully" + Fore.RESET) 121 | 122 | # ------------------------------------------------------------------------------------------------------------------------------------------------------ 123 | # | 124 | # | 125 | # °-- Install pdfgui_tools: 126 | if (args.all or args.uninstall or args.remove_all) is False: 127 | install_targz(package_pdfgui ,url_package_pdfgui, paths_pdfgui); 128 | 129 | if args.all : install_targz (package_poppler, url_package_poppler, paths_poppler); sys.exit() 130 | elif args.uninstall : uninstall_targz(package_pdfgui, paths_pdfgui); sys.exit() 131 | elif args.remove_all : uninstall_targz(package_pdfgui, paths_pdfgui); uninstall_targz(package_poppler, paths_poppler); sys.exit() 132 | -------------------------------------------------------------------------------- /man/pdfgui_tools.1: -------------------------------------------------------------------------------- 1 | ." Process this file with 2 | ." groff -man -Tascii pdfgui_tools.1 3 | ." 4 | .TH pdfgui_tools "1" "" "" "User commands" 5 | 6 | .SH NAME 7 | pdfgui_tools - PDF GUI Tools 8 | 9 | .SH SYNOPSIS 10 | .B pdfgui_tools 11 | .OP OPTIONS 12 | 13 | .SH DESCRIPTION 14 | .B pdfgui_tools 15 | is a GUI tool that includes the poppler-utils and PyPDF2 tools for working with PDF documents. It includes the following utilities: 16 | 17 | .RS 18 | .nf 19 | - Merge PDFs: its purpose is to merge multiple PDFs into a single one. 20 | - Encrypt PDFs its for encrypting PDF documents. 21 | - Decrypt PDFs its for decrypting PDF documents. 22 | - Separate PDF its purpose is to split PDF documents. 23 | - Convert PDF its for converting the PDF to the selected format. 24 | .RE 25 | 26 | .SH OPTIONS 27 | 28 | .B "-h | --help"\fR 29 | Prints help. 30 | 31 | .B "-m | --man"\fR 32 | Man page. 33 | 34 | .B "-v | --version"\fR 35 | Prints version. 36 | 37 | .SH AUTHOR 38 | .PP 39 | Developed by Angel Gabriel Mortera Gual 40 | 41 | 42 | .SH REPORTING BUGS 43 | .PP 44 | Report errors or suggestions to my email 45 | 46 | .SH SEE ALSO 47 | .PP 48 | .br 49 | More information in 50 | 51 | -------------------------------------------------------------------------------- /styles/styles.css: -------------------------------------------------------------------------------- 1 | /* styles.css */ 2 | 3 | /* All window */ 4 | QWidget { 5 | background-color: #1e1e1e; 6 | color: #ffffff; 7 | } 8 | 9 | /* QListWidget */ 10 | QListWidget::item { 11 | border-style: solid; 12 | border-width: 5px; 13 | border-radius: 10px; 14 | border-color: #2e2e2e; 15 | color: #ffffff; 16 | } 17 | 18 | QListWidget::item:selected { 19 | border-color: #ff6262; 20 | } 21 | 22 | /* doc_view */ 23 | QLabel#label_doc_view { 24 | background-color: #fff; 25 | } 26 | 27 | 28 | /* Buttons */ 29 | QPushButton { 30 | background-color: #3c6ae7; 31 | color: #ffffff; 32 | border: none; 33 | padding: 6px 20px; 34 | border-radius: 5px; 35 | font-weight: bold; 36 | } 37 | 38 | QPushButton:hover { 39 | background-color: #3159c5; 40 | } 41 | 42 | QPushButton:pressed { 43 | background-color: #263aa9; 44 | } 45 | 46 | /* Window Buttons */ 47 | 48 | QPushButton#button_merge { 49 | background-color: #b65200; 50 | color: #ffffff; 51 | border: none; 52 | padding: 6px 20px; 53 | border-radius: 5px; 54 | font-weight: bold; 55 | } 56 | 57 | QPushButton#button_merge:hover { 58 | background-color: #9c4600; 59 | } 60 | 61 | QPushButton#button_merge:pressed { 62 | background-color: #853c00; 63 | } 64 | 65 | QPushButton#button_encrypt { 66 | background-color: #108016; 67 | color: #ffffff; 68 | border: none; 69 | padding: 6px 20px; 70 | border-radius: 5px; 71 | font-weight: bold; 72 | } 73 | 74 | QPushButton#button_encrypt:hover { 75 | background-color: #0e7413; 76 | } 77 | 78 | QPushButton#button_encrypt:pressed { 79 | background-color: #0e6613; 80 | } 81 | 82 | QPushButton#button_decrypt { 83 | background-color: #108016; 84 | color: #ffffff; 85 | border: none; 86 | padding: 6px 20px; 87 | border-radius: 5px; 88 | font-weight: bold; 89 | } 90 | 91 | QPushButton#button_decrypt:hover { 92 | background-color: #0e7413; 93 | } 94 | 95 | QPushButton#button_decrypt:pressed { 96 | background-color: #0e6613; 97 | } 98 | 99 | /* Group Box */ 100 | QGroupBox { 101 | border: 2px solid #e74c3c; 102 | border-radius: 5px; 103 | margin-top: 10px; 104 | padding: 10px; 105 | background-color: #1e1e1e; 106 | } 107 | 108 | QGroupBox:title { 109 | padding: 5px; 110 | background-color: #e74c3c; 111 | color: white; 112 | font-size: 14px; 113 | font-weight: bold; 114 | } 115 | 116 | /* Check Box */ 117 | QCheckBox { 118 | font-size: 14px; 119 | color: #ffffff; 120 | padding: 5px; 121 | } 122 | 123 | QCheckBox::indicator { 124 | width: 20px; 125 | height: 20px; 126 | } 127 | 128 | QCheckBox::indicator:unchecked { 129 | border: 2px solid #555; 130 | background-color: #333; 131 | } 132 | 133 | QCheckBox::indicator:checked { 134 | border: 2px solid #00cc4e; 135 | background-color: rgb(23, 207, 121); 136 | } 137 | 138 | QCheckBox::indicator:unchecked:hover, 139 | QCheckBox::indicator:checked:hover { 140 | border: 2px solid #00cc4e; 141 | } 142 | 143 | --------------------------------------------------------------------------------