5440b4ccf5796778b6a65186bf83c17970f00d7a
markd
  Sun Aug 16 18:43:46 2026 -0700
Support PDF output in hgRenderTracks via hgt.psOutput. refs #38118

hgRenderTracks had PDF output wired up behind a compile-time PDF_OUTPUT define
that was set to 0, so it could only be reached by editing and rebuilding.
Select it at runtime with hgt.psOutput=on instead, which is the same variable
the hgTracks View->PDF menu item already uses.  PNG remains the default.

Also return from handlePostscript after doTrackForm when trackImgOnly is set.
In that case makeActiveImage has already converted the eps, written the PDF to
stdout and unlinked the eps, so the convertEpsToPdf that follows aborted on the
missing file.  The client never saw it because the PDF was already flushed and
hPrintDisable swallowed the error page, but every request logged
"Couldn't open ... .eps" to the apache error log.

Document the new parameter in the hgRenderTracks section of customTrackText.html
and in the hgRenderTracks tip in allTipsRaw.html.

diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c
index 85ef023b500..45051e58b9a 100644
--- src/hg/hgTracks/hgTracks.c
+++ src/hg/hgTracks/hgTracks.c
@@ -10566,30 +10566,36 @@
 ZeroVar(&ideoPsTn);
 trashDirFile(&psTn, "hgt", "hgt", ".eps");
 
 if(!trackImgOnly)
     {
     printMenuBar();
 
     printf("<div style=\"margin: 10px\">\n");
     printf("<H1>PDF Output</H1>\n");
     printf("PDF images can be printed with Acrobat Reader "
            "and edited by many drawing programs such as Adobe "
            "Illustrator or Inkscape.<BR>");
     }
 doTrackForm(psTn.forCgi, &ideoPsTn);
 
+// hgRenderTracks asks for the PDF as the response body, so makeActiveImage has already
+// converted the eps and written it to stdout.  Without this the convertEpsToPdf below
+// aborts on the eps it just deleted.
+if (trackImgOnly)
+    return;
+
 pdfFile = convertEpsToPdf(psTn.forCgi);
 if (strlen(ideoPsTn.forCgi))
     ideoPdfFile = convertEpsToPdf(ideoPsTn.forCgi);
 if (pdfFile != NULL)
     {
     printf("<UL style=\"margin-top:5px;\">\n");
     printf("<LI>Download <A TARGET=_blank HREF=\"%s\">"
        "the current browser graphic in PDF</A>\n", pdfFile);
     if (ideoPdfFile != NULL)
         printf("<LI>Download <A TARGET=_blank HREF=\"%s\">"
                "the current chromosome ideogram in PDF</A>\n", ideoPdfFile);
     printf("</UL>\n");
     freez(&pdfFile);
     freez(&ideoPdfFile);