Creating Localized PDFs in the Sitecore Media Library

Content

Sitecore makes it very simple to create multiple language versions of page and component items but it's not so obvious how to do the same with PDFs. By default Sitecore will create PDF items using the Unversioned PDF template meaning that the uploaded media file is shared across all languages. Here are three ways to get around this.

Upload Files (Advanced)

By far the simplest method is to train/instruct your content authors to use the Upload Files (Advanced) option when uploading files. This dialog provides a checkbox titled 'Make uploaded media items versionable', checking this box will create the media items using the Versioned PDF template allowing authors to then upload media files per language version of the media item.

Upload Files (Advanced)

Upload Files (Advanced)

Extend the uiUpload Pipeline

Option one is the simplest option but what if you want to automatically enforce that all PDFs uploaded can be translated without having to rely on content authors remembering to use the Upload Files (Advanced) option and then remembering to check the versionable checkbox? the uiUpload pipeline runs every time a media file is uploaded to the media library. To do this we can add a custom processor to the upUpload pipeline that runs after Sitecore's Save processor.

In your custom class you can then detect whether the media item just uploaded is based on the Unversioned PDF template and switch it to the Versioned PDF template.

Custom Media Templates

Option 3 is an option you might want to consider if you also want to customize the fields on your PDF template. For example you might want to allow a content author to assign a document type to a PDF. Create a new template and add Versioned PDF to the list of the templates base templates. Add your custom fields to the template.

You can now add your custom template as an insert option. I would recommend doing this using the rules engine. Under the item /sitecore/system/Settings/Rules/Insert Options/Rules add a new item based on the Insert Options Rule template and edit the rule like so (replacing 'specific template' with your custom template):

Insert Option Rule

Insert Option Rule

Now content authors can create items under media folders using your custom template. The next step for the author is to select which language version they want to edit and then attach the media file to that version.

So there you have it, 3 options for localized PDFs in the Sitecore content management system.