Forum moved here!

Home / [Advanced Tips] Add your own Notes

GitHubRulesOK

Many users request some way to add their own notes to PDF or other supported Read Only file formats like .xps Note this is different to the simpler request to add a comment via annotation which is done using a pre-release version

This is easily achieved (with some limitations) in current version

Notes:
There will be a few cases where this will not work due to file structures.

There can be problems when switching book modes since the page number will usually be the one of the left pair.

My example will create one new file per “Page” you can reduce that to one .NOTE.txt file per PDF easily but will need to then search that file for the corresponding page note.

You can add automatic time logging as shown but need to be aware how it works (Notepad will add a time and date opened to the end of the file if the first line is .LOG i.e. that is a dot followed by uppercase log)

So how is this done?

SumatraPDF can call notepad with the current filename and page number so in Settings > Advanced Options you will see

ExternalViewers [
]

if you change that to the following entry

 ExternalViewers [
  	[
		CommandLine = C:\windows\system32\Notepad.exe "%1.Page%p.txt"
		Name = Notepad the Notes for &This page
		Filter = *.*
	]
  ]

Then use ALTFT (note F N is for reName and F P is Print)
or use the file menu entry half-way down

it will tell notepad to open a filename.PAGE#.txt

On the first run it will ask if you want to create the file

Simply hit enter or Y or click the button
(No will keep notepad open not really useful) and
if you changed your mind simply click Cancel

IF you want to log the times the file is opened then on the first line write .LOG (don’t forget the dot)

When you finish adding notes don’t forged to “Save” the file

On subsequent runs you won’t get the yes no options but must always remember to save the notes file.

If you don’t want to litter the file folder with pages of notes but only one notes file per original then change the command to this

 ExternalViewers [
  	[
		CommandLine = C:\windows\system32\Notepad.exe "%1.Notes.txt"
		Name = Notepad the Notes for &This file
		Filter = *.*
	]
  ]

If you have a notes editor that accepts a command line search and place page markers such as [3] then you could have one file and a command like editor.exe "%1.Notes.txt" find"[%p]"

NotePad is very basic and notes cut and pasted will at best be plain text
The next best onboard option is to use Write.exe (WordPad) this application has many advantages and one or two major disadvantage.
The first hurdle is that WordPad will NOT offer to open a given notes file if it does not exist, it will usually close itself. So If you remember to always put a starter.docx or .odt alongside the PDF this will not be a problem.
The main advantages with using WordPad are

  1. You can copy and paste images as well as text.
  2. WordPad can keep one file open to be added to over and over (no need for a file per page or closing NotePad for each call).
  3. Some users can utilize the built-in spell checking.
  4. You can print your notes to PDF

You can use a script to open WordPad with a search for [Page-Tag] along with adding a timestamp. The following WordPad example can be used as a template.

' A Template script to call from within SumatraPDF to "Open" an editor such as
' Gwennel (Featured) NotePad (Quick) or WordPad (Open/Rich File Compatability)
'
' so as to add a file for collecting cuttings / notes etc. alongside the source
' file. It will not edit / change the viewed file. That needs either a seperate
' application such as MuPDF-GL or extending the internal annotation feature of
' SumatraPDF, however such an extension would not work with ALL file formats.
'
' Expects filename parameters "Full Path\FileName.Ext" followed by page Number
' OR the above plus an optional editors .FileType (e.g. .DOC, .ODT, .RTF, .etc)
'
' Typical Usage:-
' "%windir%\System32\wscript.exe" "Path\ThisFile.vbs" "Path\FileName.pdf.EXT" ##
'
' Where 
' .pdf could be ANY filetype such as EPUB, JPG or any other file type that can
' be viewed in SumatraPDF for which you wish to keep external related notes.
' .EXT is the editor format such as .docx/.odt/.rtf/.txt
' and ## is the page number for tagging
'
' SumatraPDF will be used to vary Path\FileName.pdf & ## by using the Settings
' Advanced Options variables in SumatraPDF-settings.txt so needs an extra entry 
' in the ExternalViewers section similar to this
'
' ExternalViewers [
'  	[
'		CommandLine = "c:\windows\System32\wscript.exe" "C:\Apps\Test\thisfile.vbs" "%1.DOCX" %p
'		Name = Wordpad Scrip&t
'		Filter = *.*
'	]
' ]
'
' Note The path to ThisFile.vbs will need to be where ThisFile is located
'      .DOCX needs to be the filetype for your choice of editor
'      Name = can be anything and the `&t` determines the shortcut key as T
'
' At your own risk the alternative call option to switch formats described below can be
' "%windir%\System32\wscript.exe" "Path\ThisFile.vbs" "Path\FileName.ext" ## .EXT
' Beware if it misfires the editor may attempt to open that ".ext" source document
'
' All of the above comments can be deleted in your own working copy
'
FullName = WScript.Arguments.Item(0)
PageNum = WScript.Arguments.Item(1)
'
'* Remove ' on next line to include filetype e.g write can switch between .doc/.odt/.rtf/.txt
'FileType = WScript.Arguments.Item(2)
'
Set WshShell = WScript.CreateObject("WScript.Shell")
'
'* If you use Gwennel you will need to prefix with its path\Gwennel.exe
'* for NotePad use "%windir%\NotePad.exe " for WordPad use "%windir%\write.exe "
'  WshShell.Run "Gwennel.exe "+""""+FullName+FileType+"""", 9
'  WshShell.Run "%windir%\NotePad.exe "+""""+FullName+FileType+"""", 9
WshShell.Run "%windir%\Write.exe "+""""+FullName+FileType+"""", 9

' Give Editor time to load so lets first use part of that time to
' calculate date then add say another 1000 millisecs for slow starters
dtmNow = Now()
   dtmDay = Day(dtmNow)
   dtmMonth = Month(dtmNow)
   dtmYear = Year(dtmNow)
isoDate = dtmYear & "-" & Right(0 & dtmMonth,2) & "-" & Right(0 & dtmDay,2)
'
' ensure this value is not too low otherwise the following commands will fail
' with larger notes files this delay may need to be increased
'
WScript.Sleep 1000
'* WordPad/Write is often slow to start (if not already open) so add +1 second
WScript.Sleep 1000

' start find
' Lets default from just below known HOME position just incase
' .LOG or a WordPad window is reused (i.e. unique instance)
WshShell.SendKeys "^{HOME}{DOWN}{ENTER}"
WScript.Sleep 100

'* for Gwennel % E F keys MUST be separated
'WshShell.SendKeys "%"
'WshShell.SendKeys "E"
'WshShell.SendKeys "F"

'* for NotePad send keys together and ensure
' we are searching Down with cleared buffer
'WshShell.SendKeys "%EF"
'WshShell.SendKeys "%D%n{DEL}"

'* for WordPad %H keys separated will not work
WshShell.SendKeys "%H"
WshShell.SendKeys "FD"

' Give Dialog Box time to load
WScript.Sleep 2000

' For WordPad we NEED extra +"{ENTER}" but NOT for Gwennel
' remove second +"{ENTER}" on next line for Gwennel
WshShell.SendKeys "Page-"+PageNum+"{ENTER}"+"{ENTER}"

' Close Dialog Box(s)
WshShell.SendKeys "{ESCAPE}{ESCAPE}"

'If tag found move to above either way insert new tag on current line
WshShell.SendKeys "{HOME}"
WshShell.SendKeys "*[Page-"+PageNum+"] " & isoDate & " " & Time
WshShell.SendKeys "{ENTER}{ENTER}{UP}"
'
'end of script file

So here my Advanced settings comandline is

  CommandLine = "c:\windows\System32\wscript.exe" "C:\Apps\Test\thisfile.vbs" "%1.docx" %p 

And having placed a companion thisfile.txt.docx in that folder I can add my notes like this
image

The above examples are using the tools Microsoft include in Windows
However you can apply exactly the same techniques using any prefered editor

Here is an example where I read in SumatraPDF then use a cloud synchronized MarkDown editor (actually here I am in portable offline mode)
Then as I take my notes in text format I can export to PDF (or HTML) to preview my changes as I edit in a new window

image

HaroldHaan

Hola, soy Harold Aguirre y estoy iniciando mi camino en el campo de la programación, es decir, todavía estoy procurando aprender, sin embargo, tengo una consulta. En el documento que publicaste, explicas la manera en que se puede agregar un “bloc de notas” para poder realizar anotaciones en los PDF’s, mi duda es: Entiendo que para el bloc de notas debemos dirigirnos a “Configuración avanzada” y añadir un nuevo texto en “Externalviewers” ¿Debo hacer lo mismo si deseo utilizar el “wordpad”, quiero decir, debo escribir el código que mencionas para añadir un script, en “Externalviewers”?
Gracias por la atención.

[Google Translate]

Hello, I am Harold Aguirre and I am starting my way in the field of programming, that is, I am still trying to learn, however, I have a query. In the document you published, you explain the way in which you can add a “notebook” to be able to make annotations in the PDF’s. My question is: I understand that for the notebook we must go to “Advanced settings” and add a new one. text in “Externalviewers” Should I do the same if I want to use the “wordpad”, I mean, should I write the code you mention to add a script, in “Externalviewers”?
Thanks for your attention.

GitHubRulesOK

Yes I have edited and updated the example script above to hopefully make that clearer

For SumatraPDF to run any external “Open in” command such as a web browser etc.you need to add it to ExternalViewers there is a total visible max of 10 (incuding any SumatraPDF may add automatically) but with filters that can be more

The target in this case is the wscript.exe command
then change the Name = as you like.

Note the shortcut is defined by & so in this case English ALT + F + T
(Español = ALT+A+T)

ExternalViewers [
  	[
		CommandLine = "c:\windows\System32\wscript.exe" "C:\Apps\Test\thisfile.vbs" "%1.docx" %p
		Name = Wordpad Scrip&t
		Filter = *.*
	]
  	[
		CommandLine = "a second exe" "%1" %p
		Name = Whatever &2
		Filter = *.*
	]
  ]
charenton

(next update) insert a note.
Its should be a big pregress.
Best regards,