add pdflatex
This commit is contained in:
parent
284caa592f
commit
3872cd87b6
3 changed files with 57 additions and 0 deletions
|
|
@ -26,11 +26,17 @@ RUN cd /temp/prod && bun install --frozen-lockfile --production
|
||||||
|
|
||||||
# copy production dependencies and source code into final image
|
# copy production dependencies and source code into final image
|
||||||
FROM base AS release
|
FROM base AS release
|
||||||
|
LABEL maintainer="Emrik Östling (C4illin)"
|
||||||
|
LABEL description="ConvertX: self-hosted online file converter supporting 700+ file formats."
|
||||||
|
LABEL repo="https://github.com/C4illin/ConvertX"
|
||||||
|
|
||||||
# install additional dependencies
|
# install additional dependencies
|
||||||
RUN rm -rf /var/lib/apt/lists/partial && apt-get update -o Acquire::CompressionTypes::Order::=gz \
|
RUN rm -rf /var/lib/apt/lists/partial && apt-get update -o Acquire::CompressionTypes::Order::=gz \
|
||||||
&& apt-get install -y \
|
&& apt-get install -y \
|
||||||
pandoc \
|
pandoc \
|
||||||
texlive-latex-recommended \
|
texlive-latex-recommended \
|
||||||
|
texlive-fonts-recommended \
|
||||||
|
texlive-latex-extra \
|
||||||
ffmpeg \
|
ffmpeg \
|
||||||
graphicsmagick \
|
graphicsmagick \
|
||||||
ghostscript \
|
ghostscript \
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,11 @@ import {
|
||||||
properties as propertiesGraphicsmagick,
|
properties as propertiesGraphicsmagick,
|
||||||
} from "./graphicsmagick";
|
} from "./graphicsmagick";
|
||||||
|
|
||||||
|
import {
|
||||||
|
convert as convertPdflatex,
|
||||||
|
properties as propertiesPdflatex,
|
||||||
|
} from "./pdflatex";
|
||||||
|
|
||||||
import { normalizeFiletype } from "../helpers/normalizeFiletype";
|
import { normalizeFiletype } from "../helpers/normalizeFiletype";
|
||||||
|
|
||||||
// This should probably be reconstructed so that the functions are not imported instead the functions hook into this to make the converters more modular
|
// This should probably be reconstructed so that the functions are not imported instead the functions hook into this to make the converters more modular
|
||||||
|
|
@ -49,6 +54,10 @@ const properties: {
|
||||||
properties: propertiesImage,
|
properties: propertiesImage,
|
||||||
converter: convertImage,
|
converter: convertImage,
|
||||||
},
|
},
|
||||||
|
pdflatex: {
|
||||||
|
properties: propertiesPdflatex,
|
||||||
|
converter: convertPdflatex,
|
||||||
|
},
|
||||||
pandoc: {
|
pandoc: {
|
||||||
properties: propertiesPandoc,
|
properties: propertiesPandoc,
|
||||||
converter: convertPandoc,
|
converter: convertPandoc,
|
||||||
|
|
|
||||||
42
src/converters/pdflatex.ts
Normal file
42
src/converters/pdflatex.ts
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
import { exec } from "node:child_process";
|
||||||
|
|
||||||
|
export const properties = {
|
||||||
|
from: {
|
||||||
|
text: ["tex", "latex"],
|
||||||
|
},
|
||||||
|
to: {
|
||||||
|
text: ["pdf"],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export function convert(
|
||||||
|
filePath: string,
|
||||||
|
fileType: string,
|
||||||
|
convertTo: string,
|
||||||
|
targetPath: string,
|
||||||
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
||||||
|
options?: any,
|
||||||
|
): Promise<string> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
// const fileName: string = (targetPath.split("/").pop() as string).replace(".pdf", "")
|
||||||
|
const outputPath = targetPath.split("/").slice(0, -1).join("/").replace("./", "")
|
||||||
|
exec(
|
||||||
|
`pdflatex -interaction=nonstopmode -output-directory="${outputPath}" "${filePath}"`,
|
||||||
|
(error, stdout, stderr) => {
|
||||||
|
if (error) {
|
||||||
|
reject(`error: ${error}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stdout) {
|
||||||
|
console.log(`stdout: ${stdout}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stderr) {
|
||||||
|
console.error(`stderr: ${stderr}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve("success");
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue