Paste from pdf

Hi,
there is a nice plugin for the atom text editor called notes from the pdf (https://atom.io/packages/notes-from-pdf ) which gives a new “paste” keybind which pastes text copied from a PDF document and It performs the following steps on incoming text:

  • Replace line breaks with spaces
  • Repair line-break hyphenations
  • Trim whitespace from start and end
  • Change typographers’ quotes/apostrophes to regular ones and replace double-quotes with single-quotes

Many people use Obsidian for note taking from pdfs (academic papers, books etc), and as I see from other topics the way to go for most people is to use zotero for example for extracting annotations or using the available plugins directly for the same thing. I think a “smart” pdf pasting key would bypass the excess and unreasonable complexity of these methods with what I suspect is a very easy implementation.

Thanks

5 Likes

So, I started making a plugin for this. Because I do not have any experience on js code, I just used GitHub - derwish-pro/obsidian-code-block-from-selection: Obsidian plugin. Adds code block for the selected text. plugin which seems simple enough to change it.
So I used the selected text command from the API and it seems to work. By using my plugin I can clean the selected text with the rules mentioned in my first post. So right now it works using two steps, paste text, select pasted text, press the registerd hotkey to clean it.
Does anyone know how I get the clipboard text directly? Right now I use this chunk

let text = editor.getSelection(); //need something looking like editor.getClipboard() which doesn't exist
text = text.replace(/[\n\r]/g, ' ');
text = text.replace(/- /g, '');
text = text.replace(/"|“|”|’+|‘+/g, '\'');
editor.replaceSelection(text, 'around');

Any help will be welcome :slightly_smiling_face:

1 Like

I also think this would be an amazing addition to Obsidian

it would be a very useful plugin