diff --git a/doc/guide/appendices/cli-v1vsv2.xml b/doc/guide/appendices/cli-v1vsv2.xml
index d7bd3e229..4a1e53035 100644
--- a/doc/guide/appendices/cli-v1vsv2.xml
+++ b/doc/guide/appendices/cli-v1vsv2.xml
@@ -60,7 +60,6 @@
latex
pdflatex
xelatex
- pdf2svg
asy
sage
convert
diff --git a/doc/guide/appendices/python.xml b/doc/guide/appendices/python.xml
index f64679b90..719fe44b7 100644
--- a/doc/guide/appendices/python.xml
+++ b/doc/guide/appendices/python.xml
@@ -85,7 +85,7 @@
- With lxml, you have a collection of Python routines that interface with the same base libraries for XSL processing as the xsltproc executable. A second library is requests which moderates communications with online servers and is necessary to communicate with WeBWorK servers and with a YouTube server that provides thumbnail images for static versions of videos. The pdfCropMargins package provides a tool that will crop images during their production with the pretext script. Finally, playwright uses a Chromium headless browser to take static screenshots of interactive elements of your project.
+ With lxml, you have a collection of Python routines that interface with the same base libraries for XSL processing as the xsltproc executable. A second library is requests which moderates communications with online servers and is necessary to communicate with WeBWorK servers and with a YouTube server that provides thumbnail images for static versions of videos. The pdfCropMargins package provides a tool that will crop images during their production with the pretext script. The pyMuPDF library then converts the PDF that was cropped to SVG and PNG images. Finally, playwright uses a Chromium headless browser to take static screenshots of interactive elements of your project.
Note that right after you install playwright then you want to run
playwright install
@@ -117,6 +117,11 @@
playwright |
Automatic screenshots of interactive elements |
+
+ pyMuPDF |
+ Convert images to SVG and PNG |
+
+
diff --git a/doc/guide/appendices/windows-cli.xml b/doc/guide/appendices/windows-cli.xml
index a83a8be61..1042be106 100644
--- a/doc/guide/appendices/windows-cli.xml
+++ b/doc/guide/appendices/windows-cli.xml
@@ -144,62 +144,6 @@
One thing to keep in mind: with MikTeX, you must run an initial update from the MikTeX pacakage manager before it will work correctly.
-
-
- pdf2svg
-
- If your book contains images such as TikZ, the -CLI will process those images using whatever version of you installed,
- and then it needs pdf2svg to convert the output to SVG format for use in HTML.
-
-
-
- There is no Windows installer
for thos program. Instead, it is available as a GitHub repository.
- The easiest way to get it onto your computer is to use the newly-installed Git Bash terminal.
- The first time you open Git Bash, your working directory might be the root c: drive.
- Type pwd to find out what folder you're in.
- It doesn't matter where you install pdf2svg, as long as you're aware of where it is.
- If you want to change to a different folder, you can do so using the cd command.
-
-
-
- An important note of caution: avoid using directories such as Program Files that have spaces in the name.
- This can cause problems with some of the scripts used by the -CLI.
- For this example, we will choose to place the program in our own user directory.
- In Git Bash, type cd Users/Sean (where you will replace Sean
with your own user name, as long as it doesn't contain spaces).
-
-
-
- Next, go to the pdf2svg repository on GitHub.
- Click on the Code
button, and then click on the clipboard icon to copy the URL, as shown below:
-
-
-
- Screenshot of the GitHub page for the pdf2svg project, showing where to click to copy the project URL to the clipboard
-
-
-
- Next, in Git Bash, type git clone and then right-click to paste the URL you copied,
- or use the keyboard shortcut Shift-Insert. Hit Enter.
-
-
-
- You will now have the necessary software downloaded to your computer.
- In my example, it is now available in C:\Users\Sean\pdf2svg-windows.
- To complete the installation, we need to add the program to the Windows environment variables.
- Hit the Windows key, and type path
. Open the suggested program.
-
-
-
- As shown below, click on the Environment Variables...
button, then click on the line beginning with Path
,
- and click on the Edit
button.
- You can then click on Browse
, and find the pdf2svg-windows folder you just downloaded.
-
-
-
- You should now have a working installation of pdf2svg.
- To confirm, type which pdf2svg in Git Bash. It should display the path to the pdf2svgprogram. (You may have to restart Git Bash first.)
-
-
@@ -365,7 +309,7 @@
Finally, we are ready to install the -CLI. This is perhaps the easiest step of the whole process.
From the Git Bash terminal, first type which python to confirm that Python has been successfully added to the PATH.
You should see the path to your Python program if things are working correctly.
- If you don't, you may need to reinstall Python, or you can manually add it as we did for pdf2svg.
+ If you don't, you may need to reinstall Python, or you can manually add it.
diff --git a/doc/guide/appendices/windows.xml b/doc/guide/appendices/windows.xml
index 5a948f618..7965eeb80 100644
--- a/doc/guide/appendices/windows.xml
+++ b/doc/guide/appendices/windows.xml
@@ -264,45 +264,6 @@
Congratulations, you have successfully installed ImageMagick.
-
- Installing pdf2svg
-
- The installation procedure uses git. Open Git Bash and change to your root directory:cd /cClone the repository into C:\pdf2svg:git clone https://github.com/jalios/pdf2svg-windows.git pdf2svg
-
-
- Change PATH environment variable
- We need to add the pdf2svg program to the Windows PATH. This is similar to what is done above, in .
-
- Path Environment Variable for pdf2svg
-
- -
-
Open the Start menu and start typing Edit the system environment variables
. Select this option when it becomes visible.
-
- -
-
Click the Environment Variables button near the bottom of the dialog.
-
- -
-
In the bottom part of the dialog labeled System environment variables
, look for a variable named PATH. You may need to scroll.
-
- -
-
If you do find the PATH variable, select it and click the Edit... button.
-
- -
-
You should see a dialog with two text fields. Your variable name should be PATH.
-
- -
-
Place the cursor in the existing value and press the End key, so that the cursor moves to the back of the line. The PATH string is a ;-delimited list of full path names, so append the string C:\pdf2svg\dist-32bits; or C:\pdf2svg\dist-64bits; (note the semicolon) to the existing value.
-
- -
-
Click OK to save changes.
-
-
-
-
-
- Congratulations, you have successfully installed pdf2svg.
-
-
Installing jing
diff --git a/doc/guide/author/author-faq.xml b/doc/guide/author/author-faq.xml
index 7c2ae0875..49ec9a03e 100644
--- a/doc/guide/author/author-faq.xml
+++ b/doc/guide/author/author-faq.xml
@@ -59,30 +59,7 @@
How do I install pdf2svg?
- pdf2svg is necessary for TikZ diagrams in HTML.
-
-
-
- On Debian or Ubuntu Linux:
- sudo apt-get install pdf2svg.
-
-
-
- To install pdf2svg on a Mac, you will need to install MacPorts.
- Read the directions carefully, since you will need to install Xcode
- (available from the Mac App Store) first.
- Make sure that the command line tools are installed by running Xcode.
- After Xcode is installed read the directions to install Macports.
- Once MacPorts is installed run the following command to install pdf2svg:
- sudo port install pdf2svg.
- Be patient as this will take a few minutes.
- To get rid of any intermediate build files, run the command
- sudo port clean --all all.
- Again be patient.
-
-
-
- If you have trouble with MacPorts, try HomeBrew.
+ As of July 2024, you no longer need pdf2svg to process latex-images; we now use the python pyMuPDF library instead.
diff --git a/doc/guide/author/processing.xml b/doc/guide/author/processing.xml
index 8e9949add..96a5bc21b 100644
--- a/doc/guide/author/processing.xml
+++ b/doc/guide/author/processing.xml
@@ -571,7 +571,6 @@
latex="latex"
pdflatex="pdflatex"
xelatex="xelatex"
- pdfsvg="pdf2svg"
asy="asy"
sage="sage"
pdfpng="convert"
diff --git a/doc/guide/author/topics.xml b/doc/guide/author/topics.xml
index 23dfbbfac..7cfbafae1 100644
--- a/doc/guide/author/topics.xml
+++ b/doc/guide/author/topics.xml
@@ -3236,7 +3236,7 @@ displayed line, and there are no \\s. Use \amp to mark the alignm
As an instructor, you might want to recycle images from a text for a classroom presentation, a project handout, or an examination question. As an author, you can elect to make images files available through links in the HTML version, and it is easy and flexible to produce those links automatically.
- First, it is your responsibility to manufacture the files. For making different formats, the pretext script can sometimes help (). The Image Magick convert command is a quick way to make raster images in different formats, while the pdf2svg executable is good for converting vector graphics PDFs into SVGs. Also, to make this easy to specify, different versions of the same image must have identical paths and names, other than the suffixes. Finally, the case and spelling of the suffix in your source must match the filename ( jpg versus JPEG). OK, those are the ground rules.
+ First, it is your responsibility to manufacture the files. For making different formats, the pretext script can sometimes help (). The Image Magick convert command is a quick way to make raster images in different formats, while the pdf2svg executable is good for converting vector graphics PDFs into SVGs (although now the pretext script uses the pyMuPDF library for these tasks instead). Also, to make this easy to specify, different versions of the same image must have identical paths and names, other than the suffixes. Finally, the case and spelling of the suffix in your source must match the filename ( jpg versus JPEG). OK, those are the ground rules.
For links for a single image, add the archive attribute to the image element, such as
<image ... archive="pdf svg">
diff --git a/doc/guide/project.ptx b/doc/guide/project.ptx
index feffedd99..f5dced9ee 100644
--- a/doc/guide/project.ptx
+++ b/doc/guide/project.ptx
@@ -29,7 +29,6 @@
latex
pdflatex
xelatex
- pdf2svg
asy
sage
convert
diff --git a/examples/minimal/project.ptx b/examples/minimal/project.ptx
index 01fe96617..379654359 100644
--- a/examples/minimal/project.ptx
+++ b/examples/minimal/project.ptx
@@ -29,7 +29,6 @@
latex
pdflatex
xelatex
- pdf2svg
asy
sage
convert
diff --git a/examples/sample-article/project.ptx b/examples/sample-article/project.ptx
index dd4edbab0..c17ad5dff 100644
--- a/examples/sample-article/project.ptx
+++ b/examples/sample-article/project.ptx
@@ -41,7 +41,6 @@
latex
pdflatex
xelatex
- pdf2svg
asy
sage
convert
diff --git a/examples/showcase/project.ptx b/examples/showcase/project.ptx
index 8913f2ef3..c0fe76d2a 100644
--- a/examples/showcase/project.ptx
+++ b/examples/showcase/project.ptx
@@ -38,7 +38,6 @@
latex
pdflatex
xelatex
- pdf2svg
asy
sage
convert
diff --git a/examples/webwork/sample-chapter/project.ptx b/examples/webwork/sample-chapter/project.ptx
index 19cbcd2cc..ec6346a43 100644
--- a/examples/webwork/sample-chapter/project.ptx
+++ b/examples/webwork/sample-chapter/project.ptx
@@ -36,7 +36,6 @@
latex
pdflatex
xelatex
- pdf2svg
asy
sage
convert
diff --git a/pretext/README.md b/pretext/README.md
index c5252e711..ea01fd986 100644
--- a/pretext/README.md
+++ b/pretext/README.md
@@ -27,7 +27,7 @@ Example: TikZ code for graphics images can be extracted and written
into "standalone" files with XSL, and then this script will continue
on to apply LaTeX to the files, creating a PDF, then optionally
convert these PDFS into other formats, e.g. creating SVG images
-via the pdf2svg utility.
+via the pyMuPDF library.
`pretext.cfg`
-------------
diff --git a/pretext/pretext.cfg b/pretext/pretext.cfg
index 14aa90163..ee7b834a5 100644
--- a/pretext/pretext.cfg
+++ b/pretext/pretext.cfg
@@ -50,13 +50,13 @@
# "pdfcrop" key is only useful for options
# 2022-06-24 Remove use of "pdfcrop" for options
# 2022-06-28 Remove pageres key, in favor of pyppeteer package
+# 2024-06-30 Remove pdfsvg key, in favor of pyMuPDF library
[executables]
latex = latex
pdflatex = pdflatex
xelatex = xelatex
-pdfsvg = pdf2svg
asy = asy
mermaid = mmdc
sage = sage
diff --git a/pretext/pretext.py b/pretext/pretext.py
index 766177dfc..620351d4a 100755
--- a/pretext/pretext.py
+++ b/pretext/pretext.py
@@ -424,7 +424,7 @@ def sage_conversion(
shutil.copy2(sageout, dest_dir)
def latex_image_conversion(
- xml_source, pub_file, stringparams, xmlid_root, dest_dir, outformat, method, pyMuPDF=False
+ xml_source, pub_file, stringparams, xmlid_root, dest_dir, outformat, method, pyMuPDF=True
):
# stringparams is a dictionary, best for lxml parsing
@@ -577,21 +577,20 @@ def latex_image_conversion(
if outformat == "svg" or outformat == "all":
if pyMuPDF:
# create svg using pymupdf:
+ log.info("converting {} to {}".format(latex_image_pdf, latex_image_svg))
with fitz.Document(latex_image_pdf) as doc:
svg = doc.load_page(0).get_svg_image()
with open(latex_image_svg, "w") as f:
f.write(svg)
- shutil.copy2(latex_image_svg, dest_dir)
- # classic way to produce svg, using pdf2svg:
- latex_image_svg = "classic-" + latex_image_svg
- pdfsvg_executable_cmd = get_executable_cmd("pdfsvg")
- # TODO why this debug line? get_executable_cmd() outputs the same debug info
- log.debug("pdfsvg executable: {}".format(pdfsvg_executable_cmd[0]))
- svg_cmd = pdfsvg_executable_cmd + [latex_image_pdf, latex_image_svg]
- log.info(
- "converting {} to {}".format(latex_image_pdf, latex_image_svg)
- )
- subprocess.call(svg_cmd)
+ else:
+ pdfsvg_executable_cmd = get_executable_cmd("pdfsvg")
+ # TODO why this debug line? get_executable_cmd() outputs the same debug info
+ log.debug("pdfsvg executable: {}".format(pdfsvg_executable_cmd[0]))
+ svg_cmd = pdfsvg_executable_cmd + [latex_image_pdf, latex_image_svg]
+ log.info(
+ "converting {} to {} using {}".format(latex_image_pdf, latex_image_svg, svg_cmd)
+ )
+ subprocess.call(svg_cmd)
if not os.path.exists(latex_image_svg):
log.error(
"There was a problem converting {} to svg and {} was not created".format(
@@ -602,27 +601,27 @@ def latex_image_conversion(
if outformat == "png" or outformat == "all":
if pyMuPDF:
# create high-quality png using pymupdf:
+ log.info("converting {} to {}".format(latex_image_pdf, latex_image_png))
with fitz.Document(latex_image_pdf) as doc:
png = doc.load_page(0).get_pixmap(dpi=300, alpha=True)
png.save(latex_image_png)
shutil.copy2(latex_image_png, dest_dir)
- # classic method: create high-quality png, presumes "convert" executable
- latex_image_png = "classic-" + latex_image_png
- pdfpng_executable_cmd = get_executable_cmd("pdfpng")
- # TODO why this debug line? get_executable_cmd() outputs the same debug info
- log.debug("pdfpng executable: {}".format(pdfpng_executable_cmd[0]))
- png_cmd = pdfpng_executable_cmd + [
- "-density",
- "300",
- latex_image_pdf,
- "-quality",
- "100",
- latex_image_png,
- ]
- log.info(
- "converting {} to {}".format(latex_image_pdf, latex_image_png)
- )
- subprocess.call(png_cmd)
+ else:
+ pdfpng_executable_cmd = get_executable_cmd("pdfpng")
+ # TODO why this debug line? get_executable_cmd() outputs the same debug info
+ log.debug("pdfpng executable: {}".format(pdfpng_executable_cmd[0]))
+ png_cmd = pdfpng_executable_cmd + [
+ "-density",
+ "300",
+ latex_image_pdf,
+ "-quality",
+ "100",
+ latex_image_png,
+ ]
+ log.info(
+ "converting {} to {} using command {}".format(latex_image_pdf, latex_image_png, png_cmd)
+ )
+ subprocess.call(png_cmd)
if not os.path.exists(latex_image_png):
log.error(
"There was a problem converting {} to png and {} was not created".format(
@@ -663,7 +662,6 @@ def latex_image_conversion(
image_list = "\n " + "\n ".join(failed_images)
raise ValueError(msg + image_list)
-
#############################################
#
# Binary Source Files to Base 64 in XML Files