<p>It's probably not possible to determine the actual font size, at least not without knowing the exact font and its specifications. <a href="https://graphicdesign.stackexchange.com/questions/4035/what-does-the-size-of-the-font-translate-to-exactly">see here for an explanation of why</a></p>

<p>If you just want to compare font size between documents, it might be sufficient to use average line height as the comparison, which might be easier to do. If you don't care about the actual values and only need to know relative size between documents, the following might work. You would have to consider, or avoid, the potential effect of different document sizes and/or DPI.</p>

<pre><code>library(tesseract)
library(dplyr)
library(tidyr)

df &lt;- ocr_data("http://arxiv.org/pdf/1403.2805.pdf")

df %&gt;% 
  separate(bbox, c('x1', 'y1', 'x2', 'y2'), convert = T) %&gt;% 
  mutate(line_height = y2 - y1) %&gt;% 
  summarise(avg_line_height = mean(line_height))

# # A tibble: 1 x 1
#   avg_line_height
#             &lt;dbl&gt;
# 1            58.7
</code></pre>

<p>example for average letter height and width....</p>

<pre><code>df %&gt;%
  separate(bbox, c('x1', 'y1', 'x2', 'y2'), convert = T) %&gt;%
  mutate(word_height = y2 - y1) %&gt;%
  mutate(word_width = x2 - x1) %&gt;%
  mutate(num_letters = nchar(word)) %&gt;%
  mutate(avg_letter_width = word_width / num_letters) %&gt;%
  summarise(avg_letter_height = mean(word_height),
            avg_letter_width = mean(avg_letter_width))

# # A tibble: 1 x 2
#   avg_letter_height avg_letter_width
#               &lt;dbl&gt;            &lt;dbl&gt;
# 1              58.7             37.3
</code></pre>

<p>and if you want to do it per page, you can use <code>pdftools</code> to render each page of a multi-page PDF individually and the run <code>ocr_data</code> on each one, then combine...</p>

<pre><code>library(pdftools)
library(tesseract)
library(dplyr)
library(tidyr)

download.file(url = "http://arxiv.org/pdf/1403.2805.pdf",
              destfile = pdf_path &lt;- tempfile(fileext = ".pdf"))

page_pngs &lt;-
  lapply(seq_len(pdf_info(pdf_path)$pages), function(page_num) {
    pdf_convert(pdf_path, pages = page_num, dpi = 300)
  })

df &lt;-
  bind_rows(
    lapply(seq_len(length(page_pngs)), function(page_num) {
      ocr_data(page_pngs[[page_num]]) %&gt;%
        separate(bbox, c('x1', 'y1', 'x2', 'y2'), convert = T) %&gt;%
        mutate(word_height = y2 - y1) %&gt;%
        mutate(word_width = x2 - x1) %&gt;%
        mutate(num_letters = nchar(word)) %&gt;%
        mutate(avg_letter_width = word_width / num_letters) %&gt;%
        mutate(page = page_num) %&gt;%
        select(page, letter_height = word_height, letter_width = avg_letter_width)
    })
  )

df %&gt;%
  group_by(page) %&gt;%
  summarise(avg_letter_height = mean(letter_height),
            avg_letter_width = mean(letter_width)) %&gt;%
  mutate(avg_letter_area = avg_letter_height * avg_letter_width)

# # A tibble: 29 x 4
#     page avg_letter_height avg_letter_width avg_letter_area
#    &lt;int&gt;             &lt;dbl&gt;            &lt;dbl&gt;           &lt;dbl&gt;
#  1     1              29.4             17.9            525.
#  2     2              29.3             18.9            554.
#  3     3              30.0             19.1            574.
#  4     4              30.2             18.7            565.
#  5     5              29.8             19.0            566.
#  6     6              28.2             17.7            498.
#  7     7              28.9             18.3            529.
#  8     8              29.8             18.6            554.
#  9     9              29.1             18.6            541.
# 10    10              28.3             18.3            519.
# # ... with 19 more rows
</code></pre>
Extracting character font size from PDF files with R
<p>I've been trying to reproduce a similar dataset (not exactly the same, I stress) explained in this <a href="https://pdfs.semanticscholar.org/7955/9bc8cff7f81699a63e8c43548753041cd920.pdf" rel="nofollow noreferrer">paper</a> for a similar purpose. But I'm having trouble in coming up with an idea for getting font size while coding in R. Other solutions seem to be available in other coding languages.  </p>

<p>For instance, one could very easily extract information regarding number of characters in a page or transforming each page in a image and obtaining data regarding number of pixels and such - which will be part of my metadata anyway. Such as in the example below:</p>

<pre><code>library(pdftools)
library(png)

download.file("http://arxiv.org/pdf/1403.2805.pdf", "1403.2805.pdf", mode = "wb")

txt &lt;- pdf_text("1403.2805.pdf")

num_char_page = unlist(lapply(txt,nchar))

height = 1:length(txt)
width =1:length(txt)

for (i in 1:length(txt)) {

  bitmap &lt;- pdf_render_page("1403.2805.pdf", page = i)

  png::writePNG(bitmap, paste0("page",i,".png"))

  photo=readPNG(paste0("page",i,".png"))

  height[i]  = dim(photo)[1]

  width[i] = dim(photo)[2]

}

layout_df = data.frame(page=1:length(txt), num_char_page=num_char_page, height=height, width=width)
</code></pre>

<p>So this is fairly straightforward, although the code could be made faster with some lapply version of it in the loop part (maybe). But I have no idea on how to obtain font size. How would I do it? Specially if we assume a scanned version of the documents, such as in the aforementioned paper.</p>

<hr>

<p><strong>Observation</strong>: I will ask it in a separate question probably, but I would cherish if someone could pinpoint to some ideas regarding margin sizes and spacing between lines in the comments.</p>

<p><strong>Second Observation</strong>: I think (in this particular case) the PDF that I've used as an example could have meta-data which could enable font-size extraction. But I am trying to obtain font size from scanned (and maybe OCR'd) PDFs. One could transform the pages of the PDF (in the example) into images and then transform them again into non-OCR'd PDFs, which might be somewhat similar to the scanned PDF situation.   </p>