README.md in pdfjs_viewer-rails-0.1.0 vs README.md in pdfjs_viewer-rails-0.2.0

- old
+ new

@@ -84,9 +84,65 @@ * errors (default) * warnings * infos +### Customizing the viewer + +If you're not happy with the 3 different styles with which pdfjs_viewer-rails is shipped, you can make your own adjustments by creating a file in `app/views/pdfjs_viewer/viewer/_extra_head.html.erb`. This file will be appended to the viewer's `<head>` tag. + +So for example, if you'd like to hide the print icon: + +```erb +<!-- app/views/pdfjs_viewer/viewer/_extra_head.html.erb --> + +<style> + #print { display: none; } +</style> +``` + +NOTE: You can use the parameters you passed into `pdfjs_viewer` (if you're using the helper): + +```erb +<!-- Somewhere in a view in your project --> +<%= pdfjs_viewer style: "reduced", something: "sick!" %> +``` + +and then access them: + +```erb +<!-- app/views/pdfjs_viewer/viewer/_extra_head.html.erb --> + +<%= tag.meta name: "something", content: something %> +``` + +### Setting up CORS + +If you plan to load PDFs from that are hosted on another domain from the +PDF.js viewer, you may need to set up a Cross-Origin Resource Sharing (CORS) +Policy to allow PDF.js to read PDFs from your domain. If you're serving PDFs +straight from Amazon S3 (e.g. `bucket.s3-us-west-1.amazonaws.com`), you will +need to add a CORS policy to the S3 bucket. This CORS configuration has been +tested on S3: + +```xml +<?xml version="1.0" encoding="UTF-8"?> +<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01"> + <CORSRule> + <AllowedOrigin>*</AllowedOrigin> + <AllowedMethod>GET</AllowedMethod> + <AllowedMethod>HEAD</AllowedMethod> + <MaxAgeSeconds>3000</MaxAgeSeconds> + <AllowedHeader>Range</AllowedHeader> + <AllowedHeader>Authorization</AllowedHeader> + <ExposeHeader>Accept-Ranges</ExposeHeader> + <ExposeHeader>Content-Encoding</ExposeHeader> + <ExposeHeader>Content-Length</ExposeHeader> + <ExposeHeader>Content-Range</ExposeHeader> + </CORSRule> +</CORSConfiguration> +``` + ## Development Tests can be executed with: ```