Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When I use pages from a PDF as a figure, they will get exported as PNG and the file name will be printed #118

Closed
claell opened this issue Oct 13, 2023 · 9 comments

Comments

@claell
Copy link

claell commented Oct 13, 2023

grafik

See the image: Usually, "Publishing Logo-2.png" shouldn't be printed. The figure is from the file "Publishing Logo.pdf", page 2.

I assume, tex4ebook generates PNGs (maybe as a fallback)? Single page PDF figures work for me.

@michal-h21
Copy link
Owner

Can you make a MWE for this issue? I cannot reproduce it with this sample:

\documentclass{article}
\usepackage{graphicx}
\begin{document}

Hello figure

\begin{figure}
\includegraphics[page=2]{sample.pdf}
\end{figure}
\end{document}

PDF files are converted either to PNG, or to SVG, if you select it as the output graphic format using

 $ tex4ebook filename.tex "svg"

@claell
Copy link
Author

claell commented Oct 13, 2023

Ah, I just noticed that it will do the PNG conversion also for the single page figure. Also thanks for the hint that SVG can be specified, which is great to know!

I'll try to give a MWE.

@claell
Copy link
Author

claell commented Oct 13, 2023

Hm, I tested your MWE and also got the error there.

@claell
Copy link
Author

claell commented Oct 13, 2023

Alright, problem found. The spaces in the file name seem to cause it. When I remove them, your MWE doesn't give the error anymore.

So I think, it is wanted to fix this problem, right?

@michal-h21
Copy link
Owner

Ah, I see. Spaces in filenames indeed cause this bug. I will fix that in TeX4ht sources. In the meantime, you can use this configuration file:

\Preamble{xhtml}
\catcode`\:=11
\makeatletter
\Configure{graphics*}
   {pdf}
   {\ifdefined\Gin@page\else\def\Gin@page{1}\fi%
     \edef\svg:filename{\Gin@base-\Gin@page.\a:PdfConvert}%
     % test for existence of the converted file
     \openin15={\svg:filename}\relax
      \ifeof15
      \Needs{\b:PdfConvert}%
      \fi
      \closein15
     { \Configure{Needs}{File: \svg:filename}\Needs{}}%
   \Picture[\a:GraphicsAlt]{{\svg:filename} \csname a:Gin-dim\endcsname
}}
\makeatother
\catcode`\:=12
\begin{document}
\EndPreamble

@claell
Copy link
Author

claell commented Oct 16, 2023

Great! (I might also not use spaces in the meantime). I guess you'll notify again when this is fixed in the sources. Thanks again for your support with this!

@michal-h21
Copy link
Owner

You can see changes in the sources here: https://tug.org/tex4ht/changelog.html

It will be available in TeX Live soon, most likely in few days.

@claell
Copy link
Author

claell commented Oct 16, 2023

That's awesome, thanks!

@claell
Copy link
Author

claell commented Jan 4, 2024

Finally had time for testing. Confirm that it works perfectly now with the latest package on TeX Live! Thanks again for your quick fix!

@claell claell closed this as completed Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants