Skip to content
Snippets Groups Projects
Commit f4b9ccb2 authored by tuhe's avatar tuhe
Browse files

updates

parent dd8f2587
No related branches found
No related tags found
No related merge requests found
Pipeline #33096 passed
......@@ -5,7 +5,7 @@ import subprocess
import glob
import asyncio
def latexmk(texfile,pdf_out=None,shell=True,cleanup=False, Linux=False):
def latexmk(texfile,pdf_out=None,shell=True,cleanup=False, Linux=False, compress_pdf=False):
cdir = os.getcwd()
texfile = os.path.abspath(texfile)
dname = os.path.dirname(texfile)
......@@ -37,19 +37,19 @@ def latexmk(texfile,pdf_out=None,shell=True,cleanup=False, Linux=False):
fl = glob.glob(dname + "/*."+ex)
for f in fl:
os.remove(f)
if compress_pdf:
cmd = f"""gs -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -e -o _{pdf_out} {pdf_out}"""
# cmds = [ f"""gs -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -e -o""", f"{dname}/{pdf_out}", f"{dname}/{pdf_out}"]
print("Compressing PDF file using command", cmd)
subprocess.run(cmd, shell=True)
shutil.move(f"_{pdf_out}", pdf_out)
print("[done]")
os.chdir(cdir)
return pdf_out
async def latexmk_async(texfile, pdf_out=None, cleanup=False):
cdir = os.getcwd()
texfile = os.path.abspath(texfile)
import tempfile
# with tempfile.TemporaryDirectory() as tmp:
# print('created temporary directory', tmpdirname)
# shutil.rmtree(tmp)
# shutil.copytree(os.path.dirname(texfile), tmp)
# tmp_texfile = tmp + "/" + os.path.basename(texfile)
tmp_texfile = texfile
compiled_pdf = tmp_texfile[:-4] + ".pdf"
if os.path.isfile(compiled_pdf):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment