module Jekyll::DistorteD::Molecule::PDF
Constants
- CONTAINER_ATTRIBUTES
developer.mozilla.org/en-US/docs/Web/HTML/Element/object#Attributes
- FLOAT_INT_FRAGMENT
- OUTER_LIMITS
- PDF_OPEN_PARAMS
- RESERVED_CHARACTERS_FRAGMENT
www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf
Adobe's
PDF
Open Parameters documentation sez: “Individual parameters, together with their values (separated by & or #), can be no greater then 32 characters in length.” …but then goes on to show some examples (like `comment`) that are clearly longer than 32 characters. Dunno. I'll err on the side of giving you a footgun.Keep the
PDF
Open Params in the order they are defined in the Adobe documentation, since it says they should be specified in the URL in that same order.“You cannot use the reserved characters =, #, and &. There is no way to escape these special characters.”
- ZERO_TO_ONE_HUNDRED
Public Instance Methods
Generate a Hash of our PDF
Open Params based on any given to the Liquid tag and any loaded from the defaults. www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf
# File lib/distorted-jekyll/media_molecule/pdf.rb, line 68 def pdf_open_params PDF_OPEN_PARAMS.reduce(Hash[]) {|params, compound| # Only include those params whose user-given value exists and differs from its default. params.tap { |p| p.store(compound.element, abstract(compound.element)) unless [ nil, ''.freeze, compound.default, ].include?(abstract(compound.element)) } } end
Generate the URL fragment version of the PDF
Open Params. This would be difficult / impossible to construct within Liquid from the individual variables, so let's just do it out here.
# File lib/distorted-jekyll/media_molecule/pdf.rb, line 82 def pdf_open_params_url pdf_open_params.map{ |(k,v)| case when k == :search # The PDF Open Params docs specify `search` should be quoted. "#{k}=\"#{v}\"" when Cooltrainer::BOOLEAN_VALUES.include?(v) # Convert booleans to the numeric representation Adobe use here. "#{k}=#{v ? 1 : 0}" else "#{k}=#{v}" end }.join('&') end