Use an asset file as the pdf source
498329
public Configurator fromAsset(String assetName) {
        try {
            File pdfFile = FileUtils.fileFromAsset(getContext(), assetName);
            return fromFile(pdfFile);
        } catch (IOException e) {
            throw new FileNotFoundException(assetName + " does not exist.", e);
        }
    }
1069713
function AssetHandler(req, res, next, local = false) {
            const parsedUrl = url.parse(req.url);
            // Check if we have an asset for that url defined.
            /** @type {Asset} */
            const asset = self.assetBundle.assetForUrlPath(parsedUrl.pathname);

            if (!asset) return next();

            const processors = () => (
                addSourceMapHeader(asset, res),
                addETagHeader(asset, res),
                addCacheHeader(asset, res, req.url)
            );

            if (local) {
                return createStreamProtocolResponse(asset.getFile(), res, processors);
            }
            return send(
                req,
                encodeURIComponent(asset.getFile()),
                { etag: false, cacheControl: false }
            )
                .on('file', processors)
                .pipe(res);
        }
929476
@Override
    public T addAsLibrary(Asset resource, ArchivePath target) throws IllegalArgumentException {
        Validate.notNull(resource, "Resource must be specified");
        Validate.notNull(target, "Target must be specified");

        ArchivePath location = new BasicPath(getLibraryPath(), target);
        return add(resource, location);
    }
1047907
def convert_asset(klass, asset)
      # Convert asset content
      converter = klass.new(asset)

      # Replace asset content and filename
      asset.content = converter.converted
      asset.filename = File.basename(asset.filename, '.*')

      # Add back the output extension if no extension left
      if File.extname(asset.filename) == ''
        asset.filename = "#{asset.filename}#{@type}"
      end
    rescue StandardError => e
      puts "Asset Pipeline: Failed to convert '#{asset.filename}' " \
           "with '#{klass}': #{e.message}"
      raise e
    end
702852
def build_assets():
    """"""
    cwd = os.getcwd()
    try:
        from webassets.script import GenericArgparseImplementation
        from django_assets.env import get_env
        prog = "%s assets" % os.path.basename(sys.argv[0])
        impl = GenericArgparseImplementation(
            env=get_env(), log=LOGGER, no_global_options=True, prog=prog)
        impl.run_with_argv(["build"])
    except ImportError:
        pass
    os.chdir(cwd)
815966
def render_asset_html(self, path, tag_template):
        
        url = os.path.join(settings.STATIC_URL, path)

        return tag_template.format(url=url)
1268933
function resolveAssetLink(client, type) {
    var defaultPath = '/assets/' + client.name + '/' + client.id + '.' + type,
      pack = options.packedAssets,
      link = pack !== undefined ? (pack.cdn !== undefined ? pack.cdn[type] : void 0) : void 0;
    if (link) {
      if (typeof link === 'function') {
        var file = {
          id: client.id,
          name: client.name,
          extension: type,
          path: defaultPath
        };
        return link(file);
      } else if (typeof link === 'string') {
        return link;
      } else {
        throw new Error('CDN ' + type + ' param must be a Function or String');
      }
    } else {
      return defaultPath;
    }
  }
262277
def get_asset_tarball(asset_name, src_dir, dest_project, dest_folder, json_out):
    
    if os.path.isdir(os.path.join(src_dir, "resources")):
        temp_dir = tempfile.mkdtemp()
        try:
            resource_file = os.path.join(temp_dir, asset_name + "_resources.tar.gz")
            cmd = ["tar", "-czf", resource_file, "-C", os.path.join(src_dir, "resources"), "."]
            subprocess.check_call(cmd)
            file_id = dx_upload(resource_file, dest_project, dest_folder, json_out)
            return file_id
        finally:
            shutil.rmtree(temp_dir)
352887
function (type, group) {
    return _.map(assetFiles(type, group), function (file) {
        return toHtml(type, path.join(config.root, fss.relative(file)));
    }).join('\n');
}
1152782
function loadAsset(asset, callback) {
        callback = callback || noop;

        function error(event) {
            event = event || win.event;

            // release event listeners
            ele.onload = ele.onreadystatechange = ele.onerror = null;

            // do callback
            callback();

            // need some more detailed error handling here
        }

        function process(event) {
            event = event || win.event;

            // IE 7/8 (2 events on 1st load)
            // 1) event.type = readystatechange, s.readyState = loading
            // 2) event.type = readystatechange, s.readyState = loaded

            // IE 7/8 (1 event on reload)
            // 1) event.type = readystatechange, s.readyState = complete

            // event.type === 'readystatechange' && /loaded|complete/.test(s.readyState)

            // IE 9 (3 events on 1st load)
            // 1) event.type = readystatechange, s.readyState = loading
            // 2) event.type = readystatechange, s.readyState = loaded
            // 3) event.type = load            , s.readyState = loaded

            // IE 9 (2 events on reload)
            // 1) event.type = readystatechange, s.readyState = complete
            // 2) event.type = load            , s.readyState = complete

            // event.type === 'load'             && /loaded|complete/.test(s.readyState)
            // event.type === 'readystatechange' && /loaded|complete/.test(s.readyState)

            // IE 10 (3 events on 1st load)
            // 1) event.type = readystatechange, s.readyState = loading
            // 2) event.type = load            , s.readyState = complete
            // 3) event.type = readystatechange, s.readyState = loaded

            // IE 10 (3 events on reload)
            // 1) event.type = readystatechange, s.readyState = loaded
            // 2) event.type = load            , s.readyState = complete
            // 3) event.type = readystatechange, s.readyState = complete

            // event.type === 'load'             && /loaded|complete/.test(s.readyState)
            // event.type === 'readystatechange' && /complete/.test(s.readyState)

            // Other Browsers (1 event on 1st load)
            // 1) event.type = load, s.readyState = undefined

            // Other Browsers (1 event on reload)
            // 1) event.type = load, s.readyState = undefined

            // event.type == 'load' && s.readyState = undefined

            // !doc.documentMode is for IE6/7, IE8+ have documentMode
            if (event.type === "load" || (/loaded|complete/.test(ele.readyState) && (!doc.documentMode || doc.documentMode < 9))) {
                // remove timeouts
                win.clearTimeout(asset.errorTimeout);
                win.clearTimeout(asset.cssTimeout);

                // release event listeners
                ele.onload = ele.onreadystatechange = ele.onerror = null;

                // do callback   
                callback();
            }
        }

        function isCssLoaded() {
            // should we test again ? 20 retries = 5secs ..after that, the callback will be triggered by the error handler at 7secs
            if (asset.state !== LOADED && asset.cssRetries <= 20) {

                // loop through stylesheets
                for (var i = 0, l = doc.styleSheets.length; i < l; i++) {
                    // do we have a match ?
                    // we need to tests agains ele.href and not asset.url, because a local file will be assigned the full http path on a link element
                    if (doc.styleSheets[i].href === ele.href) {
                        process({ "type": "load" });
                        return;
                    }
                }

                // increment & try again
                asset.cssRetries++;
                asset.cssTimeout = win.setTimeout(isCssLoaded, 250);
            }
        }

        var ele;
        var ext = getExtension(asset.url);

        if (ext === "css") {
            ele      = doc.createElement("link");
            ele.type = "text/" + (asset.type || "css");
            ele.rel  = "stylesheet";
            ele.href = asset.url;

            /* onload supported for CSS on unsupported browsers
             * Safari windows 5.1.7, FF < 10
             */

            // Set counter to zero
            asset.cssRetries = 0;
            asset.cssTimeout = win.setTimeout(isCssLoaded, 500);         
        }
        else {
            ele      = doc.createElement("script");
            ele.type = "text/" + (asset.type || "javascript");
            ele.src = asset.url;
        }

        ele.onload  = ele.onreadystatechange = process;
        ele.onerror = error;

        /* Good read, but doesn't give much hope !
         * http://blog.getify.com/on-script-loaders/
         * http://www.nczonline.net/blog/2010/12/21/thoughts-on-script-loaders/
         * https://hacks.mozilla.org/2009/06/defer/
         */

        // ASYNC: load in parallel and execute as soon as possible
        ele.async = false;
        // DEFER: load in parallel but maintain execution order
        ele.defer = false;

        // timout for asset loading
        asset.errorTimeout = win.setTimeout(function () {
            error({ type: "timeout" });
        }, 7e3);

        // use insertBefore to keep IE from throwing Operation Aborted (thx Bryan Forbes!)
        var head = doc.head || doc.getElementsByTagName("head")[0];

        // but insert at end of head, because otherwise if it is a stylesheet, it will not override values      
        head.insertBefore(ele, head.lastChild);
    }
1266587
function loadAsset (asset, varName) {
  if (varName && typeof window[varName] !== 'undefined') {
    return Promise.resolve(window[varName]);
  }

  if (typeof asset === 'string') {
    if (/\.css$/.test(asset)) {
      asset = { src: asset, type: 'css' };
    } else {
      asset = { src: asset };
    }
  }

  var tag;
  if (asset.type === 'css') {
    tag = document.createElement('link');
    tag.setAttribute('rel', 'stylesheet');
    tag.setAttribute('href', asset.src);
  } else {
    tag = document.createElement('script');
    tag.setAttribute('type', 'text/javascript');
    tag.setAttribute('src', asset.src);
  }

  return new Promise(function (resolve) {
    tag.async = true;
    tag.onreadystatechange = tag.onload = function () {
      var state = tag.readyState;
      if (!state || /loaded|complete/.test(state)) {
        resolve(varName ? window[varName] : undefined);
      }
    };
    document.getElementsByTagName('head')[0].appendChild(tag);
  });
}
874637
@Override
    public T addAsResource(Asset resource, ArchivePath target) throws IllegalArgumentException {
        Validate.notNull(resource, "Resource should be specified");
        Validate.notNull(target, "Target should be specified");

        ArchivePath location = new BasicPath(getResourcePath(), target);
        return add(resource, location);
    }
260008
def write_asset(environment, asset)
      filename = path_for(environment, asset)
      FileUtils.mkdir_p File.dirname(filename)
      asset.write_to filename
      asset.write_to "#{filename}.gz" if gzip?(filename)
      asset.digest
    end
954271
public void createAsset(String path, byte[] content) throws ServiceException {
        int lastSlash = path.lastIndexOf('/');
        File assetFile = new File(assetRoot + "/" + path.substring(0,  lastSlash).replace('.', '/') + path.substring(lastSlash));
        try {
            FileHelper.writeToFile(new ByteArrayInputStream(content), assetFile);
            AssetRevision rev = new AssetRevision();
            rev.setVersion(1);
            rev.setModDate(new Date());
            getVersionControl().setRevision(assetFile, rev);
        }
        catch (Exception ex) {
            throw new ServiceException(ServiceException.INTERNAL_ERROR, ex.getMessage());
        }
    }
874893
function buildResourceHint (hint, asset, glob) {
  var as = ''

  if (hint === 'dns-prefetch' || hint === 'preconnect') {
    if (!urlMatch(asset, glob)) {
      return ''
    }

    asset = urlParse(asset)
    if (isDuplicate(asset, true)) {
      return ''
    }
  } else {
    if (!minimatch(asset, glob) || isDuplicate(asset)) {
      return ''
    }
    if (globMatch(asset, fonts)) {
      as += ' as="font"'
    } else if (isCSS(asset)) {
      as += ' as="style"'
    }
  }

  parsedAssets.push(asset)
  return `<link rel="${hint}" href="${asset}"${as} />`
}
710226
def download(self, data, filename, content_type="application/pdf"):
        
        self.request.response.setHeader(
            "Content-Disposition", "inline; filename=%s" % filename)
        self.request.response.setHeader("Content-Type", content_type)
        self.request.response.setHeader("Content-Length", len(data))
        self.request.response.setHeader("Cache-Control", "no-store")
        self.request.response.setHeader("Pragma", "no-cache")
        self.request.response.write(data)
1278825
function extendAssets( {
   assets = [],
   assetUrls = [],
   assetsForTheme = [],
   assetUrlsForTheme = []
} = {}, source ) {
   return {
      assets: assets.concat( source.assets ),
      assetUrls: assetUrls.concat( source.assetUrls ),
      assetsForTheme: assetsForTheme.concat( source.assetsForTheme ),
      assetUrlsForTheme: assetUrlsForTheme.concat( source.assetUrlsForTheme )
   };
}