I had been receiving quite a number of inquiries regarding my video on how to create annotations in PDF.JS.

First and foremost, I call my web application Annotationeer. It is built on top of PDF.JS. It has the following annotations:

  • Square fill
  • Square border
  • Circle fill
  • Circle border
  • Stamp
  • Arrow
  • Sticky note
  • Measurement distance (like in Adobe Acrobat tool)
  • Measurement area (like in Adobe Acrobat tool)
  • Audio (in MP3 or OGG)
  • Free hand drawing
  • Free hand text (1 liner)
  • Text Underline
  • Text Highlight
  • Text Strike-through

All annotations come with a comment and properties like background and foreground color, measurement units in inches, centimeter or millimeter and font size to name a few. These same annotations can be accessed through the sidebar as a list where you can scroll through as well as a comments popup window to initiate a chat history for every annotation.

Some nifty features that can be configured based on the user’s preference:

  • Scales annotations based on zoom value
  • Rotates annotations based on page rotation angle
  • Tooltips
  • Showing annotation list in the left or right sidebar
  • Saving all annotations using the save button or through every action
  • Watermark in every page
  • Screenshot of a selected dragged area in the page converted to an image
  • Property popup to modify annotation properties
  • Comment popup to modify and add reply comments
  • Runs on any PDF.JS version.

These annotations are saved and retrieved through RESTful URLs that I created using Silex PHP Framework and using MySQL as database while producing outputs in JSON format.

The web application can run in IE and Webkit based browsers like Chrome and Firefox and works on mobile browsers and usable when integrated in hybrid apps.

Annotationeer also comes with a utility where users can import the annotations that they saved in PDF.JS to a physical PDF file using iText. I have managed to create code in both Java and C#.

Here is a custom function I made that will delete all files in a folder older than N time.

Time here can be minutes, seconds or hours by using the strtotime() function. So for example, if you want to delete old files less than 4 hours, you can call strtotime(‘-4 hours’).

You only need 3 headers to make this work and 1 or 2 more lines after that. That is all you need to add in order to have any binary file to force download itself whenever the PHP file is called.

The path to file variable is the absolute path of the file that you wish to have the user force download it.

The 3 headers are important, otherwise they won’t work. The basename function is also important in case you might pass a variable that contains the absolute path of the filename and we do not want other users to see the file structure of your server.

The basename function removes all directory paths and returns the name of the file itself.

That’s it! Easy, right?

Related Posts Plugin for WordPress, Blogger...