# Oneboxing of PDFs and other attachments

**URL:** https://meta.discourse.org/t/oneboxing-of-pdfs-and-other-attachments/55972
**Category:** Feature
**Created:** [18 januari 2017 om 16:20 UTC](https://meta.discourse.org/t/oneboxing-of-pdfs-and-other-attachments/55972 "2017-01-18T16:20:13Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [8 februari 2017 om 07:34 UTC](https://meta.discourse.org/t/oneboxing-of-pdfs-and-other-attachments/55972/6 "2017-02-08T07:34:32Z")

</div>

> [@techAPJ](#):
>
> PDF onebox using PDF metadata.

I had to revert this change, specifically _getting information from “PDF metadata”_.

The PDF metadata was being fetched using [pdf-reader](https://github.com/yob/pdf-reader) gem which introduced lots of its own dependencies. I just removed the dependency on pdf-reader gem for onebox.

Now the onebox will simply show pdf filename and filesize. This change significantly reduces time required to onebox because instead of fetching the whole file and loading it in memory we are now just making a HEAD request to get “Content-Length” for filesize and the URL contains filename.

Here is the demo of new PDF onebox:

[https://www.wired.com/images\_blogs/threatlevel/2009/12/redaction.pdf?new](https://www.wired.com/images_blogs/threatlevel/2009/12/redaction.pdf?new)

.

> **[Black\_Cat.pdf](https://www.ibiblio.org/ebooks/Poe/Black_Cat.pdf?new)**
>
> 80.34 KB

.

> **[Sample\_Syllabus\_for\_Wikipedia\_assignment.pdf](https://upload.wikimedia.org/wikipedia/commons/e/ef/Sample_Syllabus_for_Wikipedia_assignment.pdf?new)**
>
> 1993.87 KB

.

> **[ruby\_tutorial.pdf](https://www.tutorialspoint.com/ruby/ruby_tutorial.pdf?2sdas)**
>
> 991.79 KB

> [@tobiaseigen](#):
>
> my PDFs do not appear to be oneboxed

I looked into this locally. It was because of pdf title not being able to forced into UTF-8 encoding. The new onebox fixes this issue:

[https://namati.org/wp-content/uploads/2017/01/4.Evidence\_Land-Rights\_-Myanmar-2017-Final.pdf](https://namati.org/wp-content/uploads/2017/01/4.Evidence_Land-Rights_-Myanmar-2017-Final.pdf)

---

_[View the full topic](https://meta.discourse.org/t/oneboxing-of-pdfs-and-other-attachments/55972)._
