Method: HexaPDF::Type::FileSpecification#path

Defined in:
lib/hexapdf/type/file_specification.rb

#pathObject

Returns the path for the referenced file or URL. An empty string is returned if no file specification string is set.

If multiple file specification strings are available, the fields are search in the following order and the first one with a value is used: /UF, /F, /Unix, /Mac, /DOS.

The encoding of the returned path string is either UTF-8 (for /UF) or BINARY (for /F /Unix, /Mac and /DOS).



111
112
113
114
115
116
# File 'lib/hexapdf/type/file_specification.rb', line 111

def path
  tmp = (self[:UF] || self[:F] || self[:Unix] || self[:Mac] || self[:DOS] || '').dup
  tmp.gsub!(/\\\//, "/") # PDF2.0 s7.11.2.1 but / in filename is interpreted as separator!
  tmp.tr!("\\", "/") # always use slashes instead of back-slashes!
  tmp
end