Jump to content

PDF Fieldtype/Inputfield


Recommended Posts

@ICF Church Hi, I'm trying to solve your issue, but I can't reproduce the error. What version of PHP are you using? During module installation there is a step where the `use` statemenents in source files under FieldtypePDF folder are prefixed with `Processwire\' namespace if PW 3.x detected. Could you please examine what's wrong? Look into this method https://github.com/uiii/ProcessWire-FieldtypePDF/blob/d11ff962d520782fa25215f5ce606886773a5a44/FieldtypePDF.module#L232. Thanks

Link to comment
Share on other sites

  • 5 months later...

@ICF Church Hi, I've released new version which should fix your problem, I know it is a little bit late but if you are still interested, you may try it.

I didn't face the error before but now, there are some misterious ways to me how PW detect module updates and sometimes detect the updated module as a new module so the `upgrade` method is not executed and the namespaces are not fixed which leads to the error mentioned by you. So I've moved the 'namespaces fix' code to the init method so it will check if the namespaces are fixed each time the module is initialized.

It may happed that you will see the 'Fieldtype 'FieldtypePDF' does not exist' when updating the module, just hit the refresh button again and you are fine.

  • Like 1
Link to comment
Share on other sites

  • 8 months later...

Hi, i use PW 3.0.123 and can't use your module

 Class 'Pagefile' not found (Zeile 39 in /kunden/310636_12107/webseiten/meab/dev/site/modules/FieldtypePDF/FieldtypePDF/PagePDF.php) 

PDF with thumbnail

FieldtypePDF

1.1.5

i install from github cause the php-files (in subfolder FieldtypePDF) were empty after regularly module installation from pw repository 

 

Edited by ThomasH
Link to comment
Share on other sites

  • 2 weeks later...

Hi @Richard Jedlička

thanks a lot for this useful modul!!
Unfortunately i am running into following issue.
When trying to upload a PDF i get this error and the upload fails.
 

Failed to read the file (in /wire/modules/Inputfield/InputfieldFile/InputfieldFile.module line 790)


I´m using PW 3.0.95 - and the FieldtypePDF 1.1.5.
PHP Version: 7.2.4
ImageMagick: I
mageMagick 6.9.4-6 Q16 i686 2016-06-03

Do you know anything about this?

Thanks!

 

Link to comment
Share on other sites

5 hours ago, itsberni said:

Failed to read the file (in /wire/modules/Inputfield/InputfieldFile/InputfieldFile.module line 790)

How did you install the module? If you copied the files manually I am guessing this is simply a file permissions issue - make sure everything has the correct owner and permissions that allow reading of the files. 

Link to comment
Share on other sites

Hi all,

tried several things.....changed the php-version on the Server (down to 7.0). Updating pw to the latest master (123). Uninstalling and installing the module again.

the result is the same.

could there be any problem with the server (mittwald) to handle pdf-files in terms of security?

any thoughts or suggestions?

 

SOLUTION:

The PHP-Version has to be 7.0.32 CGI - now it works!!

Link to comment
Share on other sites

  • 2 months later...

@itsberni

I just ran into this on my development server (using PHP7.2)

The clues to a fix were found here.  NB, this module doesn't need ImageMagick/Ghostscript to have write permissions for PDFs to generate the thumbnails, read permission worked just fine for me.

  <policy domain="coder" rights="read" pattern="PDF" />

 

  • Like 2
Link to comment
Share on other sites

  • 4 months later...
On 1/4/2019 at 2:37 PM, ThomasH said:

Hi, i use PW 3.0.123 and can't use your module

 Class 'Pagefile' not found (Zeile 39 in /kunden/310636_12107/webseiten/meab/dev/site/modules/FieldtypePDF/FieldtypePDF/PagePDF.php) 

   

Hi @ThomasH

In file PagePDF.php on lines 32,33,34 change to:

use ProcessWire\Pagefile;
use ProcessWire\Pageimage;
use ProcessWire\Pageimages;

and in file PagePDFs.php add ProcessWire\ namespace for Pagefiles as well (on line 29)

BTW @Richard Jedlička very useful module for me now ? Thanks a lot!

Working on PW 3.0.133, PHP 7.3.8 FPM (FieldtypePDF v. 1.1.5)

  • Thanks 1
Link to comment
Share on other sites

  • 1 month later...

First of all many thanks to @Richard Jedlička for this great module. It does exactly what I was looking for, unfortunately I have a problem with the generated thumbnails: German umlauts are simply not displayed. In the ImageMagick documentation I can't find any hint and can only assume that it is somehow related to Ghostscript?

Maybe someone of you already had the same problem found and a solution?

Many thanks in advance!

Cheers,
Florian

Link to comment
Share on other sites

35 minutes ago, snck said:

generated thumbnails: German umlauts are simply not displayed

No umlauts in the cover/screenshot of your uploaded PDF?
Do you use some special fonts in the PDF which are not embedded?

I got the module working somehow and threw a ton of PDFs at it and there were lots of ä,ö,ü and ß.

Link to comment
Share on other sites

18 minutes ago, wbmnfktr said:

No umlauts in the cover/screenshot of your uploaded PDF?
Do you use some special fonts in the PDF which are not embedded?

Yes, I get no umlauts in the generated image. The only font used is AvenirLT-Medium, which is embedded correctly (at least Adobe Acrobat tells me it is). The PDF hat been generated with Adobe Indesign. Left of the attached image is the output I get from the module, on the right site the PDF in Acrobat as reference.

Bildschirmfoto 2019-09-30 um 15.53.30.png

Link to comment
Share on other sites

Just queried Google and there might be a problem with either

  • ImageMagick
  • Ghostscript
  • Missing fonts
  • Wrong/false/incomplete embedded fonts
  • Other font issues

Or in short... if it's a server-related you might have to dig quite deep into it. From ImageMagick versions to installed Ghostscript fonts to (above mentioned) policy restrictions. Depending on your hosting or the client's hosting it might not even work. Shared hosting plans don't allow access to files and folders - but in most cases those environments are pretty well configured.

It might be easier to create a already pre-rendered first page for the PDF without any real text and fonts. Maybe converting them to paths or however it works in InDesign.

As it is only a download and nothing you'd push to a print shop, it should work out just fine.

  • Like 1
Link to comment
Share on other sites

Thanks for your quick reply! My problem is that the client generates the PDF himself, it contains a lot of pages and gets updated regularly. Our goal is to streamline his workflow by offering him to upload just one file and having the website generate thumbnails for all pages with hi-res previews as well. I will play around with Indesign's PDF export options and try wo solve the problem by converting the fonts to paths, but we do not want to loose the ability to search in the PDF. I will try to test it on the client's server as soon as possible, maybe the configuration there magically solves my problem ?

Link to comment
Share on other sites

  • 3 months later...

After upgrading to the latest master 3.0.148 coming from the 3.0.123 version, this module stopped working in the sense that i am no longer able to upload files.

I get the following error message:

NOT AUTHORISED /files/assets/8888/filename.pdf @ error/constitute.c/ReadImage/412

Link to comment
Share on other sites

  • 1 month later...

I am still having issues with this module. this is what the error log shows running 3.0.148:

Fatal Error: Uncaught TypeError: Argument 1 passed to InputfieldPDF::getAdminThumb() must be an instance of FieldtypePDF\PagePDF, instance of Pagefile given, called in /site/assets/cache/FileCompiler/site/modules/FieldtypePDF/InputfieldPDF.module on line 111 and defined in /site/assets/cache/FileCompiler/site/modules/FieldtypePDF/InputfieldPDF.module:57 Stack trace:
1. /site/assets/cache/FileCompiler/site/modules/FieldtypePDF/InputfieldPDF.module(111): InputfieldPDF->getAdminThumb(Object(Pagefile))
2. /wire/core/Wire.php(389): InputfieldPDF->___renderItem(Object(Pagefile), 'pdf_manual_6feb...', 0)
3. /wire/core/WireHooks.php(823): Wire->_callMethod('___renderItem', Array)
4. /wire/core/Wire.php(450): WireHooks->runHooks(Object(InputfieldPDF), 'renderItem', Array)
5. /wire/modules/Inputfield/InputfieldFile/InputfieldFile.module(562): Wire->__
Line 57 of /site/assets/cache/FileCompiler/site/modules/FieldtypePDF/InputfieldPDF.module

 

Anyone experience or suggestions how to get around this?

Link to comment
Share on other sites

  • 2 weeks later...

hello @Richard Jedlička, i found the issue. It was not an issue with the module but a problem with an ImageMagick-6 policy update on my Ubuntu machine, which seems to have happen around the same time as i updated my Processwire version:

The solution to my problem was to edit

/etc/ImageMagick-6/policy.xml

than change the following line from:

<policy domain="coder" rights="none" pattern="PDF" />

to

<policy domain="coder" rights="read|write" pattern="PDF" />
and added the following line
<policy domain="coder" rights="read|write" pattern="LABEL" />

By changing the policy you have to make sure that you can trust the users that upload the pdf files. 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 4 months later...

Does fieldType PDF support tags? You can configure tags in the field set up but I get an error when I check for them with $pdf->getTag().

Edit: The field is fine, I made a mistake in how I was retrieving the tags, forgot that in order to get the tags as an array it should be $pdf->tags(true); and so the way I was doing it was the problem.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...