JavaScript is probably [not going to avail you here](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_output_pdf_considerations.htm): > - Don’t use standard components that aren’t easily formatted for print, or form elements such as inputs or buttons, or any component that requires JavaScript to be formatted. > - PDF rendering doesn’t support JavaScript-rendered content. Although I cannot say I've tried it in this context. You can achieve this with a fairly simple controller extension, although the fact that you're using field sets does complicate the Apex slightly because one must pull the fields and construct a dynamic SOQL query rather than relying upon the Visualforce page's standard controller to handle the dependencies. Something like the skeleton below should do the trick, but I'm a little leery of steering you down this road without some Apex knowledge. You'll need to try this out, possibly adapt it to your org, wire this up to your page with an `extensions=` attribute, and you *must* add a test class to be able to deploy it to production. If you don't have time to work on your development, you may not want to start down this road - or you may need to work with a developer. (Please also note that I haven't testing this actual code in my dev org. I hope it's a useful starting point). public with sharing class ContactSortingExtension { private ApexPages.StandardController controller; public ContactSortingExtension(ApexPages.StandardController c) { controller = c; } public List<Opportunity> getOpportunities() { Id accountId; List<String> fields = new List<String>(); String baseQuery = 'SELECT {0} FROM Opportunity WHERE AccountId = \'{1}\' ORDER BY CloseDate DESC'; accountId = (Account)controller.getRecord().Id; for (Schema.FieldSetMember f : Schema.SObjectType.Opportunity.fieldSets.Opp_Set.getFields()) { fields.add(f.getFieldPath()); } return Database.query( String.format(baseQuery, new List<String>{ String.join(fields, ', '), accountId } ) ); } }