xthiago / pdf-version-converter Goto Github PK
View Code? Open in Web Editor NEWPHP library for converting the version of PDF files (for compatibility purposes).
License: MIT License
PHP library for converting the version of PDF files (for compatibility purposes).
License: MIT License
PHP 5.2.1 function sys_get_temp_dir() exists to retrieve the proper temp directory for the OS.
Hi, nice to found this awesome library.
I was used this package for my project to converting a PDF file version to 1.4 if the origin file has version above 1.4. But I got wrong version, so the converting process not called.
Here the original PDF version by macOS info vs version from this library.
How can I solve this problem?
Thanks in advance
Please help , here is an PHP error , class not found ...could you please let me know where is Filesystem class inside your package. ?
This class is not found on index.php where i am using the function .
my code
<?php
// import the namespaces
use Symfony\Component\Filesystem\Filesystem,
Xthiago\PDFVersionConverter\Converter\GhostscriptConverterCommand,
Xthiago\PDFVersionConverter\Converter\GhostscriptConverter;
require_once 'Xthiago/PDFVersionConverter/GhostscriptConverterCommand.php';
require_once 'Xthiago/PDFVersionConverter/GhostscriptConverter.php';
require_once 'Xthiago/PDFVersionConverter/ConverterInterface.php';
$command = new GhostscriptConverterCommand();
$fs = new Filesystem();
$converter = new GhostscriptConverter($command, $fs);
$converter->convert('file.pdf', '1.4');
?>
Hi,
When copying the converted file via Symfony FS, here sometimes the new file is not overwritten.
I think this is the default behavior for copy function, It is described here.
https://github.com/symfony/filesystem/blob/master/Filesystem.php#L27
Just wanted to let you know.
Thank you for the useful library.
Hi
In the Xthiago\PDFVersionConverter\Converter\GhostscriptConverter class, at the 49. line, theres a typo.
Theres $this->$tmp = $tmp;
when i guess it should be $this->tmp = $tmp;
composer require xthiago/pdf-version-converter dev-master
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
Note: checking out '10bfb95366359925025501fea662d4cf4e3735f0'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
HEAD is now at 10bfb95... Merge pull request #10 from edegaudenzi/master
error: unable to create file tests/files/repo/v1.7 filename with "Sp3ci4l"; <'Ch4r5'> !£$%&()=?^[]{}è@#§.pdf (Protocol error)
fatal: Could not reset index file to revision '10bfb95366359925025501fea662d4cf4e3735f0'.
Now trying to download from dist
I convert pdf file version 1.6 to 1.4. but i found file size increase. old file size is 9.9 MB and new file size is 62.3 MB.
in GhostscriptConverterCommand.php line 39
at GhostscriptConverterCommand->run('http://192.168.10.10//storage/transcripts/H2ZEBkTp6YRpuSf7XzA1iiyjv4zuqKvXDI9Y0hdd.pdf', '/tmp/pdf_version_changer_5f81e1fbc8387.pdf', '1.4')in GhostscriptConverter.php line 66
at GhostscriptConverter->convert('http://192.168.10.10//storage/transcripts/H2ZEBkTp6YRpuSf7XzA1iiyjv4zuqKvXDI9Y0hdd.pdf', '1.4')in DocumentController.php line 34
at DocumentController->index(object(Request), object(DocumentsRepository))
at call_user_func_array(array(object(DocumentController), 'index'), array(object(Request), object(DocumentsRepository)))in Controller.php line 55
at Controller->callAction('index', array(object(Request), object(DocumentsRepository)))in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(DocumentController), 'index')in Route.php line 203
Information:
Laravel - v5.4
PHP - v7.4
Test PDF - v1.4 (secured file) / v1.2 (dummy file)
Any help/guidance to understand this issue would be great.
Hello thiago,
after I run the command (composer install), I do not have the folder "Xthiago \ PDFVersionConverter"
so I created an index.php file:
`<?php
// import the namespaces
use Xthiago\PDFVersionConverter\Guesser\RegexGuesser;
// [..]
$guesser = new RegexGuesser();
echo $guesser->guess('/path/to/my/file.pdf'); // will print something like '1.4'`
I have the following error:
Fatal error: Class 'Xthiago \ PDFVersionConverter \ Guesser \ RegexGuesser' not found in C: \ wamp \ www \ pdf-version-converter-1.0.5 \ index.php on line 6
thank you for your help
I am trying to convert version of pdf file from 1.7 to 1.4, i am getting this error: sh: 1: gs: not found\n
I have a problem while converting pdf file version. when I hit to convert it gives me this error "sh: gs: command not found". I am using the mac, I have already installed Ghostscript but still getting this error. I have type gs in my terminal it goes to GS but still getting the error.
While installing in windows 10 machine ,
I installed ghostscript and added it to PATH environment variable but still this error .
"There was an error extracting the ZIP file, it is either corrupted or using an invalid format."
heres the screenshot : https://imgur.com/a/f3vxZ
The method of invoking Ghostscript can vary on systems, e.g. Windows vs. Linux. As mentioned in the docs:
The command line to invoke Ghostscript is essentially the same on all systems, although the name of the executable program itself may differ among systems
In my situation, when using Ghostscript on Windows 7 64-bit there are two available executables:
gswin64
- opens a new type-in windowgswin64c
- runs commands in the consoleSo gswin64c
is what I want to use in combination with my PHP applications.
In Xthiago\PDFVersionConverter\Converter\GhostscriptConverterCommand
the method of invoking Ghostscript is gs
, however, when running this on my system it won't work and I get the expected error:
RuntimeException: 'gs' is not recognized as an internal or external command, operable program or batch file.
I'm guessing the quick solution is to rename the Ghostscript executable from gswin64c
to gs
, but would you consider some modifications to the pdf-version-converter package to either allow the user to modify the name of the executable (via some form of config?) or perhaps even by detecting the environment (overkill maybe?) or perhaps something simpler?
I'd be happy to submit a PR for this but would appreciate any thoughts/guidance first on how this should be dealt with even though I imagine this probably affects a small minority of users.
Hi, thanks for this package. I am having some issues installing via composer in a Laravel project (5.3) just wondering how I can fix it. Am I unable to install if Laravel is using a newer version of Syfony?
My console output:
λ composer require xthiago/pdf-version-converter dev-master
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for xthiago/pdf-version-converter dev-master -> satisfiable by xthiago/pdf-version-conver
ter[dev-master].
- Conclusion: remove symfony/process v3.1.5
- Conclusion: don't install symfony/process v3.1.5
- xthiago/pdf-version-converter dev-master requires symfony/process ~2.3 -> satisfiable by symfony/process[v2.3.
0, v2.3.1, v2.3.10, v2.3.11, v2.3.12, v2.3.13, v2.3.14, v2.3.15, v2.3.16, v2.3.17, v2.3.18, v2.3.19, v2.3.2, v2.3.20
, v2.3.21, v2.3.22, v2.3.23, v2.3.24, v2.3.25, v2.3.26, v2.3.27, v2.3.28, v2.3.29, v2.3.3, v2.3.30, v2.3.31, v2.3.32
, v2.3.33, v2.3.34, v2.3.35, v2.3.36, v2.3.37, v2.3.38, v2.3.39, v2.3.4, v2.3.40, v2.3.41, v2.3.42, v2.3.5, v2.3.6,
v2.3.7, v2.3.8, v2.3.9, v2.4.0, v2.4.1, v2.4.10, v2.4.2, v2.4.3, v2.4.4, v2.4.5, v2.4.6, v2.4.7, v2.4.8, v2.4.9, v2.
5.0, v2.5.1, v2.5.10, v2.5.11, v2.5.12, v2.5.2, v2.5.3, v2.5.4, v2.5.5, v2.5.6, v2.5.7, v2.5.8, v2.5.9, v2.6.0, v2.6
.1, v2.6.10, v2.6.11, v2.6.12, v2.6.13, v2.6.2, v2.6.3, v2.6.4, v2.6.5, v2.6.6, v2.6.7, v2.6.8, v2.6.9, v2.7.0, v2.7
.1, v2.7.10, v2.7.11, v2.7.12, v2.7.13, v2.7.14, v2.7.15, v2.7.16, v2.7.17, v2.7.18, v2.7.19, v2.7.2, v2.7.20, v2.7.
3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.10, v2.8.11, v2.8.12, v2.8.13, v2.8.2, v2.8.
3, v2.8.4, v2.8.5, v2.8.6, v2.8.7, v2.8.8, v2.8.9].
- Can only install one of: symfony/process[v2.3.0, v3.1.5].
- Can only install one of: symfony/process[v2.3.1, v3.1.5].
- Can only install one of: symfony/process[v2.3.10, v3.1.5].
- Can only install one of: symfony/process[v2.3.11, v3.1.5].
- Can only install one of: symfony/process[v2.3.12, v3.1.5].
- Can only install one of: symfony/process[v2.3.13, v3.1.5].
- Can only install one of: symfony/process[v2.3.14, v3.1.5].
- Can only install one of: symfony/process[v2.3.15, v3.1.5].
- Can only install one of: symfony/process[v2.3.16, v3.1.5].
- Can only install one of: symfony/process[v2.3.17, v3.1.5].
- Can only install one of: symfony/process[v2.3.18, v3.1.5].
- Can only install one of: symfony/process[v2.3.19, v3.1.5].
- Can only install one of: symfony/process[v2.3.2, v3.1.5].
- Can only install one of: symfony/process[v2.3.20, v3.1.5].
- Can only install one of: symfony/process[v2.3.21, v3.1.5].
- Can only install one of: symfony/process[v2.3.22, v3.1.5].
- Can only install one of: symfony/process[v2.3.23, v3.1.5].
- Can only install one of: symfony/process[v2.3.24, v3.1.5].
- Can only install one of: symfony/process[v2.3.25, v3.1.5].
- Can only install one of: symfony/process[v2.3.26, v3.1.5].
- Can only install one of: symfony/process[v2.3.27, v3.1.5].
- Can only install one of: symfony/process[v2.3.28, v3.1.5].
- Can only install one of: symfony/process[v2.3.29, v3.1.5].
- Can only install one of: symfony/process[v2.3.3, v3.1.5].
- Can only install one of: symfony/process[v2.3.30, v3.1.5].
- Can only install one of: symfony/process[v2.3.31, v3.1.5].
- Can only install one of: symfony/process[v2.3.32, v3.1.5].
- Can only install one of: symfony/process[v2.3.33, v3.1.5].
- Can only install one of: symfony/process[v2.3.34, v3.1.5].
- Can only install one of: symfony/process[v2.3.35, v3.1.5].
- Can only install one of: symfony/process[v2.3.36, v3.1.5].
- Can only install one of: symfony/process[v2.3.37, v3.1.5].
- Can only install one of: symfony/process[v2.3.38, v3.1.5].
- Can only install one of: symfony/process[v2.3.39, v3.1.5].
- Can only install one of: symfony/process[v2.3.4, v3.1.5].
- Can only install one of: symfony/process[v2.3.40, v3.1.5].
- Can only install one of: symfony/process[v2.3.41, v3.1.5].
- Can only install one of: symfony/process[v2.3.42, v3.1.5].
- Can only install one of: symfony/process[v2.3.5, v3.1.5].
- Can only install one of: symfony/process[v2.3.6, v3.1.5].
- Can only install one of: symfony/process[v2.3.7, v3.1.5].
- Can only install one of: symfony/process[v2.3.8, v3.1.5].
- Can only install one of: symfony/process[v2.3.9, v3.1.5].
- Can only install one of: symfony/process[v2.4.0, v3.1.5].
- Can only install one of: symfony/process[v2.4.1, v3.1.5].
- Can only install one of: symfony/process[v2.4.10, v3.1.5].
- Can only install one of: symfony/process[v2.4.2, v3.1.5].
- Can only install one of: symfony/process[v2.4.3, v3.1.5].
- Can only install one of: symfony/process[v2.4.4, v3.1.5].
- Can only install one of: symfony/process[v2.4.5, v3.1.5].
- Can only install one of: symfony/process[v2.4.6, v3.1.5].
- Can only install one of: symfony/process[v2.4.7, v3.1.5].
- Can only install one of: symfony/process[v2.4.8, v3.1.5].
- Can only install one of: symfony/process[v2.4.9, v3.1.5].
- Can only install one of: symfony/process[v2.5.0, v3.1.5].
- Can only install one of: symfony/process[v2.5.1, v3.1.5].
- Can only install one of: symfony/process[v2.5.10, v3.1.5].
- Can only install one of: symfony/process[v2.5.11, v3.1.5].
- Can only install one of: symfony/process[v2.5.12, v3.1.5].
- Can only install one of: symfony/process[v2.5.2, v3.1.5].
- Can only install one of: symfony/process[v2.5.3, v3.1.5].
- Can only install one of: symfony/process[v2.5.4, v3.1.5].
- Can only install one of: symfony/process[v2.5.5, v3.1.5].
- Can only install one of: symfony/process[v2.5.6, v3.1.5].
- Can only install one of: symfony/process[v2.5.7, v3.1.5].
- Can only install one of: symfony/process[v2.5.8, v3.1.5].
- Can only install one of: symfony/process[v2.5.9, v3.1.5].
- Can only install one of: symfony/process[v2.6.0, v3.1.5].
- Can only install one of: symfony/process[v2.6.1, v3.1.5].
- Can only install one of: symfony/process[v2.6.10, v3.1.5].
- Can only install one of: symfony/process[v2.6.11, v3.1.5].
- Can only install one of: symfony/process[v2.6.12, v3.1.5].
- Can only install one of: symfony/process[v2.6.13, v3.1.5].
- Can only install one of: symfony/process[v2.6.2, v3.1.5].
- Can only install one of: symfony/process[v2.6.3, v3.1.5].
- Can only install one of: symfony/process[v2.6.4, v3.1.5].
- Can only install one of: symfony/process[v2.6.5, v3.1.5].
- Can only install one of: symfony/process[v2.6.6, v3.1.5].
- Can only install one of: symfony/process[v2.6.7, v3.1.5].
- Can only install one of: symfony/process[v2.6.8, v3.1.5].
- Can only install one of: symfony/process[v2.6.9, v3.1.5].
- Can only install one of: symfony/process[v2.7.0, v3.1.5].
- Can only install one of: symfony/process[v2.7.1, v3.1.5].
- Can only install one of: symfony/process[v2.7.10, v3.1.5].
- Can only install one of: symfony/process[v2.7.11, v3.1.5].
- Can only install one of: symfony/process[v2.7.12, v3.1.5].
- Can only install one of: symfony/process[v2.7.13, v3.1.5].
- Can only install one of: symfony/process[v2.7.14, v3.1.5].
- Can only install one of: symfony/process[v2.7.15, v3.1.5].
- Can only install one of: symfony/process[v2.7.16, v3.1.5].
- Can only install one of: symfony/process[v2.7.17, v3.1.5].
- Can only install one of: symfony/process[v2.7.18, v3.1.5].
- Can only install one of: symfony/process[v2.7.19, v3.1.5].
- Can only install one of: symfony/process[v2.7.2, v3.1.5].
- Can only install one of: symfony/process[v2.7.20, v3.1.5].
- Can only install one of: symfony/process[v2.7.3, v3.1.5].
- Can only install one of: symfony/process[v2.7.4, v3.1.5].
- Can only install one of: symfony/process[v2.7.5, v3.1.5].
- Can only install one of: symfony/process[v2.7.6, v3.1.5].
- Can only install one of: symfony/process[v2.7.7, v3.1.5].
- Can only install one of: symfony/process[v2.7.8, v3.1.5].
- Can only install one of: symfony/process[v2.7.9, v3.1.5].
- Can only install one of: symfony/process[v2.8.0, v3.1.5].
- Can only install one of: symfony/process[v2.8.1, v3.1.5].
- Can only install one of: symfony/process[v2.8.10, v3.1.5].
- Can only install one of: symfony/process[v2.8.11, v3.1.5].
- Can only install one of: symfony/process[v2.8.12, v3.1.5].
- Can only install one of: symfony/process[v2.8.13, v3.1.5].
- Can only install one of: symfony/process[v2.8.2, v3.1.5].
- Can only install one of: symfony/process[v2.8.3, v3.1.5].
- Can only install one of: symfony/process[v2.8.4, v3.1.5].
- Can only install one of: symfony/process[v2.8.5, v3.1.5].
- Can only install one of: symfony/process[v2.8.6, v3.1.5].
- Can only install one of: symfony/process[v2.8.7, v3.1.5].
- Can only install one of: symfony/process[v2.8.8, v3.1.5].
- Can only install one of: symfony/process[v2.8.9, v3.1.5].
- Installation request for symfony/process (locked at v3.1.5) -> satisfiable by symfony/process[v3.1.5].
Installation failed, reverting ./composer.json to its original content.
Thanks for this library, it's working very well but facing an issue. After changing the version from 1.7 to 1.4 my 393 KB pdf size converted into 35MB. Is there any solution of this issue.
Extend timeout of \Process() for long pdf.
When you try to convert a PDF with some special chars in the filename it breaks the plugin.
hi,
i need your package for using in laravel 7. Therefore symfony/process needs be updated to version 5.
in version 5 the command needs to be given to the process() as array like described here https://symfony.com/doc/current/components/process.html#usage . i changed the run function in your class GhostscriptConverterCommand
to this:
$command = sprintf($this->baseCommand, $newVersion, $newFile);
$command_new = explode(' ',$command);
array_push($command_new,$originalFile);
$process = new Process($command_new);
$process->run();
and the $baseCommand to this
protected $baseCommand = 'gs -sDEVICE=pdfwrite -dCompatibilityLevel=%s -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -dColorConversionStrategy=/LeaveColorUnchanged -dEncodeColorImages=false -dEncodeGrayImages=false -dEncodeMonoImages=false -dDownsampleMonoImages=false -dDownsampleGrayImages=false -dDownsampleColorImages=false -dAutoFilterColorImages=false -dAutoFilterGrayImages=false -dColorImageFilter=/FlateEncode -dGrayImageFilter=/FlateEncode -sOutputFile=%s';
for my use case it's working now.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.