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/renderMain.c src/hg/hgTracks/renderMain.c
index acc3c2766fd..71ef4e7b212 100644
--- src/hg/hgTracks/renderMain.c
+++ src/hg/hgTracks/renderMain.c
@@ -130,37 +130,36 @@
     // setup approriate CGI variables which tell hgTracks code what to do.
     cartSetBoolean(cart, "hgt.trackImgOnly", TRUE);
     if(cartVarExists(cart, "jsonp"))
         {
         // experimental code to support remote rendering via a jsonp callback
         // e.g.: /cgi-bin/hgRenderTracks?track=bamMMS9MbutiPygmy&track=...&jsonp=remoteTrackCallback&postion=...&pix=800
         cartSetString(cart, "hgt.contentType", "jsonp");
         cartSetString(cart, "hgt.trackNameFilter", cartString(cart, "track"));
         cartSetString(cart, cartString(cart, "track"), cartUsualString(cart, "vis", "pack"));
         }
     else
         {
         // remote rendering of hgTracks PNG image based on contents of a session; caller may pass in a subset of
         // hgTracks parameters: e.g. db, hgsid, pix, position and tracks with explicit visibilities (e.g. knownGene=pack).
 
-#define PDF_OUTPUT 0
-#if PDF_OUTPUT
+        // hgt.psOutput=on asks for PDF instead of PNG.  Same variable the hgTracks
+        // View->PDF menu item uses, so callers do not have to learn a second name.
+        if (cartUsualBoolean(cart, "hgt.psOutput", FALSE))
             cartSetString(cart, "hgt.contentType", "pdf");
-        cartSetString(cart, "hgt.psOutput", "on");
-#else
+        else
             cartSetString(cart, "hgt.contentType", "png");
-#endif
         cartSetBoolean(cart, "hgt.imageV1", TRUE);
         if(!cartVarExists(cart, "hgt.internal"))
             {
             if(!cartVarExists(cart, "hgt.baseShowAsm"))
                 cartSetBoolean(cart, "hgt.baseShowAsm", TRUE);
             if(!cartVarExists(cart, "hgt.baseShowPos"))
                 cartSetBoolean(cart, "hgt.baseShowPos", TRUE);
             }
         // XXXX support track filtering? - if(cartVarExists(cart, "hgt.trackNameFilter"))
         }
     doMiddle(cart);
     cgiExitTime("hgRenderTracks", enteredMainTime);
     }
 else
     {