Jump to content
  • 0

Feature request: ability to combine (not 'merge') individual PDF notes


jonteamere

Idea

I sometimes slap together my own packets of notes from individual PDF documents using the 'merge' feature. Each PDF file in that packet has to be annotated individually. It's kind of annoying—esp. when the individual PDF docs within that merged note follow a logical order. It'd be nice to be able to build, within EN, a single PDF document from individual docs.

Link to post

8 replies to this idea

Recommended Posts

  • 0

I totally agree about wanting a merge feature.  Like JMichael, I don't like Evernote's way of merging notes very much.

 

This is especially useful when using a ScanSnap with the occasional thick stack that has to be hand-fed because of low grade paper.  You can easily wind up with several notes in Evernote that ought to contain a single multi-page PDF.

 

So, I think I solved the problem on my blog.  I wrote an AppleScript to join multiple PDFs across multiple notes into a single new note with a single PDF.  This script will join PDFs in the order they appear in Evernote—by notes, and by attachments within notes.  So, if you need to reverse the sort order of the notes or PDFs, you'll need to reverse the order in the Evernote.

 

In case the link ever goes down, here's the script in full.

-- Join PDFs in multiple Evernote notes into a single PDF in a new note-- Author: John Christopher Jones <john.christopher@alumni.virginia.edu>-- Created: 2014-11-17-- inspired by--   http://applehelpwriter.com/2013/03/23/how-to-merge-pdf-files-in-os-x/-- We'll join note titles together using this string-- This isn't going to be a great title, but it'll be-- a good reminder of what's in the new note.set title_separator to " | "-- Create a temporary folder for the exported Evernote attachments-- Create an output filepath to write the joined pdf toset temp_folder to do shell script "mktemp -d -t evernote_pdf"set output_filepath to temp_folder & "/" & (do shell script "uuidgen") & ".pdf"-- XSLT used to extract hash values from en-media tags-- Crazy {} translation nonsense used to work around forum post scrubbersset xslt to "{?xml version='1.0'?}{xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'                xmlns:en='http://xml.evernote.com/pub/enml2.dtd'}    {xsl:output method='text' omit-xml-declaration='yes' indent='no'/}    {xsl:strip-space elements='*'/}    {xsl:template match='en-media'}        {xsl:value-of select='@hash'/}        {xsl:text}
{/xsl:text}    {/xsl:template}    {xsl:template match='text()|@*'}{/xsl:template}{/xsl:stylesheet}"set my text item delimiters to "{"set xslt to text items of xsltset my text item delimiters to "<"set xslt to xslt as textset my text item delimiters to "}"set xslt to text items of xsltset my text item delimiters to ">"set xslt to xslt as text-- Write XSLT to temporary locationset xslt_path to do shell script "mktemp -t evernote_enml"tell application "Finder" to write xslt to xslt_path-- Initialize some listsset hash_values to {}set pdf_list to {}set title_list to {}tell application "Evernote"	-- Loop over every attachment in every note	-- Note order follows the visible sort order in Evernote OS X Desktop Client v5.7.2	set noteList to selection	repeat with n in noteList		set the end of title_list to title of n				-- Write the ENML to a temporary file and extract the en-media hash values				set enml_text to (ENML content of n) as text		set enml_path to do shell script "mktemp -t evernote_enml"		tell application "Finder" to write enml_text to enml_path				-- Extract the hash values from the ENML temporary file using the XSLT		set hash_values to paragraphs of (do shell script "xsltproc --novalid " & (quoted form of xslt_path) & " " & (quoted form of enml_path))		-- Delete the temporary ENML file		do shell script "rm " & (quoted form of enml_path)				-- Export each attachment in the order that it appears in the note		repeat with hash_value in hash_values			-- Get the attachment that has this hash			set a to item 1 of (attachments of n whose hash is hash_value)			-- Write the attachment to the temporary folder			set pdf_path to temp_folder & "/" & (do shell script "uuidgen") & ".pdf"			write a to pdf_path			-- Save the filepath for later			set the end of pdf_list to pdf_path		end repeat	end repeat		-- We'll join PDF filepaths so that they're single-quoted and space-delimited	set my text item delimiters to "' '"		-- Join PDFs	do shell script (quoted form of "/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py") & " --output " & (quoted form of output_filepath) & " " & ("'" & (pdf_list as text) & "'")		-- Create a new note with a title constructed from the titles of the selected notes	set my text item delimiters to title_separator	set new_note to create note from file output_filepath title (title_list as text)		-- Open the newly created note in a new window so the user doesn't have to wonder	-- where the thing is and if it was actually created.	open note window with new_note		-- Delete all of the remaining temporary files	do shell script "rm -r " & quoted form of temp_folder	do shell script "rm " & quoted form of xslt_pathend tell
  • Like 1
Link to post
  • 0

@John Christopher Jones

 

You, sir, are a gentleman and a scholar! I left a comment on your blog, but wanted to thank you here as well. The script is perfect. I wish I had it a week ago when I was combining my school notes manually. This really should be an EN feature.

  • Like 1
Link to post
  • 0
  • Level 5*

There are lots of PDF tools available that will allow you to easily combine and split PDF files, as well as make comments and annotations.  Personally, I would rather Evernote spend their limited resources on other things, like bug fixes, and features that have been requested for years, like selecting the image to use as a thumbnail.  I don't see combining PDF files as something that happens that often, or would be needed by that many users.

Link to post
  • 0

There are lots of PDF tools available that will allow you to easily combine and split PDF files, as well as make comments and annotations.  Personally, I would rather Evernote spend their limited resources on other things, like bug fixes, and features that have been requested for years, like selecting the image to use as a thumbnail.  I don't see combining PDF files as something that happens that often, or would be needed by that many users.

 

I agree that Evernote has more important fish to fry, but they do place a lot of importance on PDF handling in Evernote.  They do this to the extent that they added inline PDF annotation, and they did this despite having developer access to Yosemite and recognizing that Apple would add their own system-wide PDF annotation extension in Yosemite.  Evernote wanted PDF annotation that would work across platforms.  One of the killer Evernote Premium features is priority OCR, which, while useful for the occasional JPEG and photograph of a bookshelf, really gets most of its use in PDFs.  So, something like this script might be a natural feature for them to add.

 

So, I don't blame you for wanting to warn Evernote off of yet-more PDF features in lieu of at least the dozen things we've both pointed out or read about recently.

 

That said, it really is kinda difficult to merge PDFs that are embedded in Evernote notes without something like this.

Link to post
  • 0

It looks like in Yosemite and/or with the Evernote ScanSnap, it's possible to wind up with ENML that the original version of my script won't work on.  I've updated the script to handle this situation.

 
Specifically, the problem is that PDFs are saved to Evernote as "Unnamed File Attachment".  It turns out that sometimes the filename is actually a string of invalid UTF-8 characters (0xCA 0xCA 0xCA 0xCA).  For example:
 
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note><div><en-media type="application/pdf" style="cursor:pointer;" width="100%" height="1082" hash="0760b2f2fcb5c4ce81ccae342f754b8f"/>ÊÊÊÊÊ</div></en-note>
 
Updated script reproduced below in case my link breaks for some reason:
 
-- Join PDFs in multiple Evernote notes into a single PDF in a new note-- Author: John Christopher Jones <john.christopher@alumni.virginia.edu>-- Created: 2014-11-17-- Updated: 2014-12-11 -- write utf8 and strip non-ascii characters when extracting hash values-- inspired by--   http://applehelpwriter.com/2013/03/23/how-to-merge-pdf-files-in-os-x/-- We'll join note titles together using this string-- This isn't going to be a great title, but it'll be-- a good reminder of what's in the new note.set title_separator to " | "-- Create a temporary folder for the exported Evernote attachments-- Create an output filepath to write the joined pdf toset temp_folder to do shell script "mktemp -d -t evernote_pdf"set output_filepath to temp_folder & "/" & (do shell script "uuidgen") & ".pdf"-- XSLT used to extract hash values from en-media tags-- Crazy {} translation nonsense used to work around forum post scrubbersset xslt to "{?xml version='1.0'?}{xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'                xmlns:en='http://xml.evernote.com/pub/enml2.dtd'}    {xsl:output method='text' omit-xml-declaration='yes' indent='no'/}    {xsl:strip-space elements='*'/}    {xsl:template match='en-media'}        {xsl:value-of select='@hash'/}        {xsl:text}
{/xsl:text}    {/xsl:template}    {xsl:template match='text()|@*'}{/xsl:template}{/xsl:stylesheet}"set my text item delimiters to "{"set xslt to text items of xsltset my text item delimiters to "<"set xslt to xslt as textset my text item delimiters to "}"set xslt to text items of xsltset my text item delimiters to ">"set xslt to xslt as text-- Write XSLT to temporary locationset xslt_path to do shell script "mktemp -t evernote_enml"tell application "Finder" to write xslt to xslt_path-- Initialize some listsset hash_values to {}set pdf_list to {}set title_list to {}tell application "Evernote"	-- Loop over every attachment in every note	-- Note order follows the visible sort order in the OS X Desktop Client v5.7.2	set noteList to selection	repeat with n in noteList		set the end of title_list to title of n				-- Write the ENML to a temporary file and extract the en-media hash values				set enml_text to (ENML content of n) as text		set enml_path to do shell script "mktemp -t evernote_enml"		tell application "Finder" to write enml_text to enml_path				-- Extract the hash values from the ENML temporary file using the XSLT		set hash_values to paragraphs of (do shell script "cat " & (quoted form of enml_path) & " | strings | xsltproc --novalid " & (quoted form of xslt_path) & " - ")		-- Delete the temporary ENML file		do shell script "rm " & (quoted form of enml_path)				-- Export each attachment in the order that it appears in the note		repeat with hash_value in hash_values			-- Get the attachment that has this hash			set a to item 1 of (attachments of n whose hash is hash_value)			-- Write the attachment to the temporary folder			set pdf_path to temp_folder & "/" & (do shell script "uuidgen") & ".pdf"			write a to pdf_path as «class utf8»			-- Save the filepath for later			set the end of pdf_list to pdf_path		end repeat	end repeat		-- We'll join PDF filepaths so that they're single-quoted and space-delimited	set my text item delimiters to "' '"		-- Join PDFs	do shell script (quoted form of "/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py") & " --output " & (quoted form of output_filepath) & " " & ("'" & (pdf_list as text) & "'")		-- Create a new note with a title built from the titles of the selected notes	set my text item delimiters to title_separator	set new_note to create note from file output_filepath title (title_list as text)		-- Open the newly created note in a new window so the user doesn't have to wonder	-- where the thing is and if it was actually created.	open note window with new_note		-- Delete all of the remaining temporary files	do shell script "rm -r " & quoted form of temp_folder	do shell script "rm " & quoted form of xslt_pathend tell
Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...