├── .github └── workflows │ └── c-cpp.yml ├── .gitignore ├── .gitmodules ├── COPYING ├── README.md ├── assets ├── document.png ├── fusepdf-clear.png ├── fusepdf-denied.png ├── fusepdf-document.png ├── fusepdf-gofirst.png ├── fusepdf-open.png ├── fusepdf-quit.png ├── fusepdf-save.png ├── fusepdf-screenshot-2.png ├── fusepdf-screenshot.png ├── fusepdf-valid.png ├── fusepdf.desktop ├── fusepdf.ico ├── fusepdf.png ├── fusepdf.ui ├── hicolor │ ├── 128x128 │ │ └── apps │ │ │ └── fusepdf.png │ ├── 192x192 │ │ └── apps │ │ │ └── fusepdf.png │ ├── 256x256 │ │ └── apps │ │ │ └── fusepdf.png │ ├── 32x32 │ │ └── apps │ │ │ └── fusepdf.png │ ├── 48x48 │ │ └── apps │ │ │ └── fusepdf.png │ ├── 64x64 │ │ └── apps │ │ │ └── fusepdf.png │ └── 96x96 │ │ └── apps │ │ └── fusepdf.png ├── icc │ └── srgb.icc ├── nettstudio.png └── ps │ └── PDFA_def.ps ├── docs ├── CNAME ├── README.pdf ├── _config.yml ├── _layouts │ └── default.html ├── fusepdf-screenshot-01.png ├── fusepdf-screenshot-02.png ├── fusepdf-screenshot-03.png ├── fusepdf-screenshot-04.png ├── fusepdf-screenshot-05.png ├── fusepdf-screenshot-06.png ├── fusepdf-screenshot-07.png ├── fusepdf-screenshot-08.png ├── fusepdf-screenshot-09.png ├── fusepdf-screenshot-10.png ├── index.md └── logo.png ├── fusepdf.bat ├── fusepdf.pro ├── fusepdf.qrc ├── src ├── fusepdf.cpp ├── fusepdf.h └── main.cpp └── tools ├── header.md ├── header.tex ├── md2pdf.sh └── mkdoc.sh /.github/workflows/c-cpp.yml: -------------------------------------------------------------------------------- 1 | name: C/C++ CI 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v2 12 | - name: apt install 13 | run: sudo apt-get update && sudo apt-get install qt5-default qtbase5-dev qttools5-dev-tools 14 | - name: configure 15 | run: qmake PREFIX=/usr 16 | - name: make 17 | run: make 18 | - name: install 19 | run: sudo make install 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | # -------- 75 | tmp 76 | mxe 77 | *.zip 78 | *.iss 79 | build 80 | pandoc 81 | gs 82 | gs.zip 83 | gs*.zip 84 | qt 85 | pandoc-* 86 | 87 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "i18n"] 2 | path = i18n 3 | url = https://github.com/nettstudio/fusepdf-i18n 4 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 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 | # FusePDF 2 | 3 | [![GitHub](https://img.shields.io/github/license/nettstudio/fusepdf)](https://github.com/nettstudio/fusepdf/blob/main/COPYING) [![C/C++ CI](https://github.com/nettstudio/fusepdf/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/nettstudio/fusepdf/actions/workflows/c-cpp.yml) [![GitHub issues](https://img.shields.io/github/issues/nettstudio/fusepdf)](https://github.com/nettstudio/fusepdf/issues) 4 | 5 | FusePDF is a simple cross-platform application used for merging, splitting and exporting PDF pages and documents. 6 | 7 | Copyright (c) 2021, 2022 [NettStudio AS](https://nettstudio.no). All rights reserved. 8 | 9 | [![NettStudio](https://raw.githubusercontent.com/nettstudio/fusepdf/main/assets/nettstudio.png)](https://nettstudio.no) 10 | 11 | **See [fusepdf.no](https://www.fusepdf.no/#open-source) for additional information.** 12 | 13 | [![Download FusePDF](https://a.fsdn.com/con/app/sf-download-button)](https://sourceforge.net/projects/fusepdf/files/latest/download) 14 | -------------------------------------------------------------------------------- /assets/document.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/assets/document.png -------------------------------------------------------------------------------- /assets/fusepdf-clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/assets/fusepdf-clear.png -------------------------------------------------------------------------------- /assets/fusepdf-denied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/assets/fusepdf-denied.png -------------------------------------------------------------------------------- /assets/fusepdf-document.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/assets/fusepdf-document.png -------------------------------------------------------------------------------- /assets/fusepdf-gofirst.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/assets/fusepdf-gofirst.png -------------------------------------------------------------------------------- /assets/fusepdf-open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/assets/fusepdf-open.png -------------------------------------------------------------------------------- /assets/fusepdf-quit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/assets/fusepdf-quit.png -------------------------------------------------------------------------------- /assets/fusepdf-save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/assets/fusepdf-save.png -------------------------------------------------------------------------------- /assets/fusepdf-screenshot-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/assets/fusepdf-screenshot-2.png -------------------------------------------------------------------------------- /assets/fusepdf-screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/assets/fusepdf-screenshot.png -------------------------------------------------------------------------------- /assets/fusepdf-valid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/assets/fusepdf-valid.png -------------------------------------------------------------------------------- /assets/fusepdf.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | Categories=Graphics;Office 4 | GenericName=FusePDF 5 | Name=FusePDF 6 | Icon=fusepdf 7 | Exec=fusepdf 8 | Comment=Merge PDF documents 9 | -------------------------------------------------------------------------------- /assets/fusepdf.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/assets/fusepdf.ico -------------------------------------------------------------------------------- /assets/fusepdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/assets/fusepdf.png -------------------------------------------------------------------------------- /assets/fusepdf.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | FusePDF 4 | 5 | 6 | 7 | 0 8 | 0 9 | 1053 10 | 690 11 | 12 | 13 | 14 | true 15 | 16 | 17 | FusePDF 18 | 19 | 20 | 21 | :/assets/fusepdf.png:/assets/fusepdf.png 22 | 23 | 24 | 25 | true 26 | 27 | 28 | 29 | 30 | 31 | 6 32 | 33 | 34 | 35 | 36 | QTabWidget::South 37 | 38 | 39 | 0 40 | 41 | 42 | 43 | 22 44 | 22 45 | 46 | 47 | 48 | 49 | 50 | :/assets/fusepdf-document.png:/assets/fusepdf-document.png 51 | 52 | 53 | Output 54 | 55 | 56 | 57 | 1 58 | 59 | 60 | 0 61 | 62 | 63 | 0 64 | 65 | 66 | 0 67 | 68 | 69 | 0 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | QFrame::NoFrame 78 | 79 | 80 | 0 81 | 82 | 83 | true 84 | 85 | 86 | true 87 | 88 | 89 | QAbstractItemView::InternalMove 90 | 91 | 92 | Qt::CopyAction 93 | 94 | 95 | true 96 | 97 | 98 | 99 | 32 100 | 32 101 | 102 | 103 | 104 | true 105 | 106 | 107 | false 108 | 109 | 110 | true 111 | 112 | 113 | true 114 | 115 | 116 | true 117 | 118 | 119 | 120 | Document 121 | 122 | 123 | 124 | 125 | Export pages 126 | 127 | 128 | 129 | 130 | Total pages 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 0 144 | 0 145 | 146 | 147 | 148 | 149 | 16777215 150 | 125 151 | 152 | 153 | 154 | QPlainTextEdit {background-color: black; color: white; } 155 | 156 | 157 | true 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 350 168 | 16777215 169 | 170 | 171 | 172 | 173 | 0 174 | 175 | 176 | 0 177 | 178 | 179 | 0 180 | 181 | 182 | 0 183 | 184 | 185 | 186 | 187 | Qt::NoFocus 188 | 189 | 190 | background: none; border: none;margin-bottom: 1em; 191 | 192 | 193 | 194 | 195 | 196 | 197 | :/assets/fusepdf.png:/assets/fusepdf.png 198 | 199 | 200 | 201 | 128 202 | 128 203 | 204 | 205 | 206 | true 207 | 208 | 209 | 210 | 211 | 212 | 213 | 0 214 | 215 | 216 | 217 | 218 | 0 219 | 0 220 | 350 221 | 193 222 | 223 | 224 | 225 | Preview 226 | 227 | 228 | 229 | 0 230 | 231 | 232 | 0 233 | 234 | 235 | 0 236 | 237 | 238 | 0 239 | 240 | 241 | 242 | 243 | 244 | 0 245 | 0 246 | 247 | 248 | 249 | 250 | 16777215 251 | 16777215 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 0 262 | 0 263 | 350 264 | 193 265 | 266 | 267 | 268 | Properties 269 | 270 | 271 | 272 | 0 273 | 274 | 275 | 0 276 | 277 | 278 | 0 279 | 280 | 281 | 0 282 | 283 | 284 | 285 | 286 | 287 | 288 | Title 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 0 297 | 0 298 | 299 | 300 | 301 | 302 | 170 303 | 0 304 | 305 | 306 | 307 | Optional 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | Subject 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 0 327 | 0 328 | 329 | 330 | 331 | 332 | 170 333 | 0 334 | 335 | 336 | 337 | Optional 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | Author 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 0 357 | 0 358 | 359 | 360 | 361 | 362 | 170 363 | 0 364 | 365 | 366 | 367 | Optional 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | Qt::Vertical 377 | 378 | 379 | 380 | 20 381 | 40 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 0 395 | 0 396 | 397 | 398 | 399 | Distiller 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 0 408 | 0 409 | 410 | 411 | 412 | 413 | 100 414 | 0 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 0 424 | 0 425 | 426 | 427 | 428 | 429 | 100 430 | 0 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 0 440 | 0 441 | 442 | 443 | 444 | Compatibility 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 0 455 | 0 456 | 457 | 458 | 459 | 100 460 | 461 | 462 | 0 463 | 464 | 465 | true 466 | 467 | 468 | Ready 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 0 483 | 0 484 | 1053 485 | 25 486 | 487 | 488 | 489 | 490 | File 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | Help 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | true 531 | 532 | 533 | Tool Bar 534 | 535 | 536 | false 537 | 538 | 539 | Qt::AllToolBarAreas 540 | 541 | 542 | Qt::Horizontal 543 | 544 | 545 | 546 | 24 547 | 24 548 | 549 | 550 | 551 | Qt::ToolButtonTextBesideIcon 552 | 553 | 554 | false 555 | 556 | 557 | TopToolBarArea 558 | 559 | 560 | false 561 | 562 | 563 | 564 | 565 | 566 | 567 | true 568 | 569 | 570 | 571 | 572 | 573 | :/assets/fusepdf-open.png:/assets/fusepdf-open.png 574 | 575 | 576 | Open 577 | 578 | 579 | Add PDF doucments you want to merge, you can select multiple documents. 580 | 581 | 582 | Ctrl+O 583 | 584 | 585 | 586 | 587 | 588 | :/assets/fusepdf-save.png:/assets/fusepdf-save.png 589 | 590 | 591 | Save 592 | 593 | 594 | Save to PDF 595 | 596 | 597 | Ctrl+S 598 | 599 | 600 | 601 | 602 | 603 | :/assets/fusepdf-quit.png:/assets/fusepdf-quit.png 604 | 605 | 606 | Quit 607 | 608 | 609 | Quit 610 | 611 | 612 | Ctrl+Q 613 | 614 | 615 | 616 | 617 | About 618 | 619 | 620 | 621 | 622 | About Qt 623 | 624 | 625 | 626 | 627 | true 628 | 629 | 630 | Show log 631 | 632 | 633 | Show Ghostscript output 634 | 635 | 636 | Ctrl+L 637 | 638 | 639 | 640 | 641 | true 642 | 643 | 644 | Automatic sorting 645 | 646 | 647 | Automatic sorting of items 648 | 649 | 650 | 651 | 652 | true 653 | 654 | 655 | Open after save 656 | 657 | 658 | Open PDF after save 659 | 660 | 661 | 662 | 663 | true 664 | 665 | 666 | Remember author 667 | 668 | 669 | Remember author 670 | 671 | 672 | 673 | 674 | true 675 | 676 | 677 | Remember subject 678 | 679 | 680 | Remember subject 681 | 682 | 683 | 684 | 685 | true 686 | 687 | 688 | Remember title 689 | 690 | 691 | Remember title 692 | 693 | 694 | 695 | 696 | Open cache folder 697 | 698 | 699 | 700 | 701 | true 702 | 703 | 704 | Show tooltips 705 | 706 | 707 | 708 | 709 | Check for updates 710 | 711 | 712 | 713 | 714 | Support 715 | 716 | 717 | Support 718 | 719 | 720 | 721 | 722 | Documentation 723 | 724 | 725 | 726 | 727 | true 728 | 729 | 730 | Output preview 731 | 732 | 733 | 734 | 735 | true 736 | 737 | 738 | Support dark mode 739 | 740 | 741 | 742 | 743 | Clear cache 744 | 745 | 746 | 747 | 748 | 749 | FilesTreeWidget 750 | QTreeWidget 751 |
fusepdf.h
752 |
753 |
754 | 755 | 756 | 757 | 758 |
759 | -------------------------------------------------------------------------------- /assets/hicolor/128x128/apps/fusepdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/assets/hicolor/128x128/apps/fusepdf.png -------------------------------------------------------------------------------- /assets/hicolor/192x192/apps/fusepdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/assets/hicolor/192x192/apps/fusepdf.png -------------------------------------------------------------------------------- /assets/hicolor/256x256/apps/fusepdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/assets/hicolor/256x256/apps/fusepdf.png -------------------------------------------------------------------------------- /assets/hicolor/32x32/apps/fusepdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/assets/hicolor/32x32/apps/fusepdf.png -------------------------------------------------------------------------------- /assets/hicolor/48x48/apps/fusepdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/assets/hicolor/48x48/apps/fusepdf.png -------------------------------------------------------------------------------- /assets/hicolor/64x64/apps/fusepdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/assets/hicolor/64x64/apps/fusepdf.png -------------------------------------------------------------------------------- /assets/hicolor/96x96/apps/fusepdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/assets/hicolor/96x96/apps/fusepdf.png -------------------------------------------------------------------------------- /assets/icc/srgb.icc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/assets/icc/srgb.icc -------------------------------------------------------------------------------- /assets/nettstudio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/assets/nettstudio.png -------------------------------------------------------------------------------- /assets/ps/PDFA_def.ps: -------------------------------------------------------------------------------- 1 | %! 2 | % PDF/A document. 3 | 4 | % Define entries in the document Info dictionary : 5 | [ /Title (Title) 6 | /DOCINFO pdfmark 7 | 8 | % Define an ICC profile : 9 | /ICCProfile (srgb.icc) 10 | def 11 | 12 | [/_objdef {icc_PDFA} /type /stream /OBJ pdfmark 13 | 14 | %% This code attempts to set the /N (number of components) key for the ICC colour space. 15 | %% To do this it checks the ColorConversionStrategy or the device ProcessColorModel if 16 | %% ColorConversionStrategy is not set. 17 | %% This is not 100% reliable. A better solution is for the user to edit this and replace 18 | %% the code between the ---8<--- lines with a simple declaration like: 19 | %% /N 3 20 | %% where the value of N is the number of components from the profile defined in /ICCProfile above. 21 | %% 22 | [{icc_PDFA} 23 | << 24 | %% ----------8<--------------8<-------------8<--------------8<---------- 25 | systemdict /ColorConversionStrategy known { 26 | systemdict /ColorConversionStrategy get cvn dup /Gray eq { 27 | pop /N 1 false 28 | }{ 29 | dup /RGB eq { 30 | pop /N 3 false 31 | }{ 32 | /CMYK eq { 33 | /N 4 false 34 | }{ 35 | (\tColorConversionStrategy not a device space, falling back to ProcessColorModel, output may not be valid PDF/A.\n)= 36 | true 37 | } ifelse 38 | } ifelse 39 | } ifelse 40 | } { 41 | (\tColorConversionStrategy not set, falling back to ProcessColorModel, output may not be valid PDF/A.\n)= 42 | true 43 | } ifelse 44 | 45 | { 46 | currentpagedevice /ProcessColorModel get 47 | dup /DeviceGray eq { 48 | pop /N 1 49 | }{ 50 | dup /DeviceRGB eq { 51 | pop /N 3 52 | }{ 53 | dup /DeviceCMYK eq { 54 | pop /N 4 55 | } { 56 | (\tProcessColorModel not a device space.)= 57 | /ProcessColorModel cvx /rangecheck signalerror 58 | } ifelse 59 | } ifelse 60 | } ifelse 61 | } if 62 | %% ----------8<--------------8<-------------8<--------------8<---------- 63 | 64 | >> /PUT pdfmark 65 | [ 66 | {icc_PDFA} 67 | {ICCProfile (r) file} stopped 68 | { 69 | (\n\tFailed to open the supplied ICCProfile for reading. This may be due to\n) print 70 | (\t an incorrect filename or a failure to add --permif-file-read=\n) print 71 | (\t to the command line. This PostScript program needs to open the file\n) print 72 | (\t and you must explicitly grant it permission to do so.\n\n) print 73 | (\tPDF/A processing aborted, output may not be a PDF/A file.\n\n) print 74 | cleartomark 75 | } 76 | { 77 | /PUT pdfmark 78 | % Define the output intent dictionary : 79 | 80 | [/_objdef {OutputIntent_PDFA} /type /dict /OBJ pdfmark 81 | [{OutputIntent_PDFA} << 82 | /Type /OutputIntent % Must be so (the standard requires). 83 | /S /GTS_PDFA1 % Must be so (the standard requires). 84 | /DestOutputProfile {icc_PDFA} % Must be so (see above). 85 | /OutputConditionIdentifier (sRGB) % Customize 86 | >> /PUT pdfmark 87 | [{Catalog} <> /PUT pdfmark 88 | } ifelse 89 | -------------------------------------------------------------------------------- /docs/CNAME: -------------------------------------------------------------------------------- 1 | www.fusepdf.no -------------------------------------------------------------------------------- /docs/README.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/docs/README.pdf -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-tactile 2 | show_downloads: true 3 | title: FusePDF 4 | github: 5 | zip_url: https://github.com/nettstudio/fusepdf/releases/latest 6 | -------------------------------------------------------------------------------- /docs/_layouts/default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | {% seo %} 14 | 15 | 16 | 17 | 18 | 19 |
20 |
21 | 22 |
23 |

{{ site.title | default: site.github.repository_name }}

24 |

{{ site.description | default: site.github.project_tagline }}

25 |
26 |
27 | Download 28 | View on GitHub 29 |
30 |
31 |
32 | {{ content }} 33 |
34 | 35 |
36 | {% if site.github.is_project_page %} 37 | {{ site.title | default: site.github.repository_name }} is maintained by {{ site.github.owner_name }}
38 | {% endif %} 39 | This page was generated by GitHub Pages. 40 |
41 | 42 |
43 |
44 | 45 | {% if site.google_analytics %} 46 | 54 | {% endif %} 55 | 56 | 57 | -------------------------------------------------------------------------------- /docs/fusepdf-screenshot-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/docs/fusepdf-screenshot-01.png -------------------------------------------------------------------------------- /docs/fusepdf-screenshot-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/docs/fusepdf-screenshot-02.png -------------------------------------------------------------------------------- /docs/fusepdf-screenshot-03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/docs/fusepdf-screenshot-03.png -------------------------------------------------------------------------------- /docs/fusepdf-screenshot-04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/docs/fusepdf-screenshot-04.png -------------------------------------------------------------------------------- /docs/fusepdf-screenshot-05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/docs/fusepdf-screenshot-05.png -------------------------------------------------------------------------------- /docs/fusepdf-screenshot-06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/docs/fusepdf-screenshot-06.png -------------------------------------------------------------------------------- /docs/fusepdf-screenshot-07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/docs/fusepdf-screenshot-07.png -------------------------------------------------------------------------------- /docs/fusepdf-screenshot-08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/docs/fusepdf-screenshot-08.png -------------------------------------------------------------------------------- /docs/fusepdf-screenshot-09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/docs/fusepdf-screenshot-09.png -------------------------------------------------------------------------------- /docs/fusepdf-screenshot-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/docs/fusepdf-screenshot-10.png -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | # FusePDF 2 | 3 | FusePDF is an simple cross-platform and open source application used for converting, merging and splitting PDF documents. 4 | 5 | ![Screenshot of main interface](https://github.com/nettstudio/fusepdf/raw/main/docs/fusepdf-screenshot-01.png "Screenshot of main interface") 6 | 7 | * Drag-and-drop any PDF document 8 | * Preview input and output pages 9 | * Exclude/Include pages 10 | * Export to images (TIFF/PNG) 11 | * Modify meta data (properties) 12 | * Supports common distiller presets 13 | 14 | ## Supported PDF versions 15 | 16 | FusePDF supports the most common Portable Document Format (PDF) versions and standards. 17 | 18 | * PDF 1.0 (Acrobat 1.0) 19 | * PDF 1.1 (Acrobat 2.0) 20 | * PDF 1.2 (Acrobat 3.0) 21 | * PDF 1.3 (Acrobat 4.0) 22 | * PDF 1.4 (Acrobat 5.0) 23 | * PDF 1.5 (Acrobat 6.0) 24 | * PDF 1.6 (Acrobat 7.0) 25 | * PDF 1.7 (Acrobat 8.0 / ISO 32000-1) 26 | * PDF 2.0 (ISO 32000-2) 27 | 28 | PDF/A is an ISO-standardized version of the Portable Document Format (PDF) specialized for use in the archiving and long-term preservation of electronic documents. 29 | 30 | * PDF/A-1 (ISO 19005-1) 31 | * PDF/A-2 (ISO 19005-2) 32 | * PDF/A-3 (ISO 19005-3) 33 | 34 | # Basic usage 35 | 36 | For the most basic usage we assume you have a couple of PDF documents you want to merge into one. 37 | 38 | You can add PDF documents in various ways, either by drag-and-drop or with the ``Open`` action in the toolbar, right-click and ``Add`` or in the ``File`` menu (``Ctrl+O``). You can select multiple documents with the open dialog, and of course drag-and-drop multiple documents. 39 | 40 | ![Screenshot of main interface with document added](https://github.com/nettstudio/fusepdf/raw/main/docs/fusepdf-screenshot-02.png "Screenshot of main interface with document added") 41 | 42 | You can move documents up and down, and remove with the ``DEL`` key or right-click ``Remove``. 43 | 44 | That's it, if you are satisfied click ``Save`` (or ``Ctrl+S``) and you are done. As default the generated PDF will open in your default PDF viewer. 45 | 46 | # Excluding pages 47 | 48 | Sometimes you may want to exclude some pages from a document. 49 | 50 | Double-click the document or select the tab with the document you want to modify. 51 | 52 | ![Screenshot of document interface](https://github.com/nettstudio/fusepdf/raw/main/docs/fusepdf-screenshot-03.png "Screenshot of document interface") 53 | 54 | Enabled pages are marked as green. If you want to exclude a page just double-click it. You can also select all or none through the context menu (right-click). 55 | 56 | # Issues 57 | 58 | Some common issues users may experience. 59 | 60 | ## Missing Ghostscript 61 | 62 | ![Screenshot of missing Ghostscript](https://github.com/nettstudio/fusepdf/raw/main/docs/fusepdf-screenshot-08.png "Screenshot of missing Ghostscript") 63 | 64 | If you see this dialog your installation is broken, or you are using a version of FusePDF shipped without Ghostscript. On Windows follow the instructions or download a FusePDF version with Ghostscript included. On macOS/Linux/BSD and others make sure Ghostscript (``gs``) is installed and available in path, check your package manager for more information. 65 | 66 | For macOS [Richard Koch](https://pages.uoregon.edu/koch/) hosts Ghostscript binaries that will work with FusePDF. Else use [macports](https://ports.macports.org/port/ghostscript/) or [homebrew](https://formulae.brew.sh/formula/ghostscript) to install Ghostscript. 67 | 68 | # ChangeLog 69 | 70 | ## 2.3.0 71 | 72 | N/A 73 | 74 | ## 2.2.0 75 | 76 | Released : Apr 8, 2022. 77 | 78 | * Clear cache option 79 | * Preview update bug fix 80 | * Updated UI 81 | * Set document properties as tooltip (Windows) 82 | * Can now save to PDF 2.0 (ISO 32000-2) 83 | * Can now save to PDF/A 84 | * PDF/A-1 (ISO 19005-1) 85 | * PDF/A-2 (ISO 19005-2) 86 | * PDF/A-3 (ISO 19005-3) 87 | 88 | ## 2.1.0 89 | 90 | Released : Apr 1, 2022. 91 | 92 | * Check total pages before export (bug fix) 93 | * Context menu in output 94 | * Real time output preview (default on, can be disabled) 95 | * UI changes 96 | * Code changes 97 | * Support dark mode on Windows (can be disabled) 98 | * Added support for translations (i18n) 99 | * Added basic documentation (not complete) 100 | * Export image bug fix (check format compatibility before export) 101 | * Windows release updated to Ghostscript 9.55 102 | * Windows release updated to Qt 5.12.12 103 | * Windows release now uses MSVC 2019 104 | 105 | ## 2.0.0 106 | 107 | Released : Jun 2, 2021. 108 | 109 | * Improved UI/UX 110 | * Preview pages 111 | * Include/Exclude pages 112 | * Bug fixes 113 | * More options 114 | * Improved macOS support 115 | * Export page(s) to image(s) 116 | 117 | ## 1.2.0 118 | 119 | Released : Apr 13, 2021. 120 | 121 | * Improved Linux support 122 | * Change license to GPLv3 123 | * Improved UI 124 | 125 | ## 1.1.0 126 | 127 | Released : Jan 26, 2021. 128 | 129 | * Support for meta/properties data 130 | * More options 131 | * Improved UX 132 | 133 | ## 1.0.0 134 | 135 | Released : Jan 24, 2021. 136 | 137 | * Initial release 138 | 139 | # Open Source 140 | 141 | FusePDF targets Windows as it's primary platform, but since it's open source it can be built and run on most platforms available today. We check compatibility with macOS and Linux and rely on community feedback for more exotic platform. If Qt5 and Ghostscript works on your platform, FusePDF will too. 142 | 143 | ## Introduction 144 | 145 | FusePDF requires Qt5 (Core/Gui/Widgets/Concurrent) to build, and Ghostscript (``gs``) available during runtime. 146 | 147 | ## Dependencies 148 | 149 | Instructions for installing the needed dependencies on various platforms. 150 | 151 | ### Debian/Ubuntu (and compatible) 152 | 153 | ``sudo apt install ghostscript qt5-default qtbase5-dev qttools5-dev-tools`` 154 | 155 | ### Fedora/CentOS/RHEL (and compatible) 156 | 157 | ``sudo yum install ghostscript qt5-qtbase-devel qt5-qttools`` 158 | 159 | ### macports 160 | 161 | ``sudo port install ghostscript qt5-qtbase qt5-qttools`` 162 | 163 | ### FreeBSD 164 | 165 | ``sudo pkg install ghostscript9-agpl-base qt5`` 166 | 167 | ## Download 168 | 169 | Download the latest (``main``) source code from GitHub: 170 | 171 | ``` 172 | git clone https://github.com/nettstudio/fusepdf 173 | cd fusepdf 174 | git submodule update -i 175 | ``` 176 | 177 | Or download the latest stable tarball [release](https://github.com/nettstudio/fusepdf/releases/latest). 178 | 179 | ## Building 180 | 181 | In the FusePDF source folder run the following commands: 182 | 183 | ``` 184 | mkdir build && cd build 185 | qmake CONFIG+=release PREFIX=/usr .. && make 186 | ``` 187 | 188 | ## Package 189 | 190 | If you want to package the build (highly recommended) run the following command (remember to replace the output folder): 191 | 192 | ``` 193 | make INSTALL_ROOT= install 194 | ``` 195 | 196 | # License 197 | 198 | ## FusePDF 199 | 200 | Developed by Ole-André Rodlie for NettStudio AS. 201 | 202 | Copyright © 2021, 2022 [NettStudio AS](https://nettstudio.no). All rights reserved. 203 | 204 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. 205 | 206 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 207 | 208 | You should have received a copy of the GNU General Public License along with this program. If not, see . 209 | 210 | Translations (i18n) are Creative Commons Zero v1.0 Universal. 211 | 212 | The Creative Commons CC0 Public Domain Dedication waives copyright interest in a work you've created and dedicates it to the world-wide public domain. Use CC0 to opt out of copyright entirely and ensure your work has the widest reach. As with the Unlicense and typical software licenses, CC0 disclaims warranties. CC0 is very similar to the Unlicense. 213 | 214 | ## Qt 215 | 216 | Source code: 217 | 218 | * [qtbase](https://mirrors.dotsrc.org/qtproject/archive/qt/5.12/5.12.12/submodules/qtbase-everywhere-src-5.12.12.zip) 5.12.12 219 | * [qttools](https://mirrors.dotsrc.org/qtproject/archive/qt/5.12/5.12.12/submodules/qttools-everywhere-src-5.12.12.zip) 5.12.12 220 | 221 | Copyright © 2020 The Qt Company Ltd and other contributors. 222 | 223 | Qt and the Qt logo are trademarks of The Qt Company Ltd. 224 | 225 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. 226 | 227 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 228 | 229 | You should have received a copy of the GNU General Public License along with this program. If not, see . 230 | 231 | ## GPL Ghostscript 232 | 233 | Source code: 234 | 235 | * [Ghostscript](https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs9550/ghostscript-9.55.0.tar.xz) 9.55 236 | 237 | Copyright © 2000-2021 Artifex Software, Inc. All rights reserved. 238 | 239 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 240 | 241 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. 242 | 243 | You should have received a copy of the GNU Affero General Public License along with this program. If not, see . 244 | 245 | -------------------------------------------------------------------------------- /docs/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nettstudio/fusepdf/c89cec7008c87c4daad2c0de1d49b116a083c2f9/docs/logo.png -------------------------------------------------------------------------------- /fusepdf.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM ### BUILD FUSEPDF WINDOWS X64 RELEASE 4 | REM ### COPYRIGHT 2022 NETTSTUDIO AS 5 | 6 | call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 %* 7 | 8 | set CWD=%cd% 9 | set TOOLS=%CWD%\tools 10 | set FUSEPDF=2.3.0 11 | set QT_MAJOR=5 12 | set QT_MINOR=12 13 | set QT_PATCH=12 14 | set QT_VERSION=%QT_MAJOR%.%QT_MINOR%.%QT_PATCH% 15 | set QT_DIR=%TOOLS%\qt 16 | set GS=9550 17 | 18 | set PATH=%QT_DIR%\bin;%ProgramFiles%\7-Zip;%PATH% 19 | 20 | set GS_EXE=gs%GS%w64.exe 21 | set GS_URL=https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs%GS%/%GS_EXE% 22 | 23 | set QTBASE=qtbase-everywhere-src-%QT_VERSION% 24 | set QTTOOLS=qttools-everywhere-src-%QT_VERSION% 25 | set QT_URL=https://mirrors.dotsrc.org/qtproject/archive/qt/%QT_MAJOR%.%QT_MINOR%/%QT_VERSION%/submodules 26 | set QTBASE_URL=%QT_URL%/%QTBASE%.zip 27 | set QTTOOLS_URL=%QT_URL%/%QTTOOLS%.zip 28 | 29 | @RD /S /Q build 30 | mkdir build 31 | 32 | if not exist "%QT_DIR%\bin\qmake.exe" ( 33 | if not exist "%TOOLS%\%QTBASE%.zip" ( 34 | curl --url %QTBASE_URL% -o "%TOOLS%\%QTBASE%.zip" 35 | ) 36 | cd "%CWD%\build" 37 | 7z x "%TOOLS%\%QTBASE%.zip" 38 | cd "%QTBASE%" 39 | configure.bat -static -release -prefix "%QT_DIR%" -platform win32-msvc2019 -opensource -confirm-license -nomake examples -nomake tests -static-runtime -opengl desktop -optimize-size -no-pch -no-glib -no-dbus -no-sse4.2 -no-avx -no-avx2 -no-avx512 -strip -no-openssl -no-gif -no-ico 40 | nmake 41 | nmake install 42 | ) 43 | 44 | if not exist "%QT_DIR%\bin\lrelease.exe" ( 45 | if not exist "%TOOLS%\%QTTOOLS%.zip" ( 46 | curl --url %QTTOOLS_URL% -o "%TOOLS%\%QTTOOLS%.zip" 47 | ) 48 | cd "%CWD%\build" 49 | 7z x "%TOOLS%\%QTTOOLS%.zip" 50 | cd "%QTTOOLS%" 51 | qmake.exe 52 | nmake 53 | nmake install 54 | ) 55 | 56 | cd "%CWD%\build" 57 | qmake.exe CONFIG+=release .. 58 | nmake 59 | 60 | mkdir FusePDF-%FUSEPDF%-x64 61 | COPY release\FusePDF.exe FusePDF-%FUSEPDF%-x64\ 62 | COPY %CWD%\docs\README.pdf FusePDF-%FUSEPDF%-x64\ 63 | 64 | REM if not exist "%TOOLS%\%GS_EXE%" ( 65 | REM curl --url %GS_URL% -o "%TOOLS%\%GS_EXE%" 66 | REM ) 67 | 68 | if exist "%TOOLS%\gs.zip" ( 69 | cd "%CWD%\build" 70 | 7z x "%TOOLS%\gs.zip" 71 | MOVE gs FusePDF-%FUSEPDF%-x64\ 72 | ) 73 | 74 | cd "%CWD%\build" 75 | 7z a -mx9 FusePDF-%FUSEPDF%-x64.zip FusePDF-%FUSEPDF%-x64 76 | -------------------------------------------------------------------------------- /fusepdf.pro: -------------------------------------------------------------------------------- 1 | # 2 | # FusePDF - https://fusepdf.no 3 | # 4 | # Copyright (c) 2021, 2022 NettStudio AS . 5 | # All rights reserved. 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program. If not, see 19 | # 20 | 21 | unix:!mac { 22 | TARGET = fusepdf 23 | } else { 24 | TARGET = FusePDF 25 | } 26 | VERSION = 2.3.0 27 | TEMPLATE = app 28 | 29 | QT += core gui widgets concurrent 30 | CONFIG += c++11 31 | 32 | CONFIG(release, debug|release): DEFINES += QT_NO_DEBUG_OUTPUT QT_NO_WARNING_OUTPUT 33 | isEmpty(PREFIX): PREFIX = /usr/local 34 | 35 | CONFIG(FORCE_NORWEGIAN): DEFINES += FORCE_NORWEGIAN 36 | 37 | DEFINES += VERSION_APP=\\\"$${VERSION}\\\" 38 | 39 | QMAKE_TARGET_COMPANY = "NettStudio AS" 40 | QMAKE_TARGET_PRODUCT = "FusePDF" 41 | QMAKE_TARGET_DESCRIPTION = "Convert/Merge/Split PDF documents" 42 | QMAKE_TARGET_COPYRIGHT = "NettStudio AS" 43 | 44 | # convert -background transparent fusepdf.png -define icon:auto-resize=16,32,48,64,128,192,256 fusepdf.ico 45 | win32: RC_ICONS += assets/fusepdf.ico 46 | 47 | INCLUDEPATH += src 48 | SOURCES += src/main.cpp src/fusepdf.cpp 49 | HEADERS += src/fusepdf.h 50 | FORMS += assets/fusepdf.ui 51 | RESOURCES += fusepdf.qrc 52 | INSTALLS += target docs desktop hicolor 53 | 54 | desktop.path = $${PREFIX}/share/applications 55 | desktop.files = assets/fusepdf.desktop 56 | hicolor.path = $${PREFIX}/share/icons 57 | hicolor.files = assets/hicolor 58 | docs.path = $${PREFIX}/share/doc/$${TARGET}-$${VERSION} 59 | docs.files = docs/README.pdf 60 | target.path = $${PREFIX}/bin 61 | 62 | exists(i18n/fusepdf.pri): include(i18n/fusepdf.pri) 63 | -------------------------------------------------------------------------------- /fusepdf.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | assets/fusepdf.png 4 | assets/fusepdf-clear.png 5 | assets/fusepdf-open.png 6 | assets/fusepdf-quit.png 7 | assets/fusepdf-save.png 8 | assets/fusepdf-document.png 9 | assets/document.png 10 | assets/nettstudio.png 11 | assets/fusepdf-denied.png 12 | assets/fusepdf-valid.png 13 | assets/fusepdf-gofirst.png 14 | assets/icc/srgb.icc 15 | assets/ps/PDFA_def.ps 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/fusepdf.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # 3 | # FusePDF - https://fusepdf.no 4 | # 5 | # Copyright (c) 2021, 2022 NettStudio AS . 6 | # All rights reserved. 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 3 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see 20 | # 21 | */ 22 | 23 | #include "fusepdf.h" 24 | #include "ui_fusepdf.h" 25 | 26 | ExportImageDialog::ExportImageDialog(QWidget *parent, 27 | Qt::WindowFlags f, 28 | QString suffix): 29 | QDialog(parent, f) 30 | , _type(nullptr) 31 | , _res(nullptr) 32 | { 33 | setWindowTitle(tr("Export image")); 34 | 35 | QVBoxLayout *layout = new QVBoxLayout(this); 36 | 37 | QWidget *formatWidget = new QWidget(this); 38 | QHBoxLayout *formatLayout = new QHBoxLayout(formatWidget); 39 | 40 | QLabel *formatLabel = new QLabel(this); 41 | formatLabel->setText(tr("Format")); 42 | formatLayout->addWidget(formatLabel); 43 | 44 | _type = new QComboBox(this); 45 | _res = new QComboBox(this); 46 | 47 | _res->addItem(tr("72 dpi"), 72); 48 | _res->addItem(tr("96 dpi"), 96); 49 | _res->addItem(tr("120 dpi"), 120); 50 | _res->addItem(tr("300 dpi"), 300); 51 | _res->addItem(tr("600 dpi"), 600); 52 | _res->addItem(tr("1200 dpi"), 1200); 53 | _res->setCurrentIndex(3); 54 | 55 | if (suffix.toLower() == "png") { 56 | _type->addItem(tr("PNG 16"), exportPNGType16); 57 | _type->addItem(tr("PNG Gray"), exportPNGTypeGray); 58 | } else if (suffix.toLower() == "tif" || suffix.toLower() == "tiff") { 59 | _type->addItem(tr("TIFF RGB 24-bit"), exportTiffTypeRGB24); 60 | _type->addItem(tr("TIFF RGB 12-bit"), exportTiffTypeRGB12); 61 | _type->addItem(tr("TIFF RGB 48-bit"), exportTiffTypeRGB48); 62 | _type->addItem(tr("TIFF CMYK 32-bit"), exportTiffTypeCMYK32); 63 | _type->addItem(tr("TIFF CMYK 64-bit"), exportTiffTypeCMYK64); 64 | _type->addItem(tr("TIFF Gray"), exportTiffTypeGray); 65 | } else { 66 | _type->addItem(tr("PNG 16"), exportPNGType16); 67 | _type->addItem(tr("PNG Gray"), exportPNGTypeGray); 68 | _type->addItem(tr("TIFF RGB 24-bit"), exportTiffTypeRGB24); 69 | _type->addItem(tr("TIFF RGB 12-bit"), exportTiffTypeRGB12); 70 | _type->addItem(tr("TIFF RGB 48-bit"), exportTiffTypeRGB48); 71 | _type->addItem(tr("TIFF CMYK 32-bit"), exportTiffTypeCMYK32); 72 | _type->addItem(tr("TIFF CMYK 64-bit"), exportTiffTypeCMYK64); 73 | _type->addItem(tr("TIFF Gray"), exportTiffTypeGray); 74 | } 75 | 76 | QLabel *resLabel = new QLabel(this); 77 | resLabel->setText(tr("Resolution")); 78 | 79 | formatLayout->addWidget(_type); 80 | formatLayout->addWidget(resLabel); 81 | formatLayout->addWidget(_res); 82 | 83 | QWidget *buttonWidget = new QWidget(this); 84 | QHBoxLayout *buttonLayout = new QHBoxLayout(buttonWidget); 85 | 86 | QPushButton *buttonCancel = new QPushButton(this); 87 | QPushButton *buttonOk = new QPushButton(this); 88 | 89 | connect(buttonCancel, SIGNAL(clicked()), 90 | this, SLOT(handleButtonCancel())); 91 | connect(buttonOk, SIGNAL(clicked()), 92 | this, SLOT(handleButtonOk())); 93 | 94 | buttonCancel->setText(tr("Cancel")); 95 | buttonOk->setText(tr("Export")); 96 | 97 | buttonLayout->addStretch(); 98 | buttonLayout->addWidget(buttonCancel); 99 | buttonLayout->addWidget(buttonOk); 100 | 101 | layout->addWidget(formatWidget); 102 | layout->addWidget(buttonWidget); 103 | 104 | QTimer::singleShot(100, buttonOk, SLOT(setFocus())); 105 | } 106 | 107 | int ExportImageDialog::getImageType() 108 | { 109 | return _type->currentData().toInt(); 110 | } 111 | 112 | int ExportImageDialog::getImageRes() 113 | { 114 | return _res->currentData().toInt(); 115 | } 116 | 117 | void ExportImageDialog::handleButtonCancel() 118 | { 119 | QDialog::reject(); 120 | } 121 | 122 | void ExportImageDialog::handleButtonOk() 123 | { 124 | QDialog::accept(); 125 | } 126 | 127 | PagesListWidget::PagesListWidget(QWidget *parent, 128 | const QString &filename, 129 | const QString &checksum, 130 | int pages): 131 | QListWidget(parent) 132 | , _filename(filename) 133 | , _checksum(checksum) 134 | , _pages(pages) 135 | { 136 | setViewMode(QListView::IconMode); 137 | setIconSize(QSize(FUSEPDF_PAGE_ICON_SIZE, FUSEPDF_PAGE_ICON_SIZE)); 138 | setUniformItemSizes(true); 139 | setWrapping(true); 140 | setResizeMode(QListView::Adjust); 141 | setFrameShape(QFrame::NoFrame); 142 | setContextMenuPolicy(Qt::CustomContextMenu); 143 | setItemDelegate(new PageDelegate(this)); 144 | setSpacing(10); 145 | 146 | for (int i = 1; i <= _pages; ++i) { 147 | QListWidgetItem *item = new QListWidgetItem(QIcon(FUSEPDF_ICON_LOGO), 148 | QString(), 149 | this); 150 | item->setData(FUSEPDF_PAGE_ROLE, i); 151 | item->setData(FUSEPDF_CHECKED_ROLE, true); 152 | item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); 153 | } 154 | 155 | connect(this, SIGNAL(itemDoubleClicked(QListWidgetItem*)), 156 | this, SLOT(handleItemClicked(QListWidgetItem*))); 157 | connect(this, SIGNAL(customContextMenuRequested(QPoint)), 158 | this, SLOT(handleContextMenu(QPoint))); 159 | } 160 | 161 | bool PagesListWidget::isModified() { 162 | for (int i = 0; i < count(); ++i) { 163 | QListWidgetItem *item = this->item(i); 164 | if (!item) { continue; } 165 | if (!item->data(FUSEPDF_CHECKED_ROLE).toBool()) { return true; } 166 | } 167 | return false; 168 | } 169 | 170 | QVector PagesListWidget::getPagesState(bool state) 171 | { 172 | QVector result; 173 | for (int i = 0; i < count(); ++i) { 174 | QListWidgetItem *item = this->item(i); 175 | if (!item) { continue; } 176 | if (item->data(FUSEPDF_CHECKED_ROLE).toBool() == state) { 177 | result.append(item->data(FUSEPDF_PAGE_ROLE).toInt()); 178 | } 179 | } 180 | return result; 181 | } 182 | 183 | void PagesListWidget::setPageIcon(const QString &filename, 184 | const QString &checksum, 185 | const QString &image, 186 | int page) 187 | { 188 | Q_UNUSED(checksum) 189 | if (filename != _filename || page > _pages || page < 1) { return; } 190 | for (int i = 0; i < count(); ++i) { 191 | QListWidgetItem *item = this->item(i); 192 | if (!item) { continue; } 193 | if (item->data(FUSEPDF_PAGE_ROLE).toInt() != page) { continue; } 194 | QPixmap pix(FUSEPDF_PAGE_ICON_SIZE, FUSEPDF_PAGE_ICON_SIZE); 195 | pix.fill(QColor(Qt::transparent)); 196 | QPainter p(&pix); 197 | QPixmap ppix = QPixmap::fromImage(QImage(image)).scaledToHeight(FUSEPDF_PAGE_ICON_SIZE, 198 | Qt::SmoothTransformation); 199 | ppix = ppix.copy(0, 0, FUSEPDF_PAGE_ICON_SIZE, FUSEPDF_PAGE_ICON_SIZE); 200 | QPainter pp(&ppix); 201 | QPainterPath ppath; 202 | ppath.addRect(0, 0, ppix.width(), ppix.height()); 203 | QPen ppen(Qt::black, 2); 204 | pp.setPen(ppen); 205 | pp.drawPath(ppath); 206 | p.drawPixmap((pix.width()/2)-(ppix.width()/2), 0, ppix); 207 | item->setIcon(pix); 208 | break; 209 | } 210 | } 211 | 212 | void PagesListWidget::handleItemClicked(QListWidgetItem *item) 213 | { 214 | if (!item) { return; } 215 | if (item->data(FUSEPDF_CHECKED_ROLE).toBool()) { 216 | item->setData(FUSEPDF_CHECKED_ROLE, false); 217 | } else { 218 | item->setData(FUSEPDF_CHECKED_ROLE, true); 219 | } 220 | emit changed(); 221 | } 222 | 223 | void PagesListWidget::handleContextMenu(QPoint pos) 224 | { 225 | QMenu menu; 226 | QAction selectAllAction; 227 | QAction selectNoneAction; 228 | selectAllAction.setText(tr("Select all")); 229 | selectNoneAction.setText(tr("Select none")); 230 | connect(&selectAllAction, SIGNAL(triggered(bool)), 231 | this, SLOT(selectAllPages())); 232 | connect(&selectNoneAction, SIGNAL(triggered(bool)), 233 | this, SLOT(selectNoPages())); 234 | 235 | menu.addAction(&selectAllAction); 236 | menu.addAction(&selectNoneAction); 237 | 238 | menu.addSeparator(); 239 | QAction exportAction; 240 | exportAction.setText(tr("Export current page to image")); 241 | QAction exportSelectedAction; 242 | exportSelectedAction.setText(tr("Export selected pages to images")); 243 | 244 | connect(&exportAction, SIGNAL(triggered(bool)), 245 | this, SLOT(exportSelectedPage())); 246 | connect(&exportSelectedAction, SIGNAL(triggered(bool)), 247 | this, SLOT(exportSelectedPages())); 248 | 249 | menu.addAction(&exportAction); 250 | menu.addAction(&exportSelectedAction); 251 | 252 | menu.exec(viewport()->mapToGlobal(pos)); 253 | } 254 | 255 | void PagesListWidget::selectAllPages() 256 | { 257 | setCheckedState(true); 258 | } 259 | 260 | void PagesListWidget::selectNoPages() 261 | { 262 | setCheckedState(false); 263 | } 264 | 265 | void PagesListWidget::setCheckedState(bool state) 266 | { 267 | for (int i = 0; i < count(); ++i) { 268 | QListWidgetItem *item = this->item(i); 269 | if (!item) { continue; } 270 | item->setData(FUSEPDF_CHECKED_ROLE, state); 271 | } 272 | emit changed(); 273 | } 274 | 275 | void PagesListWidget::exportSelectedPage() 276 | { 277 | QListWidgetItem *item = currentItem(); 278 | if (!item) { return; } 279 | QString filename = _filename; 280 | int page = item->data(FUSEPDF_PAGE_ROLE).toInt(); 281 | emit requestExportPage(filename, page); 282 | } 283 | 284 | void PagesListWidget::exportSelectedPages() 285 | { 286 | emit requestExportPages(_filename, 287 | getPagesState(true)); 288 | } 289 | 290 | FilesTreeWidget::FilesTreeWidget(QWidget *parent): 291 | QTreeWidget(parent) 292 | { 293 | setSortingEnabled(false); 294 | setAcceptDrops(true); 295 | viewport()->setAcceptDrops(true); 296 | setDragEnabled(true); 297 | setDragDropMode(QAbstractItemView::InternalMove); 298 | setDropIndicatorShown(false); 299 | setIconSize(QSize(32, 32)); 300 | 301 | setContextMenuPolicy(Qt::CustomContextMenu); 302 | connect(this, SIGNAL(customContextMenuRequested(QPoint)), 303 | this, SLOT(handleContextMenu(QPoint))); 304 | } 305 | 306 | void FilesTreeWidget::handleContextMenu(QPoint pos) 307 | { 308 | QMenu menu; 309 | 310 | QAction removeSelectedAction; 311 | QAction clearAllAction; 312 | QAction addAction; 313 | 314 | removeSelectedAction.setText(tr("Remove")); 315 | clearAllAction.setText(tr("Clear")); 316 | addAction.setText(tr("Add")); 317 | 318 | connect(&removeSelectedAction, SIGNAL(triggered(bool)), 319 | this, SLOT(handleRemoveSelectedAction())); 320 | connect(&clearAllAction, SIGNAL(triggered(bool)), 321 | this, SLOT(handleClearAllAction())); 322 | connect(&addAction, SIGNAL(triggered(bool)), 323 | this, SLOT(handleAddAction())); 324 | 325 | menu.addAction(&addAction); 326 | if (selectedItems().size() > 0) { menu.addAction(&removeSelectedAction); } 327 | if (topLevelItemCount() > 0) { menu.addAction(&clearAllAction); } 328 | 329 | menu.exec(viewport()->mapToGlobal(pos)); 330 | } 331 | 332 | void FilesTreeWidget::handleRemoveSelectedAction() 333 | { 334 | emit removeSelected(); 335 | } 336 | 337 | void FilesTreeWidget::handleClearAllAction() 338 | { 339 | emit clearAll(); 340 | } 341 | 342 | void FilesTreeWidget::handleAddAction() 343 | { 344 | emit add(); 345 | } 346 | 347 | void FilesTreeWidget::delayedChanged() 348 | { 349 | emit changed(); 350 | } 351 | 352 | void FilesTreeWidget::dropEvent(QDropEvent *e) 353 | { 354 | QTimer::singleShot(10, this, SLOT(delayedChanged())); 355 | if (e->mimeData()->hasUrls()) { emit foundPDF(e->mimeData()->urls()); } 356 | else { QTreeWidget::dropEvent(e); } 357 | } 358 | 359 | FusePDF::FusePDF(QWidget *parent) 360 | : QMainWindow(parent) 361 | , ui(new Ui::FusePDF) 362 | , _proc(nullptr) 363 | , _tabButton(nullptr) 364 | { 365 | ui->setupUi(this); 366 | setWindowIcon(QIcon(FUSEPDF_ICON_LOGO)); 367 | 368 | ui->toolBox->setCurrentIndex(FUSEPDF_TOOLBOX_OUTPUT); 369 | 370 | qRegisterMetaType("FusePDF::pdfInfo"); 371 | 372 | QFont font = this->font(); 373 | if (font.pointSize() < 9) { 374 | font.setPointSize(9); 375 | setFont(font); 376 | } 377 | 378 | #if defined(Q_OS_WIN) || defined(Q_OS_MAC) 379 | // force fusion style on Windows/macOS, 380 | // on Linux/BSD we don't care, use whatever the system has defined. 381 | qApp->setStyle(QStyleFactory::create("fusion")); 382 | #endif 383 | 384 | ui->presetLabel->setContentsMargins(6, 0, 6, 0); 385 | ui->compatLabel->setContentsMargins(6, 0, 6, 0); 386 | 387 | QWidget *spacer = new QWidget(this); 388 | spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); 389 | ui->toolBar->addWidget(spacer); 390 | 391 | ui->toolBar->addWidget(ui->presetLabel); 392 | ui->toolBar->addWidget(ui->preset); 393 | ui->toolBar->addWidget(ui->compatLabel); 394 | ui->toolBar->addWidget(ui->compat); 395 | 396 | #ifndef Q_OS_WIN 397 | ui->actionSupport_dark_mode->setVisible(false); 398 | #endif 399 | 400 | // don't set palette on macos as it breaks dark mode 401 | #ifndef Q_OS_MAC 402 | QPalette previewPalette = ui->preview->palette(); 403 | previewPalette.setColor(QPalette::Base, hasDarkMode() ? QColor(30, 30, 30) : Qt::lightGray); 404 | ui->preview->setPalette(previewPalette); 405 | if (hasDarkMode()) { 406 | QPalette palette; 407 | palette.setColor(QPalette::Window, QColor(53,53,53)); 408 | palette.setColor(QPalette::WindowText, Qt::white); 409 | palette.setColor(QPalette::Base, QColor(15,15,15)); 410 | palette.setColor(QPalette::AlternateBase, QColor(53,53,53)); 411 | palette.setColor(QPalette::Link, Qt::white); 412 | palette.setColor(QPalette::LinkVisited, Qt::white); 413 | palette.setColor(QPalette::ToolTipText, Qt::black); 414 | palette.setColor(QPalette::Text, Qt::white); 415 | palette.setColor(QPalette::Button, QColor(53,53,53)); 416 | palette.setColor(QPalette::ButtonText, Qt::white); 417 | palette.setColor(QPalette::Highlight, QColor(0,124,151)); 418 | palette.setColor(QPalette::HighlightedText, Qt::white); 419 | palette.setColor(QPalette::Disabled, QPalette::Text, Qt::darkGray); 420 | palette.setColor(QPalette::Disabled, QPalette::ButtonText, Qt::darkGray); 421 | qApp->setPalette(palette); 422 | } 423 | QPalette mainPalette = qApp->palette(); 424 | mainPalette.setColor(QPalette::Highlight, QColor(203, 9, 0)); // #cb0900 425 | mainPalette.setColor(QPalette::Link, hasDarkMode() ? Qt::white : QColor(203, 9, 0)); 426 | qApp->setPalette(mainPalette); 427 | 428 | QPalette treePalette = ui->inputs->palette(); 429 | treePalette.setColor(QPalette::Highlight, QColor(124, 124, 124)); // #7c7c7c 430 | ui->inputs->setPalette(treePalette); 431 | #endif 432 | ui->inputs->header()->setVisible(true); // bypass designer bug 433 | 434 | ui->inputs->header()->setStretchLastSection(false); 435 | ui->inputs->header()->setSectionResizeMode(0, QHeaderView::Stretch); 436 | ui->inputs->header()->setSectionResizeMode(1, QHeaderView::Fixed); 437 | 438 | QShortcut *deleteShortcut = new QShortcut(QKeySequence(Qt::Key_Delete), ui->inputs); 439 | connect(deleteShortcut, SIGNAL(activated()), 440 | this, SLOT(deleteDocumentItem())); 441 | 442 | ui->progressBar->setMaximumWidth(100); 443 | ui->statusBar->addPermanentWidget(ui->progressBar); 444 | showProgress(false); 445 | 446 | _proc = new QProcess(this); 447 | 448 | _tabButton = new QPushButton(this); 449 | _tabButton->setFlat(true); 450 | _tabButton->setIconSize(QSize(24, 24)); 451 | _tabButton->setIcon(QIcon::fromTheme(HICOLOR_ICON_CLEAR, 452 | QIcon(FUSEPDF_ICON_CLEAR))); 453 | _tabButton->setToolTip(tr("Clear")); 454 | ui->tabs->setCornerWidget(_tabButton); 455 | populateUI(); 456 | 457 | connect(_proc, SIGNAL(finished(int)), 458 | this, SLOT(commandFinished(int))); 459 | connect(_proc, SIGNAL(started()), 460 | this, SLOT(commandStarted())); 461 | connect(_proc, SIGNAL(readyReadStandardOutput()), 462 | this, SLOT(handleProcOutput())); 463 | connect(_proc, SIGNAL(errorOccurred(QProcess::ProcessError)), 464 | this, SLOT(handleProcessError(QProcess::ProcessError))); 465 | connect(ui->inputs, SIGNAL(foundPDF(QList)), 466 | this, SLOT(handleFoundPDF(QList))); 467 | connect(ui->inputs, SIGNAL(changed()), 468 | this, SLOT(handleOutputPagesChanged())); 469 | connect(ui->inputs, SIGNAL(removeSelected()), 470 | this, SLOT(handleOutputRemoveSelected())); 471 | connect(ui->inputs, SIGNAL(clearAll()), 472 | this, SLOT(handleOutputClearAll())); 473 | connect(ui->inputs, SIGNAL(add()), 474 | this, SLOT(handleOutputAdd())); 475 | connect(this, SIGNAL(commandReady(QString,QString)), 476 | this, SLOT(runCommand(QString,QString))); 477 | connect(this, SIGNAL(statusMessage(QString,int)), 478 | statusBar(), SLOT(showMessage(QString,int))); 479 | connect(this, SIGNAL(exportDone(QString)), 480 | this, SLOT(handleExportDone(QString))); 481 | connect(_tabButton, SIGNAL(clicked(bool)), 482 | this, SLOT(handleTabButtonClicked(bool))); 483 | connect(this, SIGNAL(foundPdfInfo(FusePDF::pdfInfo)), 484 | this, SLOT(handleFoundPdfInfo(FusePDF::pdfInfo))); 485 | 486 | QTimer::singleShot(0, this, SLOT(loadSettings())); 487 | } 488 | 489 | FusePDF::~FusePDF() 490 | { 491 | saveSettings(); 492 | delete ui; 493 | } 494 | 495 | void FusePDF::on_actionOpen_triggered() 496 | { 497 | QStringList files = QFileDialog::getOpenFileNames(this, 498 | tr("Open document(s)"), 499 | !_lastLoadDir.isEmpty()?_lastLoadDir:QDir::homePath(), 500 | "*.pdf"); 501 | if (files.size() > 0) { 502 | QList urls; 503 | for (int i = 0; i < files.size(); ++i) { 504 | urls.append(QUrl::fromUserInput(files.at(i))); 505 | } 506 | if (urls.size() > 0) { handleFoundPDF(urls); } 507 | } 508 | } 509 | 510 | void FusePDF::on_actionSave_triggered() 511 | { 512 | ui->toolBox->setCurrentIndex(FUSEPDF_TOOLBOX_OUTPUT); 513 | int totalPages = pagesToExport(); 514 | qDebug() << "total pages to export" << totalPages; 515 | if (ui->inputs->topLevelItemCount() == 0 || totalPages < 1) { 516 | QMessageBox::warning(this, 517 | tr("No documents/pages"), 518 | tr("No documents/pages to merge, please add some documents or enable some pages before trying to save.")); 519 | return; 520 | } 521 | QString file = QFileDialog::getSaveFileName(this, 522 | tr("Save document"), 523 | !_lastSaveDir.isEmpty()?_lastSaveDir:QDir::homePath(), 524 | "*.pdf"); 525 | if (file.isEmpty()) { return; } 526 | if (!file.endsWith(".pdf", Qt::CaseInsensitive)) { file.append(".pdf"); } 527 | 528 | showProgress(true); 529 | QtConcurrent::run(this, &FusePDF::prepCommand, file); 530 | } 531 | 532 | void FusePDF::on_actionQuit_triggered() 533 | { 534 | qApp->quit(); 535 | } 536 | 537 | void FusePDF::on_actionAbout_triggered() 538 | { 539 | QMessageBox::about(this, 540 | QString("FusePDF"), 541 | QString("

FusePDF %1

" 542 | "

Developed by Ole-André Rodlie for NettStudio AS.

" 543 | "

Copyright © 2021, 2022 NettStudio AS. All rights reserved.

" 544 | "

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

" 545 | "

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

" 546 | "

You should have received a copy of the GNU General Public License along with this program. If not, see www.gnu.org/licenses.

" 547 | "

" 548 | ).arg(VERSION_APP)); 549 | } 550 | 551 | void FusePDF::prepCommand(const QString &filename) 552 | { 553 | QString compat = ui->compat->currentData().toString(); 554 | int pdfa = 0; 555 | if (compat == "A1") { pdfa = 1; } 556 | else if (compat == "A2") { pdfa = 2; } 557 | else if (compat == "A3") { pdfa = 3; } 558 | /*if (pdfa > 0 && ui->metaTitle->text().isEmpty()) { 559 | QMessageBox::warning(this, 560 | tr("PDF/A Warning"), 561 | tr("Document title is not optional in PDF/A. Please add title in 'Output properties'.")); 562 | return; 563 | }*/ 564 | QString command = makeCommand(filename, pdfa); 565 | if (!command.isEmpty()) { emit commandReady(filename, command); } 566 | else { 567 | showProgress(false); 568 | QMessageBox::warning(this, 569 | tr("Failed to make process"), 570 | tr("Failed to make process, this should not happen, please contact support.")); 571 | } 572 | } 573 | 574 | const QString FusePDF::makeCommand(const QString &filename, 575 | int pdfa) 576 | { 577 | if (filename.isEmpty()) { return QString(); } 578 | 579 | QString command = findGhost(); 580 | #ifdef Q_OS_WIN 581 | command = QString("\"%1\"").arg(findGhost()); 582 | #endif 583 | command.append(" -sDEVICE=pdfwrite"); 584 | if (pdfa == 0 && 585 | !ui->compat->currentData().toString().isEmpty() && 586 | ui->compat->currentData().toString().toLower() != "default") { 587 | command.append(QString(" -dCompatibilityLevel=%1").arg(ui->compat->currentData().toString())); 588 | } 589 | if (pdfa == 0 && 590 | !ui->preset->currentData().toString().isEmpty() && 591 | ui->preset->currentData().toString().toLower() != "none") 592 | { 593 | command.append(QString(" -dPDFSETTINGS=/%1").arg(ui->preset->currentData().toString().toLower())); 594 | } 595 | command.append(" -dNOPAUSE -dBATCH"); 596 | 597 | if (pdfa == 0) { command.append(" -dDetectDuplicateImages -dCompressFonts=true"); } 598 | 599 | command.append(QString(" -sOutputFile=\"%1\"").arg(filename)); 600 | 601 | QString title = ui->metaTitle->text(); 602 | QString subject = ui->metaSubject->text(); 603 | QString author = ui->metaAuthor->text(); 604 | 605 | if (pdfa > 0) { 606 | command.append(QString(" -dEmbedAllFonts=true -dNOSAFER -dNOOUTERSAVE -dPDFACompatibilityPolicy=1 -sProcessColorModel=DeviceRGB -sColorConversionStrategy=RGB -dPDFA=%1").arg(pdfa)); 607 | command.append(QString(" \"%1\"").arg(findGhostPdfa())); 608 | } 609 | for (int i = 0; i < ui->inputs->topLevelItemCount(); ++i) { 610 | QString filename = ui->inputs->topLevelItem(i)->data(0, FUSEPDF_PATH_ROLE).toString(); 611 | PagesListWidget *tab = getTab(filename); 612 | int enabledPages = tab? tab->getPagesState(true).size() : 0; 613 | bool modified = false; 614 | if (tab && tab->isModified() && enabledPages > 0) { 615 | modified = true; 616 | QVector pages = tab->getPagesState(true); 617 | for (int i = 0; i < pages.count(); ++i) { 618 | QString extracted = extractPDF(filename, getChecksum(filename), pages.at(i)); 619 | if (!extracted.isEmpty()) { 620 | command.append(QString(" \"%1\"").arg(extracted)); 621 | } 622 | } 623 | } 624 | if (enabledPages < 1) { continue; } 625 | if (!modified) { 626 | command.append(QString(" \"%1\"").arg(filename)); 627 | } 628 | } 629 | 630 | QString marks; 631 | marks.append("/Creator(FusePDF - https://fusepdf.no)"); 632 | if (!title.isEmpty()) { marks.append(QString(pdfa > 0 ? "/Title(%1)" : "/Title<%1>").arg(pdfa > 0 ? stripMarks(title) : QString(toUtf16Hex(title)).toUpper())); } 633 | if (!subject.isEmpty()) { marks.append(QString(pdfa > 0 ? "/Subject(%1)" : "/Subject<%1>").arg(pdfa > 0 ? stripMarks(subject) : QString(toUtf16Hex(subject)).toUpper())); } 634 | if (!author.isEmpty()) { marks.append(QString(pdfa > 0 ? "/Author(%1)" : "/Author<%1>").arg(pdfa > 0 ? stripMarks(author) : QString(toUtf16Hex(author)).toUpper())); } 635 | command.append(QString(" -c \"[%1/DOCINFO pdfmark\"").arg(marks)); 636 | 637 | qDebug() << command; 638 | return command; 639 | } 640 | 641 | void FusePDF::runCommand(const QString &filename, 642 | const QString &command) 643 | { 644 | showProgress(false); 645 | if (missingGhost()) { return; } 646 | 647 | if (ui->inputs->topLevelItemCount() == 0 || filename.isEmpty()) { 648 | QMessageBox::warning(this, 649 | tr("Unable to process"), 650 | tr("Input and/or output is missing.")); 651 | return; 652 | } 653 | if (hasFile(filename)) { 654 | QMessageBox::warning(this, 655 | tr("Unable to save file"), 656 | tr("Unable to save to file, the output file is found in input.")); 657 | return; 658 | } 659 | if (QFile::exists(filename)) { 660 | int ret = QMessageBox::question(this, 661 | tr("File exists"), 662 | tr("File already exists, are you sure you want to overwrite it?")); 663 | if (ret != QMessageBox::Yes) { return; } 664 | } 665 | if (_proc->isOpen()) { 666 | QMessageBox::warning(this, 667 | tr("Still active"), 668 | QString("FusePDF %1").arg(tr("process is still active, please wait until done."))); 669 | return; 670 | } 671 | 672 | if (command.isEmpty()) { 673 | QMessageBox::warning(this, 674 | tr("Failed to make process"), 675 | tr("Failed to make process, this should not happen, please contact support.")); 676 | return; 677 | } 678 | _output = filename; 679 | qDebug() << command; 680 | _proc->start(command); 681 | } 682 | 683 | void FusePDF::commandStarted() 684 | { 685 | ui->cmd->clear(); 686 | ui->actionSave->setDisabled(true); 687 | showProgress(true); 688 | } 689 | 690 | void FusePDF::commandFinished(int exitCode) 691 | { 692 | ui->actionSave->setDisabled(false); 693 | showProgress(false); 694 | _proc->close(); 695 | 696 | if (exitCode == 0) { 697 | QFileInfo fileInfo(_output); 698 | if (_lastSaveDir != fileInfo.absoluteDir().absolutePath()) { 699 | _lastSaveDir = fileInfo.absoluteDir().absolutePath(); 700 | } 701 | if (ui->actionOpen_saved_PDF->isChecked()) { 702 | QDesktopServices::openUrl(QUrl::fromUserInput(_output)); 703 | } 704 | return; 705 | } 706 | 707 | QMessageBox::warning(this, 708 | tr("Failed to save PDF"), 709 | tr("Failed to save PDF, see log (CTRL+L) for more information")); 710 | } 711 | 712 | void FusePDF::populateUI() 713 | { 714 | QIcon docIcon(QIcon::fromTheme(HICOLOR_ICON_DOC, 715 | QIcon(FUSEPDF_ICON_DOC))); 716 | 717 | ui->actionOpen->setIcon(QIcon::fromTheme(HICOLOR_ICON_OPEN, 718 | QIcon(FUSEPDF_ICON_OPEN))); 719 | ui->actionQuit->setIcon(QIcon::fromTheme(HICOLOR_ICON_QUIT, 720 | QIcon(FUSEPDF_ICON_QUIT))); 721 | ui->actionSave->setIcon(QIcon::fromTheme(HICOLOR_ICON_SAVE, 722 | QIcon(FUSEPDF_ICON_SAVE))); 723 | 724 | 725 | QString versionString = tr("version"); 726 | 727 | ui->compat->blockSignals(true); 728 | ui->compat->clear(); 729 | ui->compat->addItem(docIcon, QString("PDF %1 1.0 (Acrobat 1.0)").arg(versionString), "1.0"); 730 | ui->compat->addItem(docIcon, QString("PDF %1 1.1 (Acrobat 2.0)").arg(versionString), "1.1"); 731 | ui->compat->addItem(docIcon, QString("PDF %1 1.2 (Acrobat 3.0)").arg(versionString), "1.2"); 732 | ui->compat->addItem(docIcon, QString("PDF %1 1.3 (Acrobat 4.0)").arg(versionString), "1.3"); 733 | ui->compat->addItem(docIcon, QString("PDF %1 1.4 (Acrobat 5.0)").arg(versionString), "1.4"); 734 | ui->compat->addItem(docIcon, QString("PDF %1 1.5 (Acrobat 6.0)").arg(versionString), "1.5"); 735 | ui->compat->addItem(docIcon, QString("PDF %1 1.6 (Acrobat 7.0)").arg(versionString), "1.6"); 736 | ui->compat->addItem(docIcon, QString("PDF %1 1.7 (Acrobat 8.0/ISO 32000-1)").arg(versionString), "1.7"); 737 | ui->compat->addItem(docIcon, QString("PDF %1 2.0 (ISO 32000-2)").arg(versionString), "2.0"); 738 | ui->compat->addItem(docIcon, QString("PDF/A-1 (ISO 19005-1)"), "A1"); 739 | ui->compat->addItem(docIcon, QString("PDF/A-2 (ISO 19005-2)"), "A2"); 740 | ui->compat->addItem(docIcon, QString("PDF/A-3 (ISO 19005-3)"), "A3"); 741 | ui->compat->blockSignals(false); 742 | 743 | ui->preset->blockSignals(true); 744 | ui->preset->clear(); 745 | ui->preset->addItem(docIcon, tr("None"), "None"); 746 | ui->preset->addItem(docIcon, tr("Default"), "Default"); 747 | ui->preset->addItem(docIcon, tr("Prepress"), "Prepress"); 748 | ui->preset->addItem(docIcon, tr("eBook"), "eBook"); 749 | ui->preset->addItem(docIcon, tr("Screen"), "Screen"); 750 | ui->preset->addItem(docIcon, tr("Printer"), "Printer"); 751 | ui->preset->blockSignals(false); 752 | 753 | ui->preview->setViewMode(QListView::IconMode); 754 | ui->preview->setIconSize(QSize(310, 310)); 755 | ui->preview->setUniformItemSizes(true); 756 | ui->preview->setWrapping(true); 757 | ui->preview->setResizeMode(QListView::Adjust); 758 | ui->preview->setFrameShape(QFrame::NoFrame); 759 | ui->preview->setContextMenuPolicy(Qt::CustomContextMenu); 760 | ui->preview->setItemDelegate(new PageDelegate(this)); 761 | ui->preview->setSpacing(10); 762 | 763 | connect(this, SIGNAL(generatedOutputPreview(QStringList)), 764 | this, SLOT(showOutputPreview(QStringList))); 765 | } 766 | 767 | void FusePDF::loadSettings() 768 | { 769 | QSettings settings; 770 | settings.beginGroup("ui"); 771 | QByteArray lastGeo = settings.value("geometry").toByteArray(); 772 | if (!lastGeo.isNull()) { 773 | restoreGeometry(lastGeo); 774 | QApplication::processEvents(); 775 | } 776 | QByteArray lastState = settings.value("state").toByteArray(); 777 | if (!lastState.isNull()) { 778 | restoreState(lastState); 779 | QApplication::processEvents(); 780 | } 781 | bool wasMax = settings.value("maximized", false).toBool(); 782 | if (wasMax) { showMaximized(); } 783 | settings.endGroup(); 784 | 785 | loadOptions(); 786 | 787 | if (getCachePath().isEmpty()) { 788 | QMessageBox::warning(this, 789 | tr("Missing cache folder"), 790 | tr("Unable to create the cache folder, please check your system permissions.")); 791 | QTimer::singleShot(100, qApp, SLOT(quit())); 792 | } 793 | if (missingGhost()) { 794 | QTimer::singleShot(100, qApp, SLOT(quit())); 795 | } 796 | } 797 | 798 | void FusePDF::saveSettings() 799 | { 800 | saveOptions(); 801 | 802 | QSettings settings; 803 | settings.beginGroup("ui"); 804 | settings.setValue("state", saveState()); 805 | settings.setValue("geometry", saveGeometry()); 806 | settings.setValue("maximized", isMaximized()); 807 | settings.endGroup(); 808 | settings.sync(); 809 | } 810 | 811 | void FusePDF::handleProcOutput() 812 | { 813 | QString log; 814 | log.append(_proc->readAllStandardError()); 815 | log.append(_proc->readAllStandardOutput()); 816 | ui->cmd->appendPlainText(log.simplified()); 817 | ui->statusBar->showMessage(log.simplified(), 1000); 818 | qDebug() << log; 819 | } 820 | 821 | void FusePDF::clearInput(bool askFirst) 822 | { 823 | if (ui->inputs->topLevelItemCount() < 1) { return; } 824 | if (askFirst) { 825 | int res = QMessageBox::question(this, 826 | tr("Clear?"), 827 | tr("Clear all documents?"), 828 | QMessageBox::Yes | QMessageBox::No, 829 | QMessageBox::Yes); 830 | if (res != QMessageBox::Yes) { return; } 831 | } 832 | ui->inputs->clear(); 833 | for (int i = 0; i < ui->tabs->count(); ++i) { 834 | PagesListWidget *tab = qobject_cast(ui->tabs->widget(i)); 835 | if (!tab) { continue; } 836 | tab->deleteLater(); 837 | } 838 | ui->tabs->clear(); 839 | ui->tabs->addTab(ui->tabInputs, 840 | QIcon(FUSEPDF_ICON_MAIN), 841 | tr("Output")); 842 | ui->cmd->clear(); 843 | _output.clear(); 844 | ui->preview->clear(); 845 | ui->toolBox->setCurrentIndex(FUSEPDF_TOOLBOX_OUTPUT); 846 | } 847 | 848 | const QString FusePDF::findGhost(bool pathOnly) 849 | { 850 | #ifdef Q_OS_WIN 851 | QString appDir = QString("%1/gs").arg(qApp->applicationDirPath()); 852 | if (QFile::exists(appDir)) { 853 | QString bin64 = appDir + "/bin/gswin64c.exe"; 854 | if (QFile::exists(bin64)) { return pathOnly ? appDir : bin64; } 855 | QString bin32 = appDir + "/bin/gswin32c.exe"; 856 | if (QFile::exists(bin32)) { return pathOnly ? appDir : bin32; } 857 | } 858 | QString programFilesPath(qgetenv("PROGRAMFILES")); 859 | QDirIterator it(programFilesPath + "/gs", QStringList() << "*.*", QDir::Dirs/*, QDirIterator::Subdirectories*/); 860 | while (it.hasNext()) { 861 | QString folder = it.next(); 862 | QString bin64 = folder + "/bin/gswin64c.exe"; 863 | if (QFile::exists(bin64)) { return pathOnly ? folder : bin64; } 864 | QString bin32 = folder + "/bin/gswin32c.exe"; 865 | if (QFile::exists(bin32)) { return pathOnly ? folder : bin32; } 866 | } 867 | return QString(); 868 | #endif 869 | #ifdef Q_OS_MAC 870 | if (pathOnly) { return QString(); } 871 | QStringList gs; 872 | gs << "/opt/local/bin/gs" << "/usr/local/bin/gs"; 873 | for (int i = 0; i < gs.size(); ++i) { if (QFile::exists(gs.at(i))) { return gs.at(i); } } 874 | return QString(); 875 | #endif 876 | return pathOnly ? QString() : QString("gs"); 877 | } 878 | 879 | const QString FusePDF::findGhostPdfInfo() 880 | { 881 | QString folder = findGhost(true); 882 | if (!QFile::exists(folder)) { return QString(); } 883 | 884 | QString filename = QString("%1/lib/pdf_info.ps").arg(folder); 885 | qDebug() << "have pdf_info.ps?" << filename; 886 | if (QFile::exists(filename)) { return filename; } 887 | 888 | return QString(); 889 | } 890 | 891 | const QString FusePDF::findGhostPdfa(const QString &title) 892 | { 893 | Q_UNUSED(title) 894 | QString cachePath = getCachePath(); 895 | if (cachePath.isEmpty() || !QFile::exists(cachePath)) { return QString(); } 896 | 897 | QString iccPath = QString("%1/srgb.icc").arg(cachePath); 898 | QString pdfaPath = QString("%1/PDFA_def.ps").arg(cachePath); 899 | if ((QFile::exists(iccPath) /*&& title.isEmpty()*/) && QFile::exists(pdfaPath)) { return pdfaPath; } 900 | 901 | if (!QFile::exists(pdfaPath) || !title.isEmpty()) { 902 | QString def; 903 | QFile defFile(":/assets/ps/PDFA_def.ps"); 904 | if (defFile.open(QIODevice::ReadOnly | QIODevice::Text)) { 905 | def = defFile.readAll(); 906 | defFile.close(); 907 | } 908 | if (def.isEmpty()) { return QString(); } 909 | def = def.replace("srgb.icc", iccPath); 910 | //if (!title.isEmpty()) { def = def.replace("Title (Title)", QString("Title (%1)").arg(title)); } 911 | QFile pdfa(pdfaPath); 912 | if (pdfa.open(QIODevice::WriteOnly)) { 913 | pdfa.write(def.toUtf8()); 914 | pdfa.close(); 915 | } 916 | } 917 | 918 | if (!QFile::exists(iccPath)) { 919 | QFile iccfile(":/assets/icc/srgb.icc"); 920 | QByteArray iccBuffer; 921 | if (iccfile.open(QIODevice::ReadOnly)) { 922 | iccBuffer = iccfile.readAll(); 923 | iccfile.close(); 924 | } 925 | if (iccBuffer.size() < 2500) { return QString(); } 926 | QFile srgb(iccPath); 927 | if (srgb.open(QIODevice::WriteOnly)) { 928 | srgb.write(iccBuffer); 929 | srgb.close(); 930 | } 931 | } 932 | 933 | if (QFile::exists(iccPath) && QFile::exists(pdfaPath)) { return pdfaPath; } 934 | return QString(); 935 | } 936 | 937 | void FusePDF::on_actionShow_log_triggered() 938 | { 939 | ui->cmd->setVisible(ui->actionShow_log->isChecked()); 940 | } 941 | 942 | void FusePDF::on_actionAbout_Qt_triggered() 943 | { 944 | QMessageBox::aboutQt(this, QString("%1 Qt").arg(tr("About"))); 945 | } 946 | 947 | void FusePDF::handleFoundPDF(const QList &urls) 948 | { 949 | for (int i=0;i< urls.size();++i) { 950 | const QFileInfo info(urls.at(i).toLocalFile()); 951 | if (!isPDF(info.filePath()) || hasFile(info.filePath())) { continue; } 952 | int pages = getPageCount(info.filePath()); 953 | QString checksum = getChecksum(info.filePath()); 954 | QTreeWidgetItem *item = new QTreeWidgetItem(ui->inputs); 955 | item->setData(0, FUSEPDF_PATH_ROLE, info.filePath()); 956 | item->setData(0, FUSEPDF_PAGES_ROLE, pages); 957 | item->setData(0, FUSEPDF_CHECKSUM_ROLE, checksum); 958 | item->setText(0, info.fileName()); 959 | item->setText(1, QString::number(pages)); 960 | item->setText(2, QString::number(pages)); 961 | item->setIcon(0, QIcon(FUSEPDF_ICON_MAIN)); 962 | item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemNeverHasChildren); 963 | if (!info.absolutePath().isEmpty()) { _lastLoadDir = info.absolutePath(); } 964 | if (hasTab(info.filePath())) { continue; } 965 | ui->tabs->addTab(new PagesListWidget(this, info.filePath(), checksum, pages), 966 | QIcon(QIcon::fromTheme(HICOLOR_ICON_DOC, QIcon(FUSEPDF_ICON_DOC))), 967 | info.fileName()); 968 | // don't set palette on macos as it breaks dark mode 969 | #ifndef Q_OS_MAC 970 | QPalette pal = getTab(info.filePath())->palette(); 971 | if (hasDarkMode()) { pal.setColor(QPalette::Base, QColor(30, 30, 30)); } 972 | else { pal.setColor(QPalette::Base, Qt::lightGray); } 973 | getTab(info.filePath())->setPalette(pal); 974 | #endif 975 | connect(this, SIGNAL(foundPagePreview(QString,QString,QString,int)), 976 | getTab(info.filePath()), SLOT(setPageIcon(QString,QString,QString,int))); 977 | connect(getTab(info.filePath()), SIGNAL(requestExportPage(QString,int)), 978 | this, SLOT(handleExport(QString,int))); 979 | connect(getTab(info.filePath()), SIGNAL(requestExportPages(QString,QVector)), 980 | this, SLOT(handleExports(QString,QVector))); 981 | connect(getTab(info.filePath()), SIGNAL(changed()), 982 | this, SLOT(handleOutputPagesChanged())); 983 | QtConcurrent::run(this, 984 | &FusePDF::getPagePreviews, 985 | info.filePath(), 986 | checksum, 987 | pages); 988 | QtConcurrent::run(this, 989 | &FusePDF::getPdfInfo, 990 | info.filePath(), 991 | checksum); 992 | if (ui->actionOutput_preview->isChecked()) { 993 | QtConcurrent::run(this, &FusePDF::generateOutputPreview); 994 | } 995 | } 996 | } 997 | 998 | void FusePDF::on_inputs_itemDoubleClicked(QTreeWidgetItem *item, 999 | int column) 1000 | { 1001 | Q_UNUSED(column) 1002 | if (!item) { return; } 1003 | QString filename = item->data(0, FUSEPDF_PATH_ROLE).toString(); 1004 | int index = getTabIndex(filename); 1005 | if (index < 1) { return; } 1006 | ui->tabs->setCurrentIndex(index); 1007 | } 1008 | 1009 | void FusePDF::on_actionAuto_Sort_triggered() 1010 | { 1011 | ui->inputs->setSortingEnabled(ui->actionAuto_Sort->isChecked()); 1012 | } 1013 | 1014 | bool FusePDF::hasFile(const QString &file) 1015 | { 1016 | if (file.isEmpty()) { return false; } 1017 | QFileInfo fileInfo(file); 1018 | for (int i = 0; i < ui->inputs->topLevelItemCount(); ++i) { 1019 | QFileInfo inputInfo(ui->inputs->topLevelItem(i)->data(0, FUSEPDF_PATH_ROLE).toString()); 1020 | if (inputInfo.absoluteFilePath() == fileInfo.absoluteFilePath()) { return true; } 1021 | } 1022 | return false; 1023 | } 1024 | 1025 | void FusePDF::loadOptions() 1026 | { 1027 | QSettings settings; 1028 | settings.beginGroup("options"); 1029 | 1030 | QString savedCompat = settings.value("compat", "1.5").toString(); 1031 | ui->compat->blockSignals(true); 1032 | for (int i = 0; i < ui->compat->count(); i++) { 1033 | QString value = ui->compat->itemData(i).toString(); 1034 | if (value == savedCompat) { 1035 | ui->compat->setCurrentIndex(i); 1036 | qDebug() << "set compat index" << i << savedCompat; 1037 | break; 1038 | } 1039 | } 1040 | ui->compat->blockSignals(false); 1041 | 1042 | QString savedPreset = settings.value("preset", "Default").toString(); 1043 | ui->preset->blockSignals(true); 1044 | for (int i = 0; i < ui->preset->count(); i++) { 1045 | QString value = ui->preset->itemData(i).toString(); 1046 | if (value == savedPreset) { 1047 | ui->preset->setCurrentIndex(i); 1048 | qDebug() << "set preset index" << i << savedPreset; 1049 | break; 1050 | } 1051 | } 1052 | ui->preset->blockSignals(false); 1053 | 1054 | #ifdef Q_OS_WIN 1055 | ui->actionSupport_dark_mode->setChecked(settings.value("supportDarkMode", false).toBool()); 1056 | #endif 1057 | ui->actionOutput_preview->setChecked(settings.value("outputPreview", true).toBool()); 1058 | ui->actionShow_log->setChecked(settings.value("showLog", false).toBool()); 1059 | ui->actionAuto_Sort->setChecked(settings.value("autoSort", false).toBool()); 1060 | ui->actionRemember_meta_author->setChecked(settings.value("metaAuthor", true).toBool()); 1061 | ui->actionRemember_meta_subject->setChecked(settings.value("metaSubject", true).toBool()); 1062 | ui->actionRemember_meta_title->setChecked(settings.value("metaTitle", true).toBool()); 1063 | _lastLoadDir = settings.value("lastLoadDir", "").toString(); 1064 | _lastSaveDir = settings.value("lastSaveDir", "").toString(); 1065 | _lastExportDir = settings.value("lastExportDir").toString(); 1066 | ui->actionOpen_saved_PDF->setChecked(settings.value("openSavedPDF", true).toBool()); 1067 | ui->actionShow_tooltips->setChecked(settings.value("showTooltips", true).toBool()); 1068 | showTooltips(settings.value("showTooltips", true).toBool()); 1069 | ui->cmd->setVisible(ui->actionShow_log->isChecked()); 1070 | ui->inputs->setSortingEnabled(ui->actionAuto_Sort->isChecked()); 1071 | 1072 | if (ui->actionRemember_meta_author->isChecked()) { 1073 | QString author = settings.value("metaAuthorText").toString(); 1074 | if (!author.isEmpty()) { 1075 | ui->metaAuthor->blockSignals(true); 1076 | ui->metaAuthor->setText(author); 1077 | ui->metaAuthor->blockSignals(false); 1078 | } 1079 | } 1080 | if (ui->actionRemember_meta_subject->isChecked()) { 1081 | QString subject = settings.value("metaSubjectText").toString(); 1082 | if (!subject.isEmpty()) { 1083 | ui->metaSubject->blockSignals(true); 1084 | ui->metaSubject->setText(subject); 1085 | ui->metaSubject->blockSignals(false); 1086 | } 1087 | } 1088 | if (ui->actionRemember_meta_title->isChecked()) { 1089 | QString title = settings.value("metaTitleText").toString(); 1090 | if (!title.isEmpty()) { 1091 | ui->metaTitle->blockSignals(true); 1092 | ui->metaTitle->setText(title); 1093 | ui->metaTitle->blockSignals(false); 1094 | } 1095 | } 1096 | 1097 | settings.endGroup(); 1098 | 1099 | ui->toolBox->setItemEnabled(FUSEPDF_TOOLBOX_PREVIEW, 1100 | ui->actionOutput_preview->isChecked()); 1101 | } 1102 | 1103 | void FusePDF::saveOptions() 1104 | { 1105 | QSettings settings; 1106 | settings.beginGroup("options"); 1107 | 1108 | #ifdef Q_OS_WIN 1109 | settings.setValue("supportDarkMode", ui->actionSupport_dark_mode->isChecked()); 1110 | #endif 1111 | settings.setValue("outputPreview", ui->actionOutput_preview->isChecked()); 1112 | settings.setValue("showLog", ui->actionShow_log->isChecked()); 1113 | settings.setValue("autoSort", ui->actionAuto_Sort->isChecked()); 1114 | settings.setValue("openSavedPDF", ui->actionOpen_saved_PDF->isChecked()); 1115 | settings.setValue("showTooltips", ui->actionShow_tooltips->isChecked()); 1116 | settings.setValue("metaAuthor", ui->actionRemember_meta_author->isChecked()); 1117 | settings.setValue("metaSubject", ui->actionRemember_meta_subject->isChecked()); 1118 | settings.setValue("metaTitle", ui->actionRemember_meta_title->isChecked()); 1119 | 1120 | if (!_lastLoadDir.isEmpty()) { settings.setValue("lastLoadDir", _lastLoadDir); } 1121 | if (!_lastSaveDir.isEmpty()) { settings.setValue("lastSaveDir", _lastSaveDir); } 1122 | if (!_lastExportDir.isEmpty()) { settings.setValue("lastExportDir", _lastExportDir); } 1123 | settings.endGroup(); 1124 | } 1125 | 1126 | bool FusePDF::isNewVersion() 1127 | { 1128 | QSettings settings; 1129 | if (settings.value("version") != VERSION_APP) { 1130 | settings.setValue("version", VERSION_APP); 1131 | return true; 1132 | } 1133 | return false; 1134 | } 1135 | 1136 | bool FusePDF::missingGhost() 1137 | { 1138 | if (findGhost().isEmpty()) { 1139 | QString mac = QString(". %1 uoregon.edu, %3 macports %5 homebrew %7 Ghostscript") 1140 | .arg(tr("On macOS you can find installers from"), 1141 | FUSEPDF_GS_MAC_URL, 1142 | tr("or use"), 1143 | FUSEPDF_GS_MACPORTS_URL, 1144 | tr("or"), 1145 | FUSEPDF_GS_HOMEBREW_URL, 1146 | tr("to install")); 1147 | QMessageBox::warning(this, 1148 | QString("%1 Ghostscript").arg(tr("Missing")), 1149 | QString("%1 Ghostscript, %2 ghostscript.com %3%5.") 1150 | .arg(tr("Unable to find"), 1151 | tr("please download the latest Windows installer from"), 1152 | tr("and install it before running this application again"), 1153 | FUSEPDF_GS_URL, 1154 | mac)); 1155 | return true; 1156 | } 1157 | return false; 1158 | } 1159 | 1160 | void FusePDF::handleProcessError(QProcess::ProcessError error) 1161 | { 1162 | _proc->close(); 1163 | QString errorMsg; 1164 | switch (error) { 1165 | case QProcess::FailedToStart: 1166 | errorMsg = tr("The process failed to start."); 1167 | break; 1168 | case QProcess::Crashed: 1169 | errorMsg = tr("The process crashed."); 1170 | break; 1171 | default: 1172 | errorMsg = tr("An unknown error occured."); 1173 | break; 1174 | } 1175 | errorMsg.append(QString(" %1").arg(tr("See log (CTRL+L) for more information"))); 1176 | QMessageBox::warning(this, tr("Process failed"), errorMsg); 1177 | } 1178 | 1179 | void FusePDF::deleteDocumentItem() 1180 | { 1181 | if (ui->inputs->topLevelItemCount() == 0 || ui->inputs->currentItem() == nullptr) { return; } 1182 | QString filename = ui->inputs->currentItem()->data(0, FUSEPDF_PATH_ROLE).toString(); 1183 | delete ui->inputs->currentItem(); 1184 | 1185 | int index = getTabIndex(filename); 1186 | if (index < 0) { return; } 1187 | PagesListWidget *tab = getTab(filename); 1188 | if (!tab) { return; } 1189 | ui->tabs->removeTab(index); 1190 | tab->deleteLater(); 1191 | 1192 | ui->toolBox->setCurrentIndex(ui->actionOutput_preview->isChecked() ? FUSEPDF_TOOLBOX_PREVIEW : FUSEPDF_TOOLBOX_OUTPUT); 1193 | 1194 | handleOutputPagesChanged(); 1195 | } 1196 | 1197 | QByteArray FusePDF::toUtf16Hex(QString str) 1198 | { 1199 | // https://stackoverflow.com/a/38831604 1200 | str.prepend(QChar::ByteOrderMark); 1201 | return QByteArray::fromRawData(reinterpret_cast(str.constData()), 1202 | (str.size()+1)*2).toHex(); 1203 | } 1204 | 1205 | int FusePDF::getPageCount(const QString &filename) 1206 | { 1207 | int result = 0; 1208 | if (!isPDF(filename)) { return result; } 1209 | 1210 | QString command = findGhost(); 1211 | if (command.isEmpty()) { return result; } 1212 | #ifdef Q_OS_WIN 1213 | command = QString("\"%1\"").arg(findGhost()); 1214 | #endif 1215 | command.append(QString(FUSEPDF_GS_COUNT).arg(filename)); 1216 | 1217 | QProcess proc; 1218 | proc.start(command); 1219 | proc.waitForFinished(); 1220 | result = proc.readAll().replace("PageCount:", "").simplified().toInt(); 1221 | proc.close(); 1222 | 1223 | qDebug() << command << result; 1224 | 1225 | return result; 1226 | } 1227 | 1228 | bool FusePDF::isFileType(const QString &filename, 1229 | const QString &mime, 1230 | bool startsWith) 1231 | { 1232 | QMimeDatabase db; 1233 | QMimeType type = db.mimeTypeForFile(filename); 1234 | return (startsWith? type.name().startsWith(mime) : type.name() == mime); 1235 | } 1236 | 1237 | bool FusePDF::isPDF(const QString &filename) 1238 | { 1239 | return isFileType(filename, "application/pdf"); 1240 | } 1241 | 1242 | bool FusePDF::isJPG(const QString &filename) 1243 | { 1244 | return isFileType(filename, "image/jpeg"); 1245 | } 1246 | 1247 | bool FusePDF::isTIFF(const QString &filename) 1248 | { 1249 | return isFileType(filename, "image/tiff"); 1250 | } 1251 | 1252 | bool FusePDF::isPNG(const QString &filename) 1253 | { 1254 | return isFileType(filename, "image/png"); 1255 | } 1256 | 1257 | bool FusePDF::isImage(const QString &filename) 1258 | { 1259 | return isFileType(filename, "image/", true); 1260 | } 1261 | 1262 | QString FusePDF::ghostImageFormat(int type) 1263 | { 1264 | QString format; 1265 | switch (type) { 1266 | case exportTiffTypeGray: 1267 | format = "tiffgray"; 1268 | break; 1269 | case exportTiffTypeRGB12: 1270 | format = "tiff12nc"; 1271 | break; 1272 | case exportTiffTypeRGB24: 1273 | format = "tiff24nc"; 1274 | break; 1275 | case exportTiffTypeRGB48: 1276 | format = "tiff48nc"; 1277 | break; 1278 | case exportTiffTypeCMYK32: 1279 | format = "tiff32nc"; 1280 | break; 1281 | case exportTiffTypeCMYK64: 1282 | format = "tiff64nc"; 1283 | break; 1284 | case exportPNGTypeGray: 1285 | format = "pnggray"; 1286 | break; 1287 | case exportPNGType16: 1288 | format = "png16m"; 1289 | break; 1290 | default: break; 1291 | } 1292 | return format; 1293 | } 1294 | 1295 | const QString FusePDF::getCachePath() 1296 | { 1297 | QString path = QDir::tempPath(); 1298 | path.append("/fusepdf"); 1299 | if (!QFile::exists(path)) { 1300 | QDir dir(path); 1301 | if (!dir.mkpath(path)) { return QString(); } 1302 | } 1303 | return path; 1304 | } 1305 | 1306 | PagesListWidget *FusePDF::getTab(const QString &filename) 1307 | { 1308 | if (filename.isEmpty()) { return nullptr; } 1309 | for (int i = 0; i < ui->tabs->count(); ++i) { 1310 | PagesListWidget *tab = qobject_cast(ui->tabs->widget(i)); 1311 | if (tab && tab->getFilename() == filename) { return tab; } 1312 | } 1313 | return nullptr; 1314 | } 1315 | 1316 | bool FusePDF::hasTab(const QString &filename) 1317 | { 1318 | PagesListWidget *tab = getTab(filename); 1319 | if (tab && tab->getFilename() == filename) { return true; } 1320 | return false; 1321 | } 1322 | 1323 | int FusePDF::getTabIndex(const QString &filename) 1324 | { 1325 | int result = -1; 1326 | if (filename.isEmpty()) { return result; } 1327 | for (int i = 0; i < ui->tabs->count(); ++i) { 1328 | PagesListWidget *tab = qobject_cast(ui->tabs->widget(i)); 1329 | if (tab && tab->getFilename() == filename) { return i; } 1330 | } 1331 | return result; 1332 | } 1333 | 1334 | const QString FusePDF::getPagePreview(const QString &filename, 1335 | const QString &checksum, 1336 | int page, 1337 | int quality) 1338 | { 1339 | emit statusMessage(tr("Generating preview %1 for %2 ...").arg(page).arg(QFileInfo(filename).fileName()), 1000); 1340 | QString cache = getCachePath(); 1341 | if (!isPDF(filename) || cache.isEmpty()) { return QString(); } 1342 | 1343 | QString image = QString(FUSEPDF_CACHE_JPEG).arg(cache, checksum, QString::number(page)); 1344 | 1345 | QString command = findGhost(); 1346 | if (command.isEmpty()) { return QString(); } 1347 | #ifdef Q_OS_WIN 1348 | command = QString("\"%1\"").arg(findGhost()); 1349 | #endif 1350 | command.append(QString(FUSEPDF_GS_PREVIEW).arg(filename).arg(image).arg(page).arg(quality)); 1351 | 1352 | QProcess proc; 1353 | proc.start(command); 1354 | proc.waitForFinished(); 1355 | proc.close(); 1356 | 1357 | qDebug() << command << image; 1358 | 1359 | if (isJPG(image)) { return image; } 1360 | return QString(); 1361 | } 1362 | 1363 | void FusePDF::getPagePreviews(const QString &filename, 1364 | const QString &checksum, 1365 | int pages) 1366 | { 1367 | QString cache = getCachePath(); 1368 | if (!isPDF(filename) || pages < 1 || cache.isEmpty()) { return; } 1369 | for (int i = 1; i <= pages; ++i) { 1370 | QString image = QString(FUSEPDF_CACHE_JPEG).arg(cache, checksum, QString::number(i)); 1371 | if (!QFile::exists(image)) { 1372 | image = getPagePreview(filename, checksum, i); 1373 | } 1374 | if (!image.isEmpty()) { emit foundPagePreview(filename, checksum, image, i); } 1375 | } 1376 | } 1377 | 1378 | const QString FusePDF::getChecksum(const QString &filename) 1379 | { 1380 | if (!isPDF(filename)) { return QString(); } 1381 | QFile file(filename); 1382 | QString result; 1383 | if (file.open(QFile::ReadOnly)) { 1384 | QCryptographicHash hash(QCryptographicHash::Sha256); 1385 | if (hash.addData(&file)) { result = hash.result().toHex(); } 1386 | file.close(); 1387 | } 1388 | return result; 1389 | } 1390 | 1391 | const QString FusePDF::extractPDF(const QString &filename, 1392 | const QString &checksum, 1393 | int page, 1394 | bool force) 1395 | { 1396 | emit statusMessage(tr("Extracting pages ..."), 1000); 1397 | QString cache = getCachePath(); 1398 | QString command = findGhost(); 1399 | 1400 | if (command.isEmpty() || cache.isEmpty()) { return QString(); } 1401 | cache = QString(FUSEPDF_CACHE_PDF).arg(cache, checksum, QString::number(page)); 1402 | if (!force && QFile::exists(cache) && isPDF(cache)) { return cache; } 1403 | #ifdef Q_OS_WIN 1404 | command = QString("\"%1\"").arg(findGhost()); 1405 | #endif 1406 | command.append(QString(FUSEPDF_GS_EXTRACT).arg(filename).arg(cache).arg(page)); 1407 | 1408 | QProcess proc; 1409 | proc.start(command); 1410 | proc.waitForFinished(); 1411 | proc.close(); 1412 | 1413 | qDebug() << command << cache; 1414 | 1415 | if (isPDF(cache)) { return cache; } 1416 | return QString(); 1417 | } 1418 | 1419 | void FusePDF::showProgress(bool progress) 1420 | { 1421 | ui->progressBar->setMaximum(progress?0:100); 1422 | ui->progressBar->setValue(progress?0:100); 1423 | ui->progressBar->setHidden(!progress); 1424 | } 1425 | 1426 | void FusePDF::on_actionOpen_cache_folder_triggered() 1427 | { 1428 | QDesktopServices::openUrl(QUrl::fromUserInput(getCachePath())); 1429 | } 1430 | 1431 | void FusePDF::on_actionShow_tooltips_triggered() 1432 | { 1433 | showTooltips(ui->actionShow_tooltips->isChecked()); 1434 | } 1435 | 1436 | void FusePDF::showTooltips(bool show) 1437 | { 1438 | ui->metaTitleLabel->setToolTip(show?tr("Set custom document title"):QString()); 1439 | ui->metaTitle->setToolTip(show?ui->metaTitleLabel->toolTip():QString()); 1440 | ui->metaAuthorLabel->setToolTip(show?tr("Set custom document author"):QString()); 1441 | ui->metaAuthor->setToolTip(show?ui->metaAuthorLabel->toolTip():QString()); 1442 | ui->metaSubjectLabel->setToolTip(show?tr("Set custom document subject"):QString()); 1443 | ui->metaSubject->setToolTip(show?ui->metaSubjectLabel->toolTip():QString()); 1444 | ui->presetLabel->setToolTip(show?tr("Distiller presets\n\n" 1445 | "- DEFAULT: selects output intended to be useful across a wide variety of uses, possibly at the expense of a larger output file.\n" 1446 | "- PREPRESS: selects output similar to Acrobat Distiller \"Prepress Optimized\" setting.\n" 1447 | "- EBOOK: selects medium-resolution output similar to the Acrobat Distiller \"eBook\" setting.\n" 1448 | "- SCREEN: selects low-resolution output similar to the Acrobat Distiller \"Screen Optimized\" setting.\n" 1449 | "- PRINTER: selects output similar to the Acrobat Distiller \"Print Optimized\" setting."):QString()); 1450 | ui->preset->setToolTip(show?ui->presetLabel->toolTip():QString()); 1451 | ui->compatLabel->setToolTip(show?tr("Select the PDF version this document should be compatible with."):QString()); 1452 | ui->compat->setToolTip(show?ui->compatLabel->toolTip():QString()); 1453 | /*ui->inputs->setToolTip(show?tr("Drag and drop PDF documents you want to merge here. You can re-arrange after adding them (if sorting is disabled).\n\n" 1454 | "Note that the first document will define the paper size on the final output.\n\n" 1455 | "You can remove a document with the DEL key."):QString());*/ 1456 | } 1457 | 1458 | void FusePDF::on_actionCheck_for_updates_triggered() 1459 | { 1460 | QDesktopServices::openUrl(QUrl::fromUserInput(FUSEPDF_RELEASES_URL)); 1461 | } 1462 | 1463 | void FusePDF::on_actionReport_issue_triggered() 1464 | { 1465 | QDesktopServices::openUrl(QUrl::fromUserInput(FUSEPDF_ISSUE_URL)); 1466 | } 1467 | 1468 | bool FusePDF::exportImage(const QString &filename, 1469 | const QString &image, 1470 | int page, 1471 | int type, 1472 | int res, 1473 | int alpha) 1474 | { 1475 | if (!isPDF(filename) || image.isEmpty() || page < 1 || res < 72 || alpha < 1) { 1476 | return false; 1477 | } 1478 | QString format = ghostImageFormat(type); 1479 | QString command = findGhost(); 1480 | 1481 | if (command.isEmpty() || format.isEmpty()) { return false; } 1482 | #ifdef Q_OS_WIN 1483 | command = QString("\"%1\"").arg(findGhost()); 1484 | #endif 1485 | command.append(QString(FUSEPDF_GS_EXPORT).arg(filename).arg(image).arg(page).arg(format).arg(res)); 1486 | 1487 | QProcess proc; 1488 | proc.start(command); 1489 | proc.waitForFinished(); 1490 | proc.close(); 1491 | 1492 | qDebug() << command << image; 1493 | 1494 | if (isImage(image)) { return true; } 1495 | return false; 1496 | } 1497 | 1498 | void FusePDF::handleExport(const QString &filename, int page) 1499 | { 1500 | QString image = QFileDialog::getSaveFileName(this, 1501 | tr("Save Image"), 1502 | !_lastExportDir.isEmpty()?_lastExportDir:QDir::homePath(), 1503 | "*.tif *.tiff *.png"); 1504 | if (image.isEmpty()) { return; } 1505 | ExportImageDialog dialog(this, Qt::WindowFlags(), QFileInfo(image).suffix()); 1506 | int d = dialog.exec(); 1507 | if (d != QDialog::Accepted) { return; } 1508 | int type = dialog.getImageType(); 1509 | int res = dialog.getImageRes(); 1510 | QVector pages; 1511 | pages << page; 1512 | 1513 | showProgress(true); 1514 | QtConcurrent::run(this, 1515 | &FusePDF::doExport, 1516 | filename, 1517 | image, 1518 | pages, 1519 | type, 1520 | res); 1521 | } 1522 | 1523 | void FusePDF::handleExports(const QString &filename, 1524 | QVector pages) 1525 | { 1526 | QString image = QFileDialog::getSaveFileName(this, 1527 | tr("Save Image"), 1528 | !_lastExportDir.isEmpty()?_lastExportDir:QDir::homePath(), 1529 | "*.tif *.tiff *.png"); 1530 | if (image.isEmpty()) { return; } 1531 | ExportImageDialog dialog(this, Qt::WindowFlags(), QFileInfo(image).suffix()); 1532 | int d = dialog.exec(); 1533 | if (d != QDialog::Accepted) { return; } 1534 | int type = dialog.getImageType(); 1535 | int res = dialog.getImageRes(); 1536 | 1537 | showProgress(true); 1538 | QtConcurrent::run(this, 1539 | &FusePDF::doExport, 1540 | filename, 1541 | image, 1542 | pages, 1543 | type, 1544 | res); 1545 | } 1546 | 1547 | void FusePDF::doExport(const QString &filename, 1548 | const QString &image, 1549 | QVector pages, 1550 | int type, 1551 | int res) 1552 | { 1553 | QFileInfo info(image); 1554 | for (int i = 0; i < pages.size(); ++i) { 1555 | emit statusMessage(tr("Exporting image %1 from %2 ...") 1556 | .arg(pages.at(i)) 1557 | .arg(QFileInfo(filename).fileName()), 1558 | 1000); 1559 | if (!exportImage(filename, 1560 | QString("%1/%2-%3.%4") 1561 | .arg(info.dir().absolutePath(), 1562 | info.baseName(), 1563 | QString::number(pages.at(i)), 1564 | info.suffix()), 1565 | pages.at(i), 1566 | type, 1567 | res)) 1568 | { 1569 | emit exportDone(QString()); 1570 | return; 1571 | } 1572 | } 1573 | if (pages.size() < 2) { 1574 | emit exportDone(QString("%1/%2-%3.%4") 1575 | .arg(info.dir().absolutePath(), 1576 | info.baseName(), 1577 | QString::number(pages.at(0)), 1578 | info.suffix())); 1579 | } else { 1580 | emit exportDone(info.dir().absolutePath()); 1581 | } 1582 | } 1583 | 1584 | void FusePDF::handleExportDone(const QString &path) 1585 | { 1586 | qDebug() << "export done" << path; 1587 | showProgress(false); 1588 | if (path.isEmpty()) { 1589 | QMessageBox::warning(this, 1590 | tr("Failed to export"), 1591 | tr("Failed to export image(s).")); 1592 | return; 1593 | } 1594 | if (_lastExportDir != QFileInfo(path).dir().absolutePath()) { 1595 | _lastExportDir = QFileInfo(path).dir().absolutePath(); 1596 | } 1597 | QDesktopServices::openUrl(QUrl::fromUserInput(path)); 1598 | } 1599 | 1600 | void FusePDF::on_preset_currentIndexChanged(int index) 1601 | { 1602 | if (index >= ui->preset->count()) { return; } 1603 | QString newPreset = ui->preset->itemData(index).toString(); 1604 | 1605 | QSettings settings; 1606 | settings.beginGroup("options"); 1607 | QString savedPreset = settings.value("preset").toString(); 1608 | if (newPreset != savedPreset && !newPreset.isEmpty()) { 1609 | settings.setValue("preset", newPreset); 1610 | qDebug() << "updated preset settings" << newPreset << "vs." << savedPreset; 1611 | } 1612 | settings.endGroup(); 1613 | } 1614 | 1615 | void FusePDF::on_compat_currentIndexChanged(int index) 1616 | { 1617 | if (index >= ui->compat->count()) { return; } 1618 | QString newCompat = ui->compat->itemData(index).toString(); 1619 | 1620 | QSettings settings; 1621 | settings.beginGroup("options"); 1622 | QString savedCompat = settings.value("compat").toString(); 1623 | if (newCompat != savedCompat && !newCompat.isEmpty()) { 1624 | settings.setValue("compat", newCompat); 1625 | qDebug() << "updated compat settings" << newCompat << "vs." << savedCompat; 1626 | } 1627 | settings.endGroup(); 1628 | } 1629 | 1630 | void FusePDF::on_metaTitle_textChanged(const QString &arg1) 1631 | { 1632 | QSettings settings; 1633 | settings.beginGroup("options"); 1634 | if (ui->actionRemember_meta_title->isChecked()) { 1635 | settings.setValue("metaTitleText", arg1); 1636 | } 1637 | settings.endGroup(); 1638 | } 1639 | 1640 | void FusePDF::on_metaSubject_textChanged(const QString &arg1) 1641 | { 1642 | QSettings settings; 1643 | settings.beginGroup("options"); 1644 | if (ui->actionRemember_meta_subject->isChecked()) { 1645 | settings.setValue("metaSubjectText", arg1); 1646 | } 1647 | settings.endGroup(); 1648 | } 1649 | 1650 | void FusePDF::on_metaAuthor_textChanged(const QString &arg1) 1651 | { 1652 | QSettings settings; 1653 | settings.beginGroup("options"); 1654 | if (ui->actionRemember_meta_author->isChecked()) { 1655 | settings.setValue("metaAuthorText", arg1); 1656 | } 1657 | settings.endGroup(); 1658 | } 1659 | 1660 | void FusePDF::on_tabs_currentChanged(int index) 1661 | { 1662 | if (index == 0) { 1663 | _tabButton->setIcon(QIcon(QIcon::fromTheme(HICOLOR_ICON_CLEAR, 1664 | QIcon(FUSEPDF_ICON_CLEAR)))); 1665 | _tabButton->setToolTip(tr("Clear")); 1666 | } else { 1667 | _tabButton->setIcon(QIcon(QIcon::fromTheme(HICOLOR_ICON_GOFIRST, 1668 | QIcon(FUSEPDF_ICON_GOFIRST)))); 1669 | _tabButton->setToolTip(tr("Show documents")); 1670 | } 1671 | } 1672 | 1673 | void FusePDF::handleTabButtonClicked(bool checked) 1674 | { 1675 | Q_UNUSED(checked) 1676 | int index = ui->tabs->currentIndex(); 1677 | if (index == 0) { 1678 | clearInput(true); 1679 | } else if (index > 0) { 1680 | ui->tabs->setCurrentIndex(0); 1681 | } 1682 | } 1683 | 1684 | bool FusePDF::hasDarkMode() 1685 | { 1686 | #ifdef Q_OS_WIN 1687 | QSettings options; 1688 | options.beginGroup("options"); 1689 | bool supportDarkMode = options.value("supportDarkMode", false).toBool(); 1690 | options.endGroup(); 1691 | if (!supportDarkMode) { return false; } 1692 | QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", QSettings::NativeFormat); 1693 | if (settings.value("AppsUseLightTheme") == 0) { return true; } 1694 | #endif 1695 | return false; 1696 | } 1697 | 1698 | void FusePDF::generateOutputPreview() 1699 | { 1700 | QString cache = getCachePath(); 1701 | if (cache.isEmpty()) { return; } 1702 | QStringList docs, images; 1703 | for (int i = 0; i < ui->inputs->topLevelItemCount(); ++i) { 1704 | QString filename = ui->inputs->topLevelItem(i)->data(0, FUSEPDF_PATH_ROLE).toString(); 1705 | PagesListWidget *tab = getTab(filename); 1706 | bool modified = false; 1707 | int enabledPages = tab? tab->getPagesState(true).size() : 0; 1708 | if (tab && tab->isModified() && enabledPages > 0) { 1709 | modified = true; 1710 | QVector pages = tab->getPagesState(true); 1711 | for (int i = 0; i < pages.count(); ++i) { 1712 | QString extracted = extractPDF(filename, getChecksum(filename), pages.at(i), false); 1713 | if (!extracted.isEmpty()) { 1714 | docs << extracted; 1715 | QString checksum = getChecksum(filename); 1716 | QString image = QString(FUSEPDF_CACHE_JPEG).arg(cache, checksum, QString::number(pages.at(i))); 1717 | if (!QFile::exists(image)) { image = getPagePreview(filename, checksum, i); } 1718 | if (!image.isEmpty()) { images << image; } 1719 | } 1720 | } 1721 | } 1722 | if (enabledPages < 1) { continue; } 1723 | if (!modified) { 1724 | docs << filename; 1725 | int pages = getPageCount(filename); 1726 | QString checksum = getChecksum(filename); 1727 | for (int i = 1; i <= pages; ++i) { 1728 | QString image = QString(FUSEPDF_CACHE_JPEG).arg(cache, checksum, QString::number(i)); 1729 | if (!QFile::exists(image)) { image = getPagePreview(filename, checksum, i); } 1730 | if (!image.isEmpty() && !images.contains(image)) { images << image; } 1731 | } 1732 | } 1733 | } 1734 | if (images.size() > 0) { emit generatedOutputPreview(images); } 1735 | } 1736 | 1737 | void FusePDF::handleOutputPagesChanged() 1738 | { 1739 | if (!ui->actionOutput_preview->isChecked()) { return; } 1740 | int totalPages = pagesToExport(); 1741 | if (totalPages < 1) { 1742 | ui->preview->clear(); 1743 | return; 1744 | } 1745 | QtConcurrent::run(this, &FusePDF::generateOutputPreview); 1746 | } 1747 | 1748 | void FusePDF::showOutputPreview(const QStringList &images) 1749 | { 1750 | if (!ui->actionOutput_preview->isChecked()) { return; } 1751 | if (images.size() < 1) { return; } 1752 | ui->preview->clear(); 1753 | ui->preview->show(); 1754 | for (int i = 0; i < images.size(); ++i) { 1755 | QListWidgetItem *item = new QListWidgetItem(QIcon(FUSEPDF_ICON_LOGO), 1756 | QString(), 1757 | ui->preview); 1758 | item->setFlags(Qt::ItemIsEnabled); 1759 | QPixmap pix(FUSEPDF_PAGE_ICON_SIZE, FUSEPDF_PAGE_ICON_SIZE); 1760 | pix.fill(QColor(Qt::transparent)); 1761 | QPainter p(&pix); 1762 | QPixmap ppix = QPixmap::fromImage(QImage(images.at(i))).scaledToHeight(FUSEPDF_PAGE_ICON_SIZE, 1763 | Qt::SmoothTransformation); 1764 | ppix = ppix.copy(0, 0, FUSEPDF_PAGE_ICON_SIZE, FUSEPDF_PAGE_ICON_SIZE); 1765 | QPainter pp(&ppix); 1766 | QPainterPath ppath; 1767 | ppath.addRect(0, 0, ppix.width(), ppix.height()); 1768 | QPen ppen(Qt::black, 2); 1769 | pp.setPen(ppen); 1770 | pp.drawPath(ppath); 1771 | p.drawPixmap((pix.width()/2)-(ppix.width()/2), 0, ppix); 1772 | item->setIcon(pix); 1773 | } 1774 | if (ui->actionOutput_preview->isChecked()) { ui->toolBox->setCurrentIndex(FUSEPDF_TOOLBOX_PREVIEW); } 1775 | } 1776 | 1777 | void FusePDF::handleOutputRemoveSelected() 1778 | { 1779 | deleteDocumentItem(); 1780 | } 1781 | 1782 | void FusePDF::handleOutputClearAll() 1783 | { 1784 | clearInput(true); 1785 | } 1786 | 1787 | void FusePDF::handleOutputAdd() 1788 | { 1789 | on_actionOpen_triggered(); 1790 | } 1791 | 1792 | 1793 | void FusePDF::on_actionDocumentation_triggered() 1794 | { 1795 | QString url = "https://fusepdf.no"; 1796 | QString readme = QString("%1/README.pdf").arg(qApp->applicationDirPath()); 1797 | if (QFile::exists(readme)) { url = readme; } 1798 | QDesktopServices::openUrl(QUrl::fromUserInput(url)); 1799 | } 1800 | 1801 | 1802 | void FusePDF::on_actionOutput_preview_triggered() 1803 | { 1804 | bool checked = ui->actionOutput_preview->isChecked(); 1805 | ui->toolBox->setItemEnabled(FUSEPDF_TOOLBOX_PREVIEW, checked); 1806 | ui->preview->clear(); 1807 | if (checked) { 1808 | ui->toolBox->setCurrentIndex(FUSEPDF_TOOLBOX_PREVIEW); 1809 | handleOutputPagesChanged(); 1810 | } else { 1811 | ui->toolBox->setCurrentIndex(FUSEPDF_TOOLBOX_OUTPUT); 1812 | } 1813 | } 1814 | 1815 | int FusePDF::pagesToExport() 1816 | { 1817 | int result = 0; 1818 | for (int i = 0; i < ui->inputs->topLevelItemCount(); ++i) { 1819 | QString filename = ui->inputs->topLevelItem(i)->data(0, FUSEPDF_PATH_ROLE).toString(); 1820 | PagesListWidget *tab = getTab(filename); 1821 | bool modified = false; 1822 | int enabledPages = tab? tab->getPagesState(true).size() : 0; 1823 | if (tab && tab->isModified() && enabledPages > 0) { 1824 | modified = true; 1825 | QVector pages = tab->getPagesState(true); 1826 | for (int i = 0; i < pages.count(); ++i) { result++; } 1827 | } 1828 | ui->inputs->topLevelItem(i)->setText(1, QString::number(enabledPages)); 1829 | if (enabledPages < 1) { continue; } 1830 | if (!modified) { 1831 | result += ui->inputs->topLevelItem(i)->text(1).toInt(); 1832 | } 1833 | } 1834 | return result; 1835 | } 1836 | 1837 | void FusePDF::getPdfInfo(const QString &filename, 1838 | const QString &checksum) 1839 | { 1840 | QString ps = FusePDF::findGhostPdfInfo(); 1841 | if (!isPDF(filename) || ps.isEmpty() || checksum.isEmpty()) { return; } 1842 | 1843 | QString command = findGhost(); 1844 | if (command.isEmpty()) { return; } 1845 | #ifdef Q_OS_WIN 1846 | command = QString("\"%1\"").arg(findGhost()); 1847 | #endif 1848 | command.append(QString(FUSEPDF_GS_INFO).arg(filename, ps)); 1849 | 1850 | FusePDF::pdfInfo pdf; 1851 | pdf.filename = filename; 1852 | pdf.checksum = checksum; 1853 | 1854 | QProcess proc; 1855 | proc.start(command); 1856 | proc.waitForFinished(); 1857 | pdf.info = proc.readAll(); 1858 | proc.close(); 1859 | 1860 | qDebug() << command; 1861 | if (!pdf.info.isEmpty()) { emit foundPdfInfo(pdf); } 1862 | } 1863 | 1864 | void FusePDF::handleFoundPdfInfo(const pdfInfo &pdf) 1865 | { 1866 | if (pdf.filename.isEmpty() || pdf.checksum.isEmpty() || pdf.info.isEmpty()) { return; } 1867 | for (int i = 0; i < ui->inputs->topLevelItemCount(); ++i) { 1868 | QString filename = ui->inputs->topLevelItem(i)->data(0, FUSEPDF_PATH_ROLE).toString(); 1869 | QString checksum = ui->inputs->topLevelItem(i)->data(0, FUSEPDF_CHECKSUM_ROLE).toString(); 1870 | if (filename == pdf.filename && checksum == pdf.checksum) { 1871 | ui->inputs->topLevelItem(i)->setToolTip(0, pdf.info); 1872 | break; 1873 | } 1874 | } 1875 | } 1876 | 1877 | const QString FusePDF::stripMarks(QString s) 1878 | { 1879 | s.remove(QRegularExpression("[" + QRegularExpression::escape("'!*,?|¡¿") + "]")); 1880 | if (s.contains(QRegularExpression("[" + QRegularExpression::escape("$/:ÅØÆåøæÀÁÄÙÛÜàáäçèéêëïñóöùûü") + "]"))) { 1881 | s.replace(QRegularExpression("[" + QRegularExpression::escape(":/") + "]"), "-"); 1882 | s.replace(QRegularExpression("[$]"), "s"); 1883 | 1884 | s.replace(QRegularExpression("[Å]"), "AA"); 1885 | s.replace(QRegularExpression("[Ø]"), "OE"); 1886 | s.replace(QRegularExpression("[Æ]"), "AE"); 1887 | 1888 | s.replace(QRegularExpression("[ÁÀ]"), "A"); 1889 | s.replace(QRegularExpression("[Ä]"), "Ae"); 1890 | s.replace(QRegularExpression("[ÜÛÙ]"), "U"); 1891 | 1892 | s.replace(QRegularExpression("[å]"), "aa"); 1893 | s.replace(QRegularExpression("[ø]"), "oe"); 1894 | s.replace(QRegularExpression("[æ]"), "ae"); 1895 | 1896 | s.replace(QRegularExpression("[áà]"), "a"); 1897 | s.replace(QRegularExpression("[ä]"), "ae"); 1898 | s.replace(QRegularExpression("[ç]"), "c"); 1899 | s.replace(QRegularExpression("[ëêéè]"), "e"); 1900 | s.replace(QRegularExpression("[ï]"), "i"); 1901 | s.replace(QRegularExpression("[ñ]"), "n"); 1902 | s.replace(QRegularExpression("[óö]"), "o"); 1903 | s.replace(QRegularExpression("[ûù]"), "u"); 1904 | s.replace(QRegularExpression("[ü]"), "ue"); 1905 | } 1906 | return s; 1907 | } 1908 | 1909 | const QString FusePDF::getCacheSize() 1910 | { 1911 | QString cachePath = getCachePath(); 1912 | if (QFile::exists(cachePath)) { 1913 | QDirIterator it (cachePath, QDirIterator::Subdirectories); 1914 | qint64 total = 0; 1915 | while (it.hasNext()) { 1916 | it.next(); 1917 | total += it.fileInfo().size(); 1918 | } 1919 | if (total > 0) { 1920 | QLocale locale = this->locale(); 1921 | QString value = locale.formattedDataSize(total); 1922 | return value; 1923 | } 1924 | } 1925 | return QString(); 1926 | } 1927 | 1928 | void FusePDF::on_actionClear_cache_triggered() 1929 | { 1930 | QString cachePath = getCachePath(); 1931 | QString cacheSize = getCacheSize(); 1932 | if (cacheSize.isEmpty() || cachePath.isEmpty() || !QFile::exists(cachePath)) { return; } 1933 | QString info = QString("%1 %2 %4:
%5?

%6.").arg(tr("Are you sure you want to remove"), 1934 | cacheSize, 1935 | tr("from"), 1936 | cachePath, 1937 | tr("Everything in the folder will be removed")); 1938 | int ret = QMessageBox::question(this, 1939 | tr("Clear cache?"), 1940 | info, 1941 | QMessageBox::Yes | QMessageBox::No, 1942 | QMessageBox::No); 1943 | if (ret == QMessageBox::Yes) { 1944 | QDir dir(cachePath); 1945 | dir.removeRecursively(); 1946 | getCachePath(); 1947 | } 1948 | } 1949 | 1950 | -------------------------------------------------------------------------------- /src/fusepdf.h: -------------------------------------------------------------------------------- 1 | /* 2 | # 3 | # FusePDF - https://fusepdf.no 4 | # 5 | # Copyright (c) 2021, 2022 NettStudio AS . 6 | # All rights reserved. 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 3 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see 20 | # 21 | */ 22 | 23 | #ifndef FUSEPDF_H 24 | #define FUSEPDF_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | #include 60 | #include 61 | #include 62 | #include 63 | #include 64 | #include 65 | #include 66 | #include 67 | #include 68 | 69 | #define FUSEPDF_SITE_URL "https://fusepdf.no" 70 | #define FUSEPDF_RELEASES_URL "https://github.com/nettstudio/fusepdf/releases" 71 | #define FUSEPDF_ISSUE_URL "https://github.com/nettstudio/fusepdf/issues" 72 | #define FUSEPDF_GS_URL "https://www.ghostscript.com/download/gsdnld.html" 73 | #define FUSEPDF_GS_MAC_URL "https://pages.uoregon.edu/koch/" 74 | #define FUSEPDF_GS_MACPORTS_URL "https://ports.macports.org/port/ghostscript/" 75 | #define FUSEPDF_GS_HOMEBREW_URL "https://formulae.brew.sh/formula/ghostscript" 76 | 77 | #define FUSEPDF_TOOLBOX_PREVIEW 0 78 | #define FUSEPDF_TOOLBOX_OUTPUT 1 79 | 80 | #define FUSEPDF_PATH_ROLE Qt::UserRole + 1 81 | #define FUSEPDF_PAGES_ROLE Qt::UserRole + 2 82 | #define FUSEPDF_PAGE_ROLE Qt::UserRole + 3 83 | #define FUSEPDF_SELECTED_ROLE Qt::UserRole + 4 84 | #define FUSEPDF_CHECKSUM_ROLE Qt::UserRole + 5 85 | #define FUSEPDF_IMAGE_TYPE_ROLE Qt::UserRole + 6 86 | #define FUSEPDF_IMAGE_RES_ROLE Qt::UserRole + 7 87 | #define FUSEPDF_CHECKED_ROLE Qt::UserRole + 8 88 | #define FUSEPDF_PDFA_ROLE Qt::userRole + 9 89 | 90 | #define FUSEPDF_PAGE_ICON_SIZE 470 91 | #define FUSEPDF_ICON_DEFAULT_SIZE 22 92 | 93 | #define FUSEPDF_CACHE_JPEG "%1/%2-%3.jpg" 94 | #define FUSEPDF_CACHE_PDF "%1/%2-%3.pdf" 95 | 96 | #define FUSEPDF_ICON_MAIN ":/assets/fusepdf-document.png" 97 | #define FUSEPDF_ICON_DOC ":/assets/document.png" 98 | #define FUSEPDF_ICON_LOGO ":/assets/fusepdf.png" 99 | #define FUSEPDF_ICON_CLEAR ":/assets/fusepdf-clear.png" 100 | #define FUSEPDF_ICON_VALID ":/assets/fusepdf-valid.png" 101 | #define FUSEPDF_ICON_DENIED ":/assets/fusepdf-denied.png" 102 | #define FUSEPDF_ICON_GOFIRST ":/assets/fusepdf-gofirst.png" 103 | #define FUSEPDF_ICON_OPEN ":/assets/fusepdf-open.png" 104 | #define FUSEPDF_ICON_SAVE ":/assets/fusepdf-save.png" 105 | #define FUSEPDF_ICON_QUIT ":/assets/fusepdf-quit.png" 106 | 107 | #define HICOLOR_ICON_DOC "document" 108 | #define HICOLOR_ICON_CLEAR "edit-clear" 109 | #define HICOLOR_ICON_VALID "dialog-apply" 110 | #define HICOLOR_ICON_DENIED "dialog-cancel" 111 | #define HICOLOR_ICON_GOFIRST "go-first" 112 | #define HICOLOR_ICON_OPEN "document-open" 113 | #define HICOLOR_ICON_SAVE "document-save" 114 | #define HICOLOR_ICON_QUIT "appliction-exit" 115 | 116 | #define FUSEPDF_GS_PREVIEW " -q -sDEVICE=jpeg -o \"%2\" -dFirstPage=%3 -dLastPage=%3 -dJPEGQ=%4 -r72x72 \"%1\"" 117 | #define FUSEPDF_GS_EXPORT " -q -sDEVICE=%4 -o \"%2\" -dFirstPage=%3 -dLastPage=%3 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r%5x%5 \"%1\"" 118 | #define FUSEPDF_GS_COUNT " -q -dNODISPLAY -dNOSAFER -c \"/pdffile (%1) (r) file runpdfbegin (PageCount: ) print pdfpagecount = quit\"" 119 | #define FUSEPDF_GS_EXTRACT " -q -dNOPAUSE -dBATCH -sOutputFile=\"%2\" -dFirstPage=%3 -dLastPage=%3 -sDEVICE=pdfwrite \"%1\"" 120 | #define FUSEPDF_GS_INFO " -q -dNODISPLAY -dNOSAFER -sFile=\"%1\" -dDumpMediaSizes=false -dDumpFontsUsed=false \"%2\"" 121 | 122 | enum exportImageType { 123 | exportImageTypeUndefined, 124 | exportTiffTypeGray, 125 | exportTiffTypeRGB12, 126 | exportTiffTypeRGB24, 127 | exportTiffTypeRGB48, 128 | exportTiffTypeCMYK32, 129 | exportTiffTypeCMYK64, 130 | exportPNGTypeGray, 131 | exportPNGType16 132 | }; 133 | 134 | class ExportImageDialog : public QDialog 135 | { 136 | Q_OBJECT 137 | 138 | public: 139 | ExportImageDialog(QWidget *parent = nullptr, 140 | Qt::WindowFlags f = Qt::WindowFlags(), 141 | QString suffix = QString()); 142 | int getImageType(); 143 | int getImageRes(); 144 | 145 | private slots: 146 | void handleButtonCancel(); 147 | void handleButtonOk(); 148 | 149 | private: 150 | QComboBox *_type; 151 | QComboBox *_res; 152 | }; 153 | 154 | class PageDelegate : public QStyledItemDelegate 155 | { 156 | Q_OBJECT 157 | 158 | public: 159 | using QStyledItemDelegate::QStyledItemDelegate; 160 | 161 | void paint(QPainter *painter, 162 | const QStyleOptionViewItem &option, 163 | const QModelIndex &index) const override 164 | { 165 | QStyledItemDelegate::paint(painter, option, index); 166 | painter->save(); 167 | 168 | int dim = FUSEPDF_ICON_DEFAULT_SIZE; 169 | int x = option.rect.x() + ((option.rect.width()/2) - (dim/2)); 170 | int y = option.rect.y() + (option.rect.height() - dim) - (dim/2); 171 | 172 | if (index.data(FUSEPDF_CHECKED_ROLE).isValid()) { 173 | QPixmap pix; 174 | pix.load(index.data(FUSEPDF_CHECKED_ROLE).toBool()? FUSEPDF_ICON_VALID : FUSEPDF_ICON_DENIED); 175 | painter->drawPixmap(QRect(x, y, dim, dim), pix); 176 | } 177 | 178 | painter->restore(); 179 | } 180 | }; 181 | 182 | class PagesListWidget : public QListWidget 183 | { 184 | Q_OBJECT 185 | 186 | public: 187 | PagesListWidget(QWidget *parent = nullptr, 188 | const QString &filename = QString(), 189 | const QString &checksum = QString(), 190 | int pages = 0); 191 | const QString getFilename() { return _filename; } 192 | const QString getChecksum() { return _checksum; } 193 | int getPageCount() { return _pages; } 194 | bool isModified(); 195 | QVector getPagesState(bool state); 196 | 197 | signals: 198 | void requestExportPage(const QString &filename, 199 | int page); 200 | void requestExportPages(const QString &filename, 201 | QVector pages); 202 | void changed(); 203 | 204 | public slots: 205 | void setPageIcon(const QString &filename, 206 | const QString &checksum, 207 | const QString &image, 208 | int page); 209 | 210 | private slots: 211 | void handleItemClicked(QListWidgetItem *item); 212 | void handleContextMenu(QPoint pos); 213 | void selectAllPages(); 214 | void selectNoPages(); 215 | void setCheckedState(bool state); 216 | void exportSelectedPage(); 217 | void exportSelectedPages(); 218 | 219 | private: 220 | QString _filename; 221 | QString _checksum; 222 | int _pages; 223 | }; 224 | 225 | class FilesTreeWidget : public QTreeWidget 226 | { 227 | Q_OBJECT 228 | 229 | public: 230 | FilesTreeWidget(QWidget *parent = nullptr); 231 | 232 | signals: 233 | void foundPDF(const QList &urls); 234 | void changed(); 235 | void removeSelected(); 236 | void clearAll(); 237 | void add(); 238 | 239 | private slots: 240 | void handleContextMenu(QPoint pos); 241 | void handleRemoveSelectedAction(); 242 | void handleClearAllAction(); 243 | void handleAddAction(); 244 | void delayedChanged(); 245 | 246 | protected: 247 | void dragEnterEvent(QDragEnterEvent *e) { e->acceptProposedAction(); } 248 | void dropEvent(QDropEvent *e); 249 | }; 250 | 251 | QT_BEGIN_NAMESPACE 252 | namespace Ui { class FusePDF; } 253 | QT_END_NAMESPACE 254 | 255 | class FusePDF : public QMainWindow 256 | { 257 | Q_OBJECT 258 | 259 | public: 260 | struct pdfInfo { 261 | QString filename; 262 | QString checksum; 263 | QString info; 264 | }; 265 | 266 | FusePDF(QWidget *parent = nullptr); 267 | ~FusePDF(); 268 | 269 | signals: 270 | void foundPagePreview(const QString &filename, 271 | const QString &checksum, 272 | const QString &image, 273 | int page); 274 | void commandReady(const QString &filename, 275 | const QString &command); 276 | void statusMessage(const QString &message, 277 | int timeout); 278 | void exportDone(const QString &path); 279 | void generatedOutputPreview(const QStringList &images); 280 | void foundPdfInfo(const FusePDF::pdfInfo &pdf); 281 | 282 | private slots: 283 | void on_actionOpen_triggered(); 284 | void on_actionSave_triggered(); 285 | void on_actionQuit_triggered(); 286 | void on_actionAbout_triggered(); 287 | void prepCommand(const QString &filename); 288 | const QString makeCommand(const QString &filename, 289 | int pdfa = 0); 290 | void runCommand(const QString &filename, 291 | const QString &command); 292 | void commandStarted(); 293 | void commandFinished(int exitCode); 294 | void populateUI(); 295 | void loadSettings(); 296 | void saveSettings(); 297 | void handleProcOutput(); 298 | void clearInput(bool askFirst = false); 299 | static const QString findGhost(bool pathOnly = false); 300 | static const QString findGhostPdfInfo(); 301 | static const QString findGhostPdfa(const QString &title = QString()); 302 | void on_actionShow_log_triggered(); 303 | void on_actionAbout_Qt_triggered(); 304 | void handleFoundPDF(const QList &urls); 305 | void on_inputs_itemDoubleClicked(QTreeWidgetItem *item, 306 | int column); 307 | void on_actionAuto_Sort_triggered(); 308 | bool hasFile(const QString &file); 309 | void loadOptions(); 310 | void saveOptions(); 311 | bool isNewVersion(); 312 | bool missingGhost(); 313 | void handleProcessError(QProcess::ProcessError error); 314 | void deleteDocumentItem(); 315 | QByteArray toUtf16Hex(QString str); 316 | int getPageCount(const QString &filename); 317 | static bool isFileType(const QString &filename, 318 | const QString &mime, 319 | bool startsWith = false); 320 | static bool isPDF(const QString &filename); 321 | static bool isJPG(const QString &filename); 322 | static bool isTIFF(const QString &filename); 323 | static bool isPNG(const QString &filename); 324 | static bool isImage(const QString &filename); 325 | static QString ghostImageFormat(int type); 326 | static const QString getCachePath(); 327 | PagesListWidget* getTab(const QString &filename); 328 | bool hasTab(const QString &filename); 329 | int getTabIndex(const QString &filename); 330 | const QString getPagePreview(const QString &filename, 331 | const QString &checksum, 332 | int page, 333 | int quality = 90); 334 | void getPagePreviews(const QString &filename, 335 | const QString &checksum, 336 | int pages); 337 | const QString getChecksum(const QString &filename); 338 | const QString extractPDF(const QString &filename, 339 | const QString &checksum, 340 | int page, 341 | bool force = true); 342 | void showProgress(bool progress); 343 | void on_actionOpen_cache_folder_triggered(); 344 | void on_actionShow_tooltips_triggered(); 345 | void showTooltips(bool show); 346 | void on_actionCheck_for_updates_triggered(); 347 | void on_actionReport_issue_triggered(); 348 | bool exportImage(const QString &filename, 349 | const QString &image, 350 | int page, 351 | int type, 352 | int res, 353 | int alpha = 4); 354 | void handleExport(const QString &filename, 355 | int page); 356 | void handleExports(const QString &filename, 357 | QVector pages); 358 | void doExport(const QString &filename, 359 | const QString &image, 360 | QVector pages, 361 | int type, 362 | int res); 363 | void handleExportDone(const QString &path); 364 | void on_preset_currentIndexChanged(int index); 365 | void on_compat_currentIndexChanged(int index); 366 | void on_metaTitle_textChanged(const QString &arg1); 367 | void on_metaSubject_textChanged(const QString &arg1); 368 | void on_metaAuthor_textChanged(const QString &arg1); 369 | void on_tabs_currentChanged(int index); 370 | void handleTabButtonClicked(bool checked); 371 | bool hasDarkMode(); 372 | void generateOutputPreview(); 373 | void handleOutputPagesChanged(); 374 | void showOutputPreview(const QStringList &images); 375 | void handleOutputRemoveSelected(); 376 | void handleOutputClearAll(); 377 | void handleOutputAdd(); 378 | void on_actionDocumentation_triggered(); 379 | void on_actionOutput_preview_triggered(); 380 | int pagesToExport(); 381 | void getPdfInfo(const QString &filename, 382 | const QString &checksum); 383 | void handleFoundPdfInfo(const FusePDF::pdfInfo &pdf); 384 | static const QString stripMarks(QString s); 385 | const QString getCacheSize(); 386 | void on_actionClear_cache_triggered(); 387 | 388 | private: 389 | Ui::FusePDF *ui; 390 | QString _output; 391 | QString _lastSaveDir; 392 | QString _lastLoadDir; 393 | QString _lastExportDir; 394 | QProcess *_proc; 395 | QPushButton *_tabButton; 396 | }; 397 | #endif // FUSEPDF_H 398 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # 3 | # FusePDF - https://fusepdf.no 4 | # 5 | # Copyright (c) 2021, 2022 NettStudio AS . 6 | # All rights reserved. 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 3 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see 20 | # 21 | */ 22 | 23 | #include "fusepdf.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | int main(int argc, char *argv[]) 31 | { 32 | QApplication a(argc, argv); 33 | QApplication::setApplicationName("FusePDF"); 34 | QApplication::setApplicationDisplayName("FusePDF"); 35 | QApplication::setApplicationVersion(VERSION_APP); 36 | QApplication::setOrganizationName("NettStudio AS"); 37 | QApplication::setOrganizationDomain("nettstudio.no"); 38 | 39 | #ifdef FORCE_NORWEGIAN 40 | QLocale curLocale(QLocale("no")); 41 | QLocale::setDefault(curLocale); 42 | #endif 43 | 44 | QTranslator i18n; 45 | if (i18n.load(QLocale(), 46 | QLatin1String("fusepdf"), 47 | QLatin1String("_"), 48 | QLatin1String(":/i18n"))) { a.installTranslator(&i18n); } 49 | #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) 50 | qDebug() << "Locale?" << QLocale().name() << i18n.filePath(); 51 | #endif 52 | 53 | FusePDF w; 54 | w.show(); 55 | return a.exec(); 56 | } 57 | -------------------------------------------------------------------------------- /tools/header.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: | 3 | ![](assets/hicolor/256x256/apps/fusepdf.png){width=2.5in} 4 | FusePDF 2.3.0 5 | author: NettStudio AS 6 | date: 'April 7, 2022' 7 | mainfont: DejaVuSans.ttf 8 | fontsize: 12pt 9 | --- 10 | -------------------------------------------------------------------------------- /tools/header.tex: -------------------------------------------------------------------------------- 1 | \usepackage{sectsty} 2 | \sectionfont{\clearpage} 3 | \usepackage{fancyhdr} 4 | \pagestyle{fancy} 5 | \fancyhead[CO,CE]{FusePDF} 6 | \fancyfoot[CO,CE]{FusePDF} 7 | \fancyfoot[LE,RO]{\thepage} 8 | -------------------------------------------------------------------------------- /tools/md2pdf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PLANG=${3:-en} 4 | ./tools/pandoc "$1" \ 5 | --include-in-header tools/header.tex \ 6 | -V linkcolor:blue \ 7 | -V geometry:a4paper \ 8 | -V geometry:margin=2cm \ 9 | -V lang=$PLANG \ 10 | --pdf-engine=xelatex \ 11 | --toc \ 12 | -o "$2" 13 | -------------------------------------------------------------------------------- /tools/mkdoc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Make FusePDF docs 4 | # 5 | 6 | # 7 | # sudo apt install texlive-xetex 8 | # 9 | # Download pandoc and copy 'pandoc' binary to this folder. 10 | # https://github.com/jgm/pandoc/releases/download/2.7.2/pandoc-2.7.2-linux.tar.gz 11 | # 12 | 13 | cat tools/header.md > tmp.md 14 | cat docs/index.md >> tmp.md 15 | 16 | echo "## GNU General Public License v3.0" >> tmp.md 17 | echo "" >> tmp.md 18 | cat COPYING >> tmp.md 19 | 20 | ./tools/md2pdf.sh tmp.md docs/README.pdf 21 | 22 | rm tmp.md 23 | --------------------------------------------------------------------------------