ho-tex / pdfcrop

pdfcrop perl utility
LaTeX Project Public License v1.3c
25 stars 6 forks source link

pdfcrop --xetex does not give correct output #3

Closed jszhao closed 1 year ago

jszhao commented 3 years ago

Here is the code to reproduce the issue.

1) generate a pdf page (named as abc.pdf) from the following code:

\documentclass{standalone}
\begin{document}
\Huge A sample text.
\end{document} 

2) use pdfcrop to remove its margins (actually it does not have white margins)

pdfcrop --xetex abc.pdf

you will see the output have two pages, and both are empty.

If replacing standalone with article, the output also have two pages, but the first page is correct, and the second page is also empty.

pdfcrop --pdftex abc.pdf
pdfcrop --luatex abc.pdf

both could give correct results.

I have run that on my Windows 10 system with TeXLive 2020 full installed and updated. The pdfcrop version is PDFCROP 1.40, 2020/06/06.

Best, Jinsong

u-fischer commented 3 years ago

Well the second page is because of the special for the pdf version. It can probably be moved into the box.

The text seems to disappear with standalone as the paper size is too small now: with the 1in displacement inserted by the code nothing is in the box, and then it gets dropped. This is perhaps a xetex bug but imho nothing pdfcrop can solve.

pablgonz commented 3 years ago

With the example file:

\documentclass{standalone}
\begin{document}
\Huge A sample text.
\end{document}

and running:

$ xelatex test.tex
$ pdfcrop --xetexcmd xelatex test.pdf

I get the correct output file:

test-crop-1

One interesting thing I have noticed here is the following. When running pdfcrop --xetex test.pdf the line executed by pdfcrop is as follows:

* XeTeX call: xetex -no-shell-escape -interaction=nonstopmode tmp-pdfcrop-9248

i.e., it uses plain XeTeX, which has an effect on the fonts of the file:

$ pdffonts  test.pdf 
name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
SYMVRB+LMRoman17-Regular-Identity-H  CID Type 0C       Identity-H       yes yes yes      4  0
$ pdffonts  test.pdf 
name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
SYMVRB+LMRoman17-Regular-Identity-H  CID Type 0C       Identity-H       yes yes yes      4  0

$ pdfcrop --xetex test.pdf
PDFCROP 1.40, 2020/06/06 - Copyright (c) 2002-2020 by Heiko Oberdiek, Oberdiek Package Support Group.
==> 1 page written on `test-crop.pdf'.

$ pdffonts test-crop.pdf 
name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
SYMVRB+LMRoman17-Regular-Identity-H  CID Type 0C       Identity-H       yes yes yes      4  0
DLSGEY+CMR10                         Type 1C           Builtin          yes yes yes     16  0

Add the font CMR10 and that affects the generated pdf-crop file, but when executing the line:

$ pdffonts test.pdf 
name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
SYMVRB+LMRoman17-Regular-Identity-H  CID Type 0C       Identity-H       yes yes yes      4  0

$ pdfcrop --xetexcmd xelatex test.pdf 
PDFCROP 1.40, 2020/06/06 - Copyright (c) 2002-2020 by Heiko Oberdiek, Oberdiek Package Support Group.
==> 1 page written on `test-crop.pdf'.

$ pdffonts test-crop.pdf 
name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
SYMVRB+LMRoman17-Regular-Identity-H  CID Type 0C       Identity-H       yes yes yes      8  0

everything works OK.

I hope this is helpful. Saludos

davidcarlisle commented 1 year ago

fixed in v1.41