Feature request: optional function to remove leftover pdftocgen documents and rename new document
I think it would be great to have an optional function that removes the recipe.toml and original PDF, and renames the newly created document with the _out.pdf suffix to the original named document (pdf-filename).
My elisp is novice at best, however I think this function could be written purely in elisp.
Thanks for the suggestion. The package has been designed to not remove the recipe.toml file, as the user might decide to 'change/improve' some previously extracted TOC. Personally, I find it no problem to have the recipe file in a book's directory. Indeed, if you are storing multiple books in a single directory, then the recipe.toml file will be reused for separate books. I will see if I find time to improve that behavior on some future update (it has no priority for now).
Regarding the _out.pdf file, that behavior is probably related to issue https://github.com/dalanicolai/doc-tools-toc/issues/1, as when using the package as instructed, the new pdf file replaces the old file by default (and the _out.pdf file should be only a temporary file).
Thanks for your response, and I didn't know this feature was already there.... I too could live with the recipe.toml if the other part was working, and indeed it may be related to issue #1, as when I run the C-c C-c as outlined in the usage instructions, I get the error reported in issue #1 and outputted file that has the original filename with the _out.pdf suffix. Am I doing something wrong?
The debug gives me the following:
Debugger entered--Lisp error: (void-variable pdf-filename)
doc-toc--pdftocgen-add-to-pdf()
funcall-interactively(doc-toc--pdftocgen-add-to-pdf)
command-execute(doc-toc--pdftocgen-add-to-pdf)
Any help in further tracking down the cause of this issue would be greatly appreciated.
Did you do it all in one go? Can you see what the value of pdf-filename is in the toc buffer, i.e. after you used doc-toc-extract-with-pdf-tocgen?
If you'd like to track down the cause, then I would advise you to read about edebug, and then edebug the functions doc-toc-extract-with-pdf-tocgen and doc-toc--pdftocgen-add-to-pdf. Those are very simple functions, you might be able to find the culprit.
By do it all in one go, do you mean just follow the process as outlined by your help docs? I think so.
The variable pdf-filename does not seem to exist:

Thanks for the pointer regarding the edebug... ~I'll give it a go when I get a bit more time and report back.~
So, I gave it a go, and it stopped on the below lines... Not sure what this is telling me. Any ideas?

From the image, it is not clear to me at which line it stopped? Also, did you try to step through the code?
It stopped on 325... Sorry, I did not try and step through the code. Very much learning to swim here, so I appreciate your patience. How do I "step through the code"?
For vanilla Emacs that is explained [here]. However, it looks like you might be using Doom emacs, for which I can not quickly find any info about edebug keybindings. However, it might be possible Doom just uses evil-collection, in which case s steps through the code...
Thanks for the tip. Okay, I have stepped through it, but I cannot make any more sense of it... Do you see anything in the gif?

I see that here pdf-filename seems to be defined. Otherwise I do not see anything interesting (also no errors). But in the gif you do not complete stepping through doc-toc--pdftocgen-add-to-pdf... you should only stop when you see the error come up (or otherwise when successfully stepped through the function). Also what do those keypresses mean? C-c and C-s?
Figured this out finally. Was a dependency and config issue on my end. Thanks!