raffaem / pdfsak

Utility to manipulate PDF files.
MIT License
43 stars 8 forks source link

--check-latex error #7

Closed anotatta closed 2 years ago

anotatta commented 2 years ago

I am using miktex. I run pdfsak --check-latex I got error pdfpages is missing, eventhough I know I intalled the package pdfpages already.

I also run pdfsak --debug -if in.pdf -o out --clearscan but there is no report.gz in temp directory

1. pdfsak --debug -if in.pdf -o out --clearscan

Creating debug temporary directory E:\Documents...\temp Input pages: 1 100%|██████████████████████████████████████████████████████████████████| 1/1 [00:11<00:00, 11.21s/it] Merging back... Latex failed to compile the file. Please run again with --debug option, then report at https://github.com/raffaem/pdftools/issues attaching ./temp/report.gz

2. pdfsak --check-latex

pdflatex ok Checking pdfpages: MISSING Checking lastpage: found Checking grffile: found Checking forloop: found Checking fancyhdr: found Checking textpos: found Checking changepage: found Checking graphicx: found Checking THIS_PACKAGE_DOES_NOT_EXIST: MISSING Exiting

raffaem commented 2 years ago

Hello,

thanks again for taking the time to report this

I am using miktex. I run pdfsak --check-latex I got error pdfpages is missing, eventhough I know I intalled the package pdfpages already.

I tested pdfsak with TexLive, but I expect it to work with MikTex nevertheless.

Can you get the latest commit, run --check-all and post the full output?

You can use 3 backticks to enclose it (```output```)

Latex failed to compile the file. Please run again with --debug option, then report at https://github.com/raffaem/pdftools/issues attaching ./temp/report.gz

You should get your report.gz now if you run with --debug

anotatta commented 2 years ago

I tested it using miktex and then texlive. Below are the outputs. I don't see report.gz yet, but there is a new error message shown below when --debug was run. Has pdfsak really been tested on windows?

Using miktex

pdflatex ok
Checking LaTeX package 'pdfpages': MISSING
stdout='This is pdfTeX, Version 3.14159265-2.6-1.40.21 (MiKTeX 2.9.7300 64-bit)
entering extended mode
(check.tex
LaTeX2e <2020-02-02> patch level 2
L3 programming layer <2020-02-14> (C:\MikTexP\tex/latex/base\article.cls
Document Class: article 2019/12/20 v1.4l Standard LaTeX document class
(C:\MikTexP\tex/latex/base\size10.clo))
(C:\MikTexP\tex/latex/pdfpages\pdfpages.sty
(C:\MikTexP\tex/latex/base\ifthen.sty) (C:\MikTexP\tex/latex/tools\calc.sty)
(C:\MikTexP\tex/latex/eso-pic\eso-pic.sty

LaTeX Warning: You have requested release `2020-10-01' of LaTeX,
               but only release `2020-02-02' is available.

! Undefined control sequence.
<argument> \nointerlineskip \AddToHook
                                       {shipout/background}{\put (0,\ESO@yof...
l.188 }

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...

l.188 }

! Undefined control sequence.
<argument> \ESO@yoffsetI

l.188 }

! Undefined control sequence.
<argument> ... \ESO@HookIIBG \@empty }}\AddToHook
                                                  {shipout/foreground}{\put ...
l.188 }

! Undefined control sequence.
<argument> \ESO@yoffsetI

l.188 }

(C:\MikTexP\tex/latex/graphics\keyval.sty)
(C:\MikTexP\tex/latex/xcolor\xcolor.sty
(C:\MikTexP\tex/latex/graphics-cfg\color.cfg
Overfull \hbox (124.91606pt too wide) in paragraph at lines 188--2
[]\OT1/cmr/m/n/10 shipout/background[]shipout/foreground[]

) (C:\MikTexP\tex/latex/graphics-def\pdftex.def)))
(C:\MikTexP\tex/latex/graphics\graphicx.sty
(C:\MikTexP\tex/latex/graphics\graphics.sty
(C:\MikTexP\tex/latex/graphics\trig.sty)
(C:\MikTexP\tex/latex/graphics-cfg\graphics.cfg)))
(C:\MikTexP\tex/latex/pdfpages\pppdftex.def))
(C:\MikTexP\tex/latex/l3backend\l3backend-pdfmode.def)
No file check.aux.
(C:\MikTexP\tex/context/base/mkii\supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (C:\MikTexP\tex/latex/epstopdf-pkg\epstopdf-base.sty)
(C:\MikTexP\tex/latex/pdflscape\pdflscape.sty
(C:\MikTexP\tex/generic/iftex\iftex.sty)
(C:\MikTexP\tex/latex/graphics\lscape.sty)) [1{C:/Users/Admin/AppData/Local/MiK
TeX/2.9/pdftex/config/pdftex.map}] (check.aux) )
(see the transcript file for additional information)<C:/MikTexP/fonts/type1/pub
lic/amsfonts/cm/cmr10.pfb>
Output written on check.pdf (1 page, 14929 bytes).
Transcript written on check.log.
'
stderr='pdflatex: security risk: running with elevated privileges
'
Checking LaTeX package 'lastpage': OK
Checking LaTeX package 'grffile': OK
Checking LaTeX package 'forloop': OK
Checking LaTeX package 'fancyhdr': OK
Checking LaTeX package 'textpos': OK
Checking LaTeX package 'changepage': OK
Checking LaTeX package 'graphicx': OK
Checking LaTeX package 'THIS_PACKAGE_DOES_NOT_EXIST': MISSING
stdout='This is pdfTeX, Version 3.14159265-2.6-1.40.21 (MiKTeX 2.9.7300 64-bit)
entering extended mode
(check.tex
LaTeX2e <2020-02-02> patch level 2
L3 programming layer <2020-02-14> (C:\MikTexP\tex/latex/base\article.cls
Document Class: article 2019/12/20 v1.4l Standard LaTeX document class
(C:\MikTexP\tex/latex/base\size10.clo))

! LaTeX Error: File `THIS_PACKAGE_DOES_NOT_EXIST.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Enter file name:
! Emergency stop.
<read *>

l.3 \begin
          {document}

!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on check.log.
'
stderr='pdflatex: security risk: running with elevated privileges
'
imagemagick ok
potrace ok
mkbitmap ok
Ghostscript ok
Exiting

And here is what I get when I use texlive

pdflatex ok
Checking LaTeX package 'pdfpages': OK
Checking LaTeX package 'lastpage': OK
Checking LaTeX package 'grffile': OK
Checking LaTeX package 'forloop': OK
Checking LaTeX package 'fancyhdr': OK
Checking LaTeX package 'textpos': OK
Checking LaTeX package 'changepage': OK
Checking LaTeX package 'graphicx': OK
Checking LaTeX package 'THIS_PACKAGE_DOES_NOT_EXIST': MISSING
stdout='This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/W32TeX) (preloaded format=pdflatex)
 \write18 enabled.
entering extended mode
(./check.tex
LaTeX2e <2019-10-01> patch level 3
(c:/texlive/2019/texmf-dist/tex/latex/base/article.cls
Document Class: article 2019/10/25 v1.4k Standard LaTeX document class
(c:/texlive/2019/texmf-dist/tex/latex/base/size10.clo))

! LaTeX Error: File `THIS_PACKAGE_DOES_NOT_EXIST.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Enter file name:
! Emergency stop.
<read *>

l.3 \begin
          {document}^^M
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on check.log.
'
stderr=''
Exiting

pdfsak --debug -if in.pdf -o out --clearscan

Creating debug temporary directory E:\Documents\...\temp
Input pages: 1
100%|██████████████████████████████████████████████████████████████████| 1/1 [00:11<00:00, 11.77s/it]
Merging back...
Creating debug temporary directory E:\Documents\...\vips\temp\temp
CWD: E:\Documents\...\vips
CWD: E:\Documents\...\vips\temp
Compressing PDF file...
gswin64c -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=E:/Documents/.../vips/out E:/Documents/.../vips/temp/merged.pdf
GPL Ghostscript 9.54.0: **** Could not open the file E:/Documents/.../vips/out .
**** Unable to open the initial device, quitting.
Error: Failed to compress PDF file
raffaem commented 2 years ago

Hello,

  1. Please get the latest commit, run pdfsak --check-all and post the result here. It is much more detailed now.

  2. About MikTex

I strongly believe this is caused by a corrupted version of MikTeX on your part. The reasons I believe so are as follows: a. From the log you posted, it looks like MikTeX throws an error ! Undefined control sequence. when trying to include eso-pic.sty (which is another project of course) b. I just tested all the examples on Windows using MikTeX, including clearscan, and they all work after allowing MikTeX to install the packages c. If you use TexLive on your part it works, and there is absolutely no reason for MikTeX to fail to compile it if TexLive can.

In order to sort it out, please try to update MikTeX as follows:

mpm --verbose --update

If it still persists, please try to uninstall MikTeX (including deleting its folder) and reinstall it. It only takes a few minutes.

If it still persists, we will go from the new information obtained by --check-all (point 1)

  1. Compressing PDF file... gswin64c -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=E:/Documents/.../vips/out E:/Documents/.../vips/temp/merged.pdf GPL Ghostscript 9.54.0: Could not open the file E:/Documents/.../vips/out . Unable to open the initial device, quitting. Error: Failed to compress PDF file

I cannot reproduce this.

I also have no idea why there are three dots ... instead of just two ...

The latest commit should allow you to retain the debug directory if you call it with --debug option as you did.

If it still happens, please send the PDF file you are using, the exact command line, and the contents of the temp folder (call pdfsak with the --debug option)

Has pdfsak really been tested on windows?

When you first posted, it wasn't.

I have used an old version of pdfsak, which I called pdftools, on Windows. It was not even a pip package yet.

Then I have long switched to Linux and did not test it on Windows anymore.

It was really foolish to think that it would work on Windows out-of-the-box in retrospect.

Yesterday I have set-up TexLive on my Windows Virtual Machine, ported all the examples in Windows' batch and tested all of the examples, fixing bug until they all worked.

Today I just installed MikTex on the Windows VM, and re-run all the examples under it and they worked, after letting MikTex install the missing packages.

anotatta commented 2 years ago

The three dots are just name of my local directory which I deleted for privacy reason. Windows is messy and complex shell script like pdfsak which call Latex, imagemagick, gs, potrace, mkbitmap, etc...requires extensive testing.

I will close this because I can't get this to work.

raffaem commented 2 years ago

The three dots are just name of my local directory which I deleted for privacy reason.

I didn't understand that. I generally put "DELETED" or "ABRIDGED" in this case.

The name of that directory is relevant as follows.

I will close this because I can't get this to work.

It's unfortunate we have given up because we were very very near the solution.

Compressing the output PDF is the very final step in the clearscan simulation process, and writing the output file is the last step of that last step.

The error you are seeing says that Ghostscript cannot write to the output file.

It may be that your ... folder contains special characters, or a write permission problem.

Anyway I'm going to test that output directory for writability before starting the process, and I'm also going to give the user to skip the compression step (which isn't really necessary anyway ... you would get a slightly bigger PDF file).

So if you ever feel like trying again, you can try the things above or just skip the compression step with the new option I'm going to implement.

Otherwise, thanks for the report, it has been a good journey :)

Windows is messy and complex shell script like pdfsak which call Latex, imagemagick, gs, potrace, mkbitmap, etc...requires extensive testing.

Well, it's not like we have a full software house here. It's just me and I'm trying my best.

You are absolutely and totally right that I left written in the documentation that Windows is a supported platform, and after switching to Linux I haven't tested on Windows anymore.

Now I fully tested all the examples on Windows 11 under both TexLive and MikTex.

I'm going to polish things up and release a new version with all the fixes.

For macOS, I will write in the docs that it's untested.