PDF error: Stream must have data

Hi,

I have the same problem, and the path of the files is fine. How can I solve it.

image

1 Like

Do you have the most recent version of OJS? I don’t think we ever did anything specifically to solve this issue, but the problem went away. I am wondering if an upgrade helped.

Hi @jaskoog,

Yes, I have version 3.2.1.0, but as far as I understand it is that it is necessary to update again because the names of the PDFs did not change in the update.

Hi @diegomejia07,

What do you see for contents in the files_dir directory (as configured in your config.inc.php)?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

This is the path of the OJS files, it was not changed and the folder is there.

image

If the OJS did not change the names of the PDF files, this error can only be fixed by updating again.

Thanks.

Hi @diegomejia07,

What does a full path to a PDF file look like in the files directory? (Pick any example.)

What version did you upgrade from?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

The path to one of the PDF’s is as follows:

C:\wamp64\archivos_ojs\journals\3\articles\1122\public\1122-4080-1-PB.pdf

Hi @diegomejia07,

That’s an OJS 2.x-style filename, so the upgrade process wasn’t able to rename it during the upgrade to 3.x. (You probably got warnings about this.) You’ll need to re-run the upgrade process using a database backup, but ensuring that the file permissions are set in a way that allows the upgrade process to rearrange the files directory.

(Alternately, if you’ve kept a copy of the errors/warnings generated during the upgrade process, it’ll contain a list of all the files that couldn’t be moved – if you really can’t re-run the upgrade, you can rename the files according to that list.)

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

I understand, but what happens is that I already made this attempt, and the only thing that solves this problem is to upload the PDF to the gallery again, because it creates the file in the proof / folder, but naming them nothing happens. Or how should this name be done if the PDFs are in the public / folder of the files and not in the proof / folder. Attached one of the errors that the update showed.

Unable to move "C:/wamp64/Archivos_ojs/journals/2//articles/1332//submission/original/1332-4339-2-SM.pdf" to "C:/wamp64/Archivos_ojs/journals/2//articles/1332//submission/1332-13-4339-2-2-20200528.pdf".

Hi @diegomejia07,

That message gives you the information you need to solve the problem (for that one file) – you need to move the file to the specified location and change its name to match. The match needs to be exact. (This will probably be annoying and error-prone to fix manually – you might consider re-running the upgrade process on a backup, then taking the resulting files directory and adding its contents to your current files directory. That’s assuming that you don’t want to re-run the upgrade process on your live site, which would be the cleanest solution.)

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

Where these PDF names are saved, the new name that OJS 3 assigns to the files. In what table and how it is built.

Thanks.

Hi @diegomejia07,

It’s constructed in PHP based on data in the submission_files table. See pkp-lib/SubmissionFile.inc.php at stable-3_2_1 · pkp/pkp-lib · GitHub for details.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

I’ve successfully re-run the upgrade process but the files path still have the same format.
What type of permissions the files folder need to have?

Best,

Hi @rafaelhcs,

That’s hard to answer in general as it depends on your OS and web server API – OJS is a PHP script, so just needs to be able to rename the files in your files directory while running the upgrade. If you’re running the upgrade tool from the command line, the files need to be modifiable by your user account.

Regards,
Alec Smecher
Public Knowledge Project Team

It worked perfectly for me!!
I was doing a crude manual update and it was caused because my “files” folder was in the wrong location (the one you select on installation).

Hello. I have the same problem described here, PDF can not be seen.
(We use OJS 3.1.2)

“Ocurrió un error al cargar el PDF.
PDF.js v2.0.943 (build: dc98bf76)
Mensaje: PDFDocument: stream must have data”

The file directory is ok.
The path, for example, to see the PDF is
https://revistasojs.una.edu.ar/index.php/IDyM/article/view/165/93

We didn’t do any modification, that is the strange thing.

Any recomendation?
Thank you

Hi @Jvil
That error says that the PDF could not be found.
1.- check that the path is really where the PDFs are
3.- check the access permissions to that directory

Regards,

Hi @dagosalas, thank you. Something is wrong in general. For instance, when I try to follow the link of a Submission File, I get error 500 (internal server). If I try to download it, I get a zip file with 0 k, I mean, is not only the PDF files.

That path for the PDF that fails is

https://revistasojs.una.edu.ar/index.php/IDyM/article/view/162/88

In config.inc.php we have:

files_dir = /home/iuna1129/tmp/ojs (uploaded files)

public_files_dir = public (public uploaded files)

thank you