sioyek
sioyek copied to clipboard
`embed_annotations` and specify new file name automatically
Come from #120.
I want to produce a new file with all annotations contained. I know that I can use command "embed_annotations" and manually type in the name for the new file in the prop-up box (in Windows).
But it would be convenient to specify the new file name automatically. For example, I want to use "Original file name_Current Date.pdf" as the name of the new file, it would be great if automation is possible.
How can I do that through new-command
?
This should be possible with a javascript command after this commit: https://github.com/ahrm/sioyek/commit/be9efb387cb4cddd546bb84e4971713da7132dce.
embed.js
:
let state = sioyek_api.get_json_state();
let path = state["document_path"];
let parts = path.split('/');
let file_name = parts[parts.length - 1];
let file_name_parts = file_name.split('.');
let new_name = file_name_parts[0] + "_embedded." + file_name_parts[1];
let new_path = parts.slice(0, parts.length - 1).join('/') + '/' + new_name;
sioyek.embed_annotations(new_path);
prefs_user.config
new_js_command _embed embed.js
Just tried https://github.com/ahrm/sioyek/commit/be9efb387cb4cddd546bb84e4971713da7132dce. One thing I notice is that the colors of the embedded highlights is really faint compared to the original. Taking a closer look I found when I embed a highlight, sioyek adds a faint highlight under all the highlights and that is what gets embedded. So when I am working on a doc with preexisting embedded highlights, on top of which exists the original highlight, and want to embed new highlights, there will be another layer of highlight on the embedded highlights that existed already. This is really bugging.
You can use toggle_pdf_annotations
to not render PDF annotations.
This should be possible with a javascript command after this commit: be9efb3.
embed.js
:let state = sioyek_api.get_json_state(); let path = state["document_path"]; let parts = path.split('/'); let file_name = parts[parts.length - 1]; let file_name_parts = file_name.split('.'); let new_name = file_name_parts[0] + "_embedded." + file_name_parts[1]; let new_path = parts.slice(0, parts.length - 1).join('/') + '/' + new_name; sioyek.embed_annotations(new_path);
prefs_user.config
new_js_command _embed embed.js
Hi there jsut wanna inquire where to put this js file. thanks a lot!
Next to the prefs_user.config
file.
Next to the
prefs_user.config
file.
Thanks for your reply!
Sorry if this might seem a bit dumb as i am quite new to this js stuff. But i have put this file there and defined the key
but nothing happens when using it in sioyek.
Which version of sioyek are you using?
Which version of sioyek are you using?
The one under development branch
What is in your embed.js
file?
let state = sioyek_api.get_json_state();
let path = state["document_path"]; let parts = path.split('/'); let file_name = parts[parts.length - 1]; let file_name_parts = file_name.split('.'); let new_name = file_name_parts[0] + "_embedded." + file_name_parts[1]; let new_path = parts.slice(0, parts.length - 1).join('/') + '/' + new_name; sioyek.embed_annotations(new_path);
The same one above
On 29 Jul 2024, at 3:41 PM, ahrm @.***> wrote:
What is in your embed.js file?
— Reply to this email directly, view it on GitHubhttps://github.com/ahrm/sioyek/issues/973#issuecomment-2255223848, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BDZGEOM3DB3A2LD2DKZUDJTZOXW27AVCNFSM6AAAAABDFEJJP6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJVGIZDGOBUHA. You are receiving this because you commented.Message ID: @.***>
Is there an _embed
command in the commands (which can be opened by typing :
) list when you enter '_'?
Also what do you expect to happen when you execute this command, note that this just creates a file named <original-file-name>_embedded.pdf
but doesn't open it.
Also what do you expect to happen when you execute this command, note that this just creates a file named
<original-file-name>_embedded.pdf
but doesn't open it.
ahh got it. I just checked the path and found it. I thought a window may pop up with the predefined name. All good now. thanks!