05e67c59a20a5d00b810a981aef3b00c5bef82e1 max Fri Sep 20 06:03:18 2024 -0700 more features to hubtools: search in both parent and subdirs, better docs diff --git src/lib/psGfx.c src/lib/psGfx.c index 062ffb6..2d89f58 100644 --- src/lib/psGfx.c +++ src/lib/psGfx.c @@ -499,30 +499,52 @@ psXyOut(ps, x4, y4); fprintf(f, "curveto\n"); fprintf(f, "stroke\n"); } void psSetDash(struct psGfx *ps, boolean on) /* Set dashed line mode on or off. If set on, show two points marked, with one point of space */ { FILE *f = ps->f; if (on) fprintf(f, "[2 1] 0 setdash\n"); else fprintf(f, "[] 0 setdash\n"); } +char * convertPdfToSvg(char *pdfFile) +/* Convert PDF to SVG in same directory as PDF and return new filename */ +{ +char *svgFile=NULL; +svgFile = cloneString(pdfFile); +chopSuffix(svgFile); +svgFile = addSuffix(svgFile, ".svg"); + +struct pipeline *pl = NULL; +char *pipeCmd[] = { "pdftocairo", "-svg", pdfFile, svgFile, NULL } ; +pl = pipelineOpen1(pipeCmd, pipelineWrite, "/dev/null", NULL, 0); + +int sysVal = 0; +sysVal = pipelineWait(pl); +if(sysVal != 0) + { + freez(&svgFile); + return NULL; + } +return svgFile; +} + char * convertEpsToPdf(char *epsFile) /* Convert EPS to PDF and return filename, or NULL if failure. */ { char *pdfTmpName = NULL, *pdfName=NULL; int sysVal = 0; struct lineFile *lf = NULL; char *line; int lineSize=0; float width=0, height=0; pdfTmpName = cloneString(epsFile); /* Get the dimensions of bounding box. */ lf = lineFileOpen(epsFile, TRUE); while(lineFileNext(lf, &line, &lineSize)) {