Git Product home page Git Product logo

craft-pdf-transform's Introduction

πŸ‘‹

Hi. I'm Jason, but most people call me Mayo, based in Manchester. I've been a self taught developer for around 15 years, but with a traditional graphic design background. Right now, I'm the Co-founder of MadeByShape, where I am the lead developer and work with global brands such as BBC, BlackBerry and 20th Century Fox right through to small-medium start ups.

On the side I'm a digital product developer working on my own ventures, as well as a Craft CMS Developer.

Working on πŸ‘¨β€πŸ’»

  • Every Creative ~ Hiring platform built specifically for creative studios/agencies & products πŸš€
  • Tap Tourist ~ A little guide to finding the best craft beer spots in and around Manchester 🍺

Stack πŸ€“

Currently using Craft CMS, Tailwind CSS, VueJS, AlpineJS, Netlify + DigitalOcean.

Writing πŸ“

I try to write every so often on various topics, have a read.

craft-pdf-transform's People

Contributors

bymayo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

craft-pdf-transform's Issues

Craft 3 Error: file_get_contents: Failed to open stream: No such file or directory

Upon updating to 1.0.8, we seem to be getting issues both uploading PDFs and rendering them using the new render function.

Uploading PDFs to any volume gives the following error
image

Rendering a PDF that has been uploaded (despite the previous error) shows the following error
file_get_contents(/files/brochures/Diversity-and-Inclusion-Policy.pdf): Failed to open stream: No such file or directory

Rendering a PDF with an already-created transform appears to work correctly.

We did not see these issues with our previous version (1.0.6), but we love the new render function as we're able to pass these images directly through imageOptimize to help page performance (so thanks for that!)

I've checked and our PDF Transform is set to use the same Thumbnails volume as it was previously using. This volume is set up with the @webroot keyword to ensure the PDF paths are found correctly. It's almost like the new update is unable to find the PDF despite it living at the path in question.

Any help or guidance here would be much appreciated. We have a site launch scheduled tomorrow and only noticed this lingering issue this morning.

Thanks in advance!

Craft v4 support

Hi, Is this plugin going to be upgraded to support Craft V4? Any timeline for this?
Thanks in advance.

Does not work with Amazon S3

I know the Readme says it has only been tested locally. I just wanted to share the error stack trace I received when trying with S3 as I thought it might be of some help for future development.

Getting unknown property: craft\awss3\Volume::path in /home/forge/example.com/vendor/yiisoft/yii2/base/Component.php:154

#0 /home/forge/example.com/vendor/bymayo/pdf-transform/src/services/PdfTransformService.php(66): yii\base\Component->__get('path')
#1 /home/forge/example.com/vendor/bymayo/pdf-transform/src/services/PdfTransformService.php(80): bymayo\pdftransform\services\PdfTransformService->getImagePath(Object(craft\elements\Asset), 'path')
#2 /home/forge/example.com/vendor/bymayo/pdf-transform/src/variables/PdfTransformVariable.php(31): bymayo\pdftransform\services\PdfTransformService->url(Object(craft\elements\Asset))
#3 /home/forge/example.com/vendor/twig/twig/lib/Twig/Extension/Core.php(1626): bymayo\pdftransform\variables\PdfTransformVariable->url(Object(craft\elements\Asset))
#4 /home/forge/example.com/vendor/craftcms/cms/src/helpers/Template.php(73): twig_get_attribute(Object(craft\web\twig\Environment), Object(Twig_Source), Object(bymayo\pdftransform\variables\PdfTransformVariable), 'url', Array, 'method', false, false)
#5 /home/forge/example.com/storage/runtime/compiled_templates/2b/2badab135d869102039d87425f0ab544d5ed8ceca3e20a24042ca872a30ad2f7.php(41): craft\helpers\Template::attribute(Object(craft\web\twig\Environment), Object(Twig_Source), Object(bymayo\pdftransform\variables\PdfTransformVariable), 'url', Array, 'method')

Versions:

Craft v3.0.26.1
PDF Transform v1.0.2
Amazon S3 v1.0.8

[Feature Request] Ability to specify a subfolder for the generated PDFs

Right now you can select a volume but it puts the PDFs in the root of the volume, which can get messy, especially if everything else is neatly organized in folders. I would like to be able to specify a subfolder path to store all the generated PDFs.

I would try my hand at a PR if you think this is a good idea.

need help to install ghostscript

when i use your library and installed imagick
before install ghostscript i get this error:
PDFDelegateFailed `The system cannot find the file specified. ' @ error/pdf.c/ReadPDFImage/794f
but when i install ghostscript 64 bit chorome says:
This site can’t be reachedThe connection was reset.
Try:

Checking the connection
Checking the proxy and the firewall
Running Windows Network Diagnostics
ERR_CONNECTION_RESET
!!!!
I use windows 10 and xampp apache. after install gostscript

in your ducument there is part " Issues regarding Ghostscript" but it is for nginx
what should i do in apache that have not php-fpm.conf file

from command line or from exec by php this command:
magick -density 1200 c:/a/a.pf c:/a/a.jpg
work currectly . but by imagick class or your library not work and when run url google chorom say : site cant be reachabed .....

Fix Composer 2 compatibility

When installing this plugin with Composer 1, the following deprecation notice is output:

Deprecation Notice: Class bymayo\pdftransform\assetbundles\PdfTransform\PdfTransformAsset located in ./vendor/bymayo/pdf-transform/src/assetbundles/pdftransform/PdfTransformAsset.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0.

Composer 2 was released on October 24, and is now the default version that will be installed, so it’s critical that this gets resolved ASAP, or people will start getting Class not found errors.

To fix, run the following command:

> git mv src/assetbundles/pdftransform src/assetbundles/PdfTransform

Then commit your change and tag a new release.

(Note that you must use the git mv command, as Git tends to not notice case-sensitive file renames otherwise.)

Works locally but not on my staging server

The plugin works great on my local site but I get messages saying "Server error" when I upload a PDF on the stagings site and no PDF image is created.

The site is using Craft 4 with PHP 8.0 and imagick is enabled.

The log has this info but I can't work out what's wrong and the hosting provider has passed the buck:

2022-10-21 11:25:19 [web.ERROR] [Error] Call to a member function getFs() on null {"trace":["#0 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/bymayo/pdf-transform/src/services/PdfTransformService.php(76): bymayo\\pdftransform\\services\\PdfTransformService->getImageFs()","#1 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/bymayo/pdf-transform/src/services/PdfTransformService.php(90): bymayo\\pdftransform\\services\\PdfTransformService->getImagePath()","#2 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/bymayo/pdf-transform/src/variables/PdfTransformVariable.php(31): bymayo\\pdftransform\\services\\PdfTransformService->url()","#3 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Extension/CoreExtension.php(1607): bymayo\\pdftransform\\variables\\PdfTransformVariable->url()","#4 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/craftcms/cms/src/helpers/Template.php(101): twig_get_attribute()","#5 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/storage/runtime/compiled_templates/c4/c4ac190651f9d17a6a43b632147b0259.php(39): craft\\helpers\\Template::attribute()","#6 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(394): __TwigTemplate_c25395822ed239b688190dbfc4ed3ed8->doDisplay()","#7 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(367): Twig\\Template->displayWithErrorHandling()","#8 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/storage/runtime/compiled_templates/29/296f0a121c9e78448826b9bc9d9a480c.php(109): Twig\\Template->display()","#9 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(394): __TwigTemplate_2765f3d79697d75dc0b7947e20bff4aa->doDisplay()","#10 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(367): Twig\\Template->displayWithErrorHandling()","#11 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/storage/runtime/compiled_templates/55/555cb5e54de9ff68ab15d5b71022ec0c.php(518): Twig\\Template->display()","#12 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(171): __TwigTemplate_52ca98011db850df96f99a6e81a476ef->block_body()","#13 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/storage/runtime/compiled_templates/5d/5dcaa8bd50cdf38b694fdc0605ea58ac.php(77): Twig\\Template->displayBlock()","#14 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(171): __TwigTemplate_4eb728540a4f60db495bce06b137c3bd->block_content()","#15 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/storage/runtime/compiled_templates/50/50806b3e6add389722d58fb5d86b20b8.php(113): Twig\\Template->displayBlock()","#16 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(394): __TwigTemplate_6bc90a4b84db3ada443c1f0b49474a17->doDisplay()","#17 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(367): Twig\\Template->displayWithErrorHandling()","#18 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/storage/runtime/compiled_templates/5d/5dcaa8bd50cdf38b694fdc0605ea58ac.php(50): Twig\\Template->display()","#19 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(394): __TwigTemplate_4eb728540a4f60db495bce06b137c3bd->doDisplay()","#20 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(367): Twig\\Template->displayWithErrorHandling()","#21 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/storage/runtime/compiled_templates/55/555cb5e54de9ff68ab15d5b71022ec0c.php(124): Twig\\Template->display()","#22 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(394): __TwigTemplate_52ca98011db850df96f99a6e81a476ef->doDisplay()","#23 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(367): Twig\\Template->displayWithErrorHandling()","#24 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/TemplateWrapper.php(47): Twig\\Template->display()","#25 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/storage/runtime/compiled_templates/f6/f61df7fc18351a7dda5bd2fca283748a.php(38): Twig\\TemplateWrapper->display()","#26 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(394): __TwigTemplate_b560aeecd2b2e702870bf71cd9bc7e79->doDisplay()","#27 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(367): Twig\\Template->displayWithErrorHandling()","#28 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(379): Twig\\Template->display()","#29 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/TemplateWrapper.php(40): Twig\\Template->render()","#30 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Environment.php(277): Twig\\TemplateWrapper->render()","#31 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/craftcms/cms/src/web/View.php(428): Twig\\Environment->render()","#32 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/craftcms/cms/src/web/View.php(481): craft\\web\\View->renderTemplate()","#33 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/craftcms/cms/src/web/TemplateResponseFormatter.php(56): craft\\web\\View->renderPageTemplate()","#34 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/yiisoft/yii2/web/Response.php(1095): craft\\web\\TemplateResponseFormatter->format()","#35 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/craftcms/cms/src/web/Response.php(286): yii\\web\\Response->prepare()","#36 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/yiisoft/yii2/web/Response.php(339): craft\\web\\Response->prepare()","#37 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/yiisoft/yii2/base/Application.php(390): yii\\web\\Response->send()","#38 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/web/index.php(26): yii\\base\\Application->run()","#39 {main}"],"memory":7324112,"exception":"[object] (Error(code: 0): Call to a member function getFs() on null at /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/bymayo/pdf-transform/src/services/PdfTransformService.php:69)"} 

?

?

PHP 8.0 compatibility?

Love this plugin, but running into a problem trying to push it up to live on Fortrabbit.

The dependency spatie/pdf-to-image ^1,8,2 doesn't support PHP 8.0.

spatie/pdf-to-image 2.1.0 does.

How can I update the requirement in this plugin's composer.json to fetch the version my host can use?

upload error with asset field

When using an asset field to upload a PDF and clicking on "upload asset" (selecting asset to upload in a dialog box), an error will occur during the transform of the pdf file. It only occurs when uploading though the dialog box. However, If I drag a PDF file into the field it uploads and transforms the image properly.

Here is the error from the weblog:

2023-07-20 07:54:48 [web.ERROR] [ImagickException] improper image header `/home/forge/dev.santiccioli.com/storage/runtime/temp/2802430.png' @ error/png.c/ReadPNGImage/4092 {"trace":["#0 /home/forge/dev.santiccioli.com/vendor/spatie/pdf-to-image/src/Pdf.php(42): Imagick->pingImage()","#1 /home/forge/dev.santiccioli.com/vendor/bymayo/pdf-transform/src/services/PdfTransformService.php(117): Spatie\\PdfToImage\\Pdf->__construct()"

I have worked around this problem by including the previous transformPdfsOnUpload functionality that was available in version for craft 3. When I turn off transformPdfsOnUpload, there is no error when clicking on "upload asset" button.

Failed to instantiate component or class "bymayo\pdftransform\assetbundles\pdftransform\PdfTransformAsset".

After installing the plugin, I get an error when trying to go to plugin settings "admin/settings/plugins/pdf-transform"

Invalid Configuration – yii\base\InvalidConfigException
Failed to instantiate component or class "bymayo\pdftransform\assetbundles\pdftransform\PdfTransformAsset".
↡
Caused by: ReflectionException
Class bymayo\pdftransform\assetbundles\pdftransform\PdfTransformAsset does not exist

in /app/vendor/yiisoft/yii2/di/Container.php at line 447

`

1. in /app/vendor/yiisoft/yii2/di/Container.php at line 449
440441442443444445446447448449450451452453454455456457458

    {
        if (isset($this->_reflections[$class])) {
            return [$this->_reflections[$class], $this->_dependencies[$class]];
        }
 
        $dependencies = [];
        try {
            $reflection = new ReflectionClass($class);
        } catch (\ReflectionException $e) {
            throw new InvalidConfigException('Failed to instantiate component or class "' . $class . '".', 0, $e);
        }
 
        $constructor = $reflection->getConstructor();
        if ($constructor !== null) {
            foreach ($constructor->getParameters() as $param) {
                if (version_compare(PHP_VERSION, '5.6.0', '>=') && $param->isVariadic()) {
                    break;
                } elseif ($param->isDefaultValueAvailable()) {
                    $dependencies[] = $param->getDefaultValue();

2. in /app/vendor/yiisoft/yii2/di/Container.php at line 374 – yii\di\Container::getDependencies('bymayo\pdftransform\assetbundles...')
3. in /app/vendor/yiisoft/yii2/di/Container.php at line 159 – yii\di\Container::build('bymayo\pdftransform\assetbundles...', [], [])
4. in /app/vendor/yiisoft/yii2/BaseYii.php at line 365 – yii\di\Container::get('bymayo\pdftransform\assetbundles...', [], [])
5. in /app/vendor/yiisoft/yii2/web/AssetManager.php at line 264 – yii\BaseYii::createObject([])
6. in /app/vendor/yiisoft/yii2/web/AssetManager.php at line 237 – yii\web\AssetManager::loadBundle('bymayo\pdftransform\assetbundles...', ['class' => 'bymayo\pdftransform\assetbundles...'], true)
7. in /app/vendor/yiisoft/yii2/web/View.php at line 287 – yii\web\AssetManager::getBundle('bymayo\pdftransform\assetbundles...')
8. in /app/vendor/twig/twig/src/Extension/CoreExtension.php at line 1499 – yii\web\View::registerAssetBundle('bymayo\pdftransform\assetbundles...')
9. in /app/vendor/craftcms/cms/src/helpers/Template.php at line 96 – twig_get_attribute(craft\web\twig\Environment, Twig\Source, craft\web\View, 'registerAssetBundle', ...)
90919293949596979899100101102

        // Add deprecated support for the old DateTime methods
        if ($object instanceof \DateTime && ($value = self::_dateTimeAttribute($object, $item, $type)) !== false) {
            return $value;
        }
 
        try {
            return \twig_get_attribute($env, $source, $object, $item, $arguments, $type, $isDefinedTest, $ignoreStrictCheck);
        } catch (UnknownMethodException $e) {
            // Copy twig_get_attribute()'s BadMethodCallException handling
            if ($ignoreStrictCheck || !$env->isStrictVariables()) {
                return null;
            }
            throw new RuntimeError($e->getMessage(), -1, $source);

10. in /app/storage/runtime/compiled_templates/d4/d4542e43416fb16da2f4a5aae9b15fa8d570d918d33d506bfb1431d9a90a5fef.php at line 43 – craft\helpers\Template::attribute(craft\web\twig\Environment, Twig\Source, craft\web\View, 'registerAssetBundle', ...)
11. in /app/vendor/twig/twig/src/Template.php at line 407 – __TwigTemplate_0acc6f79036585c3773b7fed9873488639fa1818709f338e7818fa5119b120e6::doDisplay(['settings' => bymayo\pdftransform\models\Settings, 'volumes' => [['label' => 'Uploads', 'value' => '1'], ['label' => 'User Photos', 'value' => '2'], ['label' => 'Content images', 'value' => '3']], 'view' => craft\web\View, 'devMode' => true, ...], [])
12. in /app/vendor/twig/twig/src/Template.php at line 380 – Twig\Template::displayWithErrorHandling(['settings' => bymayo\pdftransform\models\Settings, 'volumes' => [['label' => 'Uploads', 'value' => '1'], ['label' => 'User Photos', 'value' => '2'], ['label' => 'Content images', 'value' => '3']], 'view' => craft\web\View, 'devMode' => true, ...], [])
13. in /app/vendor/twig/twig/src/Template.php at line 392 – Twig\Template::display(['settings' => bymayo\pdftransform\models\Settings, 'volumes' => [['label' => 'Uploads', 'value' => '1'], ['label' => 'User Photos', 'value' => '2'], ['label' => 'Content images', 'value' => '3']]])
14. in /app/vendor/twig/twig/src/TemplateWrapper.php at line 45 – Twig\Template::render(['settings' => bymayo\pdftransform\models\Settings, 'volumes' => [['label' => 'Uploads', 'value' => '1'], ['label' => 'User Photos', 'value' => '2'], ['label' => 'Content images', 'value' => '3']]], [])
15. in /app/vendor/twig/twig/src/Environment.php at line 318 – Twig\TemplateWrapper::render(['settings' => bymayo\pdftransform\models\Settings, 'volumes' => [['label' => 'Uploads', 'value' => '1'], ['label' => 'User Photos', 'value' => '2'], ['label' => 'Content images', 'value' => '3']]])
16. in /app/vendor/craftcms/cms/src/web/View.php at line 375 – Twig\Environment::render('pdf-transform/settings', ['settings' => bymayo\pdftransform\models\Settings, 'volumes' => [['label' => 'Uploads', 'value' => '1'], ['label' => 'User Photos', 'value' => '2'], ['label' => 'Content images', 'value' => '3']]])
369370371372373374375376377378379380381

        // Render and return
        $renderingTemplate = $this->_renderingTemplate;
        $this->_renderingTemplate = $template;
 
        $e = null;
        try {
            $output = $this->getTwig()->render($template, $variables);
        } catch (\Throwable $e) {
            // throw it later
        }
 
        $this->_renderingTemplate = $renderingTemplate;
        $this->setTemplateMode($oldTemplateMode);

17. in /app/vendor/bymayo/pdf-transform/src/PdfTransform.php at line 144 – craft\web\View::renderTemplate('pdf-transform/settings', ['settings' => bymayo\pdftransform\models\Settings, 'volumes' => [['label' => 'Uploads', 'value' => '1'], ['label' => 'User Photos', 'value' => '2'], ['label' => 'Content images', 'value' => '3']]])
138139140141142143144145146147148149

    {
 
        return Craft::$app->view->renderTemplate(
            'pdf-transform/settings',
            [
                'settings' => $this->getSettings(),
                'volumes' => PdfTransform::$plugin->pdfTransformService->getVolumeOptions()
            ]
        );
 
    }
}

18. in /app/vendor/craftcms/cms/src/base/Plugin.php at line 217 – bymayo\pdftransform\PdfTransform::settingsHtml()
211212213214215216217218219220221222223

     */
    public function getSettingsResponse()
    {
        $view = Craft::$app->getView();
        $namespace = $view->getNamespace();
        $view->setNamespace('settings');
        $settingsHtml = $this->settingsHtml();
        $view->setNamespace($namespace);
 
        /** @var Controller $controller */
        $controller = Craft::$app->controller;
 
        return $controller->renderTemplate('settings/plugins/_settings', [

19. in /app/vendor/craftcms/cms/src/controllers/PluginsController.php at line 116 – craft\base\Plugin::getSettingsResponse()
110111112113114115116117118119120121122

            $plugin === null &&
            ($plugin = Craft::$app->getPlugins()->getPlugin($handle)) === null
        ) {
            throw new NotFoundHttpException('Plugin not found');
        }
 
        return $plugin->getSettingsResponse();
    }
 
    /**
     * Enables a plugin.
     *
     * @return Response

20. craft\controllers\PluginsController::actionEditPluginSettings('pdf-transform', bymayo\pdftransform\PdfTransform)
21. in /app/vendor/yiisoft/yii2/base/InlineAction.php at line 57 – call_user_func_array([craft\controllers\PluginsController, 'actionEditPluginSettings'], ['pdf-transform', null])
22. in /app/vendor/yiisoft/yii2/base/Controller.php at line 157 – yii\base\InlineAction::runWithParams(['handle' => 'pdf-transform', 'p' => 'admin/settings/plugins/pdf-trans...'])
23. in /app/vendor/craftcms/cms/src/web/Controller.php at line 178 – yii\base\Controller::runAction('edit-plugin-settings', ['handle' => 'pdf-transform', 'p' => 'admin/settings/plugins/pdf-trans...'])
172173174175176177178179180181182183184

    /**
     * @inheritdoc
     */
    public function runAction($id, $params = [])
    {
        try {
            return parent::runAction($id, $params);
        } catch (\Throwable $e) {
            if (Craft::$app->getRequest()->getAcceptsJson()) {
                Craft::$app->getErrorHandler()->logException($e);
                if (!YII_DEBUG && !$e instanceof UserException) {
                    $message = Craft::t('app', 'A server error occurred.');
                } else {

24. in /app/vendor/yiisoft/yii2/base/Module.php at line 528 – craft\web\Controller::runAction('edit-plugin-settings', ['handle' => 'pdf-transform', 'p' => 'admin/settings/plugins/pdf-trans...'])
25. in /app/vendor/craftcms/cms/src/web/Application.php at line 291 – yii\base\Module::runAction('plugins/edit-plugin-settings', ['handle' => 'pdf-transform', 'p' => 'admin/settings/plugins/pdf-trans...'])
285286287288289290291292293294295296297

     * @param string $route
     * @param array $params
     * @return Response|null The result of the action, normalized into a Response object
     */
    public function runAction($route, $params = [])
    {
        $result = parent::runAction($route, $params);
 
        if ($result !== null) {
            if ($result instanceof Response) {
                return $result;
            }
 

26. in /app/vendor/yiisoft/yii2/web/Application.php at line 103 – craft\web\Application::runAction('plugins/edit-plugin-settings', ['handle' => 'pdf-transform', 'p' => 'admin/settings/plugins/pdf-trans...'])
27. in /app/vendor/craftcms/cms/src/web/Application.php at line 276 – yii\web\Application::handleRequest(craft\web\Request)
270271272273274275276277278279280281282

        if (($response = $this->_processActionRequest($request)) !== null) {
            return $response;
        }
 
        // If we're still here, finally let Yii do it's thing.
        try {
            return parent::handleRequest($request);
        } catch (\Throwable $e) {
            $this->_unregisterDebugModule();
            throw $e;
        }
    }
 

28. in /app/vendor/yiisoft/yii2/base/Application.php at line 386 – craft\web\Application::handleRequest(craft\web\Request)
29. in /app/web/index.php at line 23 – yii\base\Application::run()
17181920212223

    (new Dotenv\Dotenv(CRAFT_BASE_PATH))->load();
}
 
// Load and run Craft
define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production');
$app = require CRAFT_VENDOR_PATH.'/craftcms/cms/bootstrap/web.php';
$app->run();

$_GET = [
'p' => 'admin/settings/plugins/pdf-transform',
];`

new file_get_contents method means pdfs protected by basic auth can't have generated images

Getting this error when uploading a PDF. My test site is under basic auth password protection

Please allow for both path based and URL based options?

2023-04-12 11:55:52 [web.ERROR] [yii\base\ErrorException:2] file_get_contents(https://exampleredacted.com/uploads/files/Invoice_1264_2023-04-14-1.pdf): Failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorize

VolumeId given null

  {% for item in entry.attachment %}
    {% if item.extension == 'pdf' %}
      {{ craft.pdfTransform.url(item) }}
    {% endif %}
  {% endfor %}

Generated this error:

TypeError
Argument 1 passed to craft\services\Volumes::getVolumeById() must be of the type int, null given, called in /Users/myname/Source/lions-club-erding/vendor/bymayo/pdf-transform/src/services/PdfTransformService.php on line 59

Craft 3: file_get_contents() cannot be empty error - for volumes without public URLs

A website of ours has the requirement of hosting PDFs that are gated and not accessible to the public. These PDFs are housed in volumes with no public URLs, meaning they are only reachable through a serverside process.

In the CraftCMS backend, we have the "assets in this volume have public URLs" toggled off:
image

Unfortunately any new assets being uploaded to these directories are failing to generate thumbnails (either on upload, or at runtime if the "Transform on upload" setting is disabled.), with the following error:
image

PDF Thumbnails for volumes with public URLs appear to be generating without issue, and when I turn on Public URLs for this gated volume - the plugin works as intended.

My hunch is that the plugin may be looking at the public URL path to find the PDF for thumbnail generation. If this is the case, a possible fix might be modifying the logic to instead look at the required "File System Path" to locate the PDF for transformation.

Lastly I will add that we currently have 100+ gated PDFs with thumbnails (most from earlier last year) which leads me to believe this issue may be related to one of the more recent plugin updates - but I could be incorrect!

Thank you in advance for any help you can provide!

How to apply a transform?

Can you provide an example of how one would apply a standard Craft transform to the generated image in a template?

Degraded Image quality

Hi! We are using this plugin on a live site and we've had a request to look into a problem with images.

I have tracked it back to (some) of the images generated by the pdfTransform.

For example, this listing image (which looks like the pdf first page) versus the generated PDF Image
The code being used is:

{% for download in entry.downloads.all() %}
    {% if download.kind == 'pdf' %}
    {% set imageUrl = craft.pdfTransform.url(download) %}
    ...
   <img src="{{ imageUrl }}" ...
{% endif %}

and we were using the default CP properties.

I don't know how to resolve this issue, can you suggest a course of action?

Colours of generated asset are inverted

When PDF Transform generates an image of a PDF, in some cases, the colours are inverted. This only happens on production, not locally. See attachments. The white one is what it should look like, the black one is the image generated by PDF Transform. I have it set to use JPG format.

I assume this has something to do with Imagick? Is there any way around it?

Thanks!
1
2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.