sioyek icon indicating copy to clipboard operation
sioyek copied to clipboard

`embed_annotations` and specify new file name automatically

Open jleaves opened this issue 1 year ago • 3 comments

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?

jleaves avatar Feb 12 '24 17:02 jleaves

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

ahrm avatar Feb 12 '24 18:02 ahrm

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.

nikinbaidar avatar Feb 13 '24 03:02 nikinbaidar

You can use toggle_pdf_annotations to not render PDF annotations.

ahrm avatar Feb 13 '24 08:02 ahrm

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!

PalaceTony avatar Jul 29 '24 06:07 PalaceTony

Next to the prefs_user.config file.

ahrm avatar Jul 29 '24 07:07 ahrm

Next to the prefs_user.config file.

Thanks for your reply!

image 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

image

but nothing happens when using it in sioyek.

PalaceTony avatar Jul 29 '24 07:07 PalaceTony

Which version of sioyek are you using?

ahrm avatar Jul 29 '24 07:07 ahrm

Which version of sioyek are you using?

The one under development branch

PalaceTony avatar Jul 29 '24 07:07 PalaceTony

What is in your embed.js file?

ahrm avatar Jul 29 '24 07:07 ahrm

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: @.***>

PalaceTony avatar Jul 29 '24 07:07 PalaceTony

Is there an _embed command in the commands (which can be opened by typing :) list when you enter '_'?

ahrm avatar Jul 29 '24 07:07 ahrm

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.

ahrm avatar Jul 29 '24 07:07 ahrm

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!

PalaceTony avatar Jul 29 '24 07:07 PalaceTony