Upload PDF Files

Many legal documents are in fact in .pdf and not in .txt format. To upload those we will use the package “pdftools”.

# Activate package
library(pdftools)

It is important to note that only pdfs with embedded digital texts can be uploaded. Scanned images of a text first need to undergo OCR – Optical Character Recognition. Today, we will work with the Universal Declaration of Human Rights as an example.

# Download a .pdf version of the Universal Declaration of Human Rights directly into R from the internet.
human_rights <- pdf_text("https://www.ohchr.org/EN/UDHR/Documents/UDHR_Translations/eng.pdf")

The pdf_text() function converts each page into an element in your object. The Universal Declaration is 8 pages long. It has thus been converted into a list with 8 elements.

# If we want to look at page 5, simply specify the number of that page.

human_rights[5]
 ##  
[1] "    1. Men and women of full age, without any limitation due to race, nationality\r\n        or religion, have the right to marry and to found a family. They are entitled\r\n        to equal rights as to marriage, during marriage and at its dissolution.\r\n    2. Marriage shall be entered into only with the free and full consent of the\r\n        intending spouses.\r\n    3. The family is the natural and fundamental group unit of society and is\r\n        entitled to protection by society and the State.\r\nArticle 17\r\n    1. Everyone has the right to own property alone as well as in association with\r\n        others.\r\n    2. No one shall be arbitrarily deprived of his property.\r\nArticle 18\r\nEveryone has the right to freedom of thought, conscience and religion; this right\r\nincludes freedom to change his religion or belief, and freedom, either alone or in\r\ncommunity with others and in public or private, to manifest his religion or belief in\r\nteaching, practice, worship and observance.\r\nArticle 19\r\nEveryone has the right to freedom of opinion and expression; this right includes\r\nfreedom to hold opinions without interference and to seek, receive and impart\r\ninformation and ideas through any media and regardless of frontiers.\r\nArticle 20\r\n    1. Everyone has the right to freedom of peaceful assembly and association.\r\n    2. No one may be compelled to belong to an association.\r\nArticle 21\r\n"

access_time Last update May 8, 2020.

chat networking coding local-network layer menu folders diagram panel route line-chart compass search flow data-sharing search-1 message target translator candidates studying chat networking coding local-network layer menu folders diagram panel route line-chart compass search flow data-sharing search-1 message target translator candidates studying