output the pdf code, streaming it to the browser
the relevant headers are set so that hopefully the browser will recognise it
977884
function stream($options =  '') {
    // setting the options allows the adjustment of the headers
    // values at the moment are:
    // 'Content-Disposition' => 'filename'  - sets the filename, though not too sure how well this will
    //        work as in my trial the browser seems to use the filename of the php file with .pdf on the end
    // 'Accept-Ranges' => 1 or 0 - if this is not set to 1, then this header is not included, off by default
    //    this header seems to have caused some problems despite tha fact that it is supposed to solve
    //    them, so I am leaving it off by default.
    // 'compress' = > 1 or 0 - apply content stream compression, this is on (1) by default
    // 'Attachment' => 1 or 0 - if 1, force the browser to open a download dialog
    if  (!is_array($options)) {
      $options =  array();
    }

    if  ( headers_sent())
      die("Unable to stream pdf: headers already sent");

    $debug = empty($options['compression']);
    $tmp =  ltrim($this->output($debug));

    header("Cache-Control: private");
    header("Content-type: application/pdf");

    //FIXME: I don't know that this is sufficient for determining content length (i.e. what about transport compression?)
    header("Content-Length: " . mb_strlen($tmp, '8bit'));
    $fileName =  (isset($options['Content-Disposition']) ?  $options['Content-Disposition'] :  'file.pdf');

    if  ( !isset($options["Attachment"]))
      $options["Attachment"] =  true;

    $attachment =  $options["Attachment"] ?  "attachment" :  "inline";

    header("Content-Disposition: $attachment; filename=\"$fileName\"");

    if  (isset($options['Accept-Ranges']) &&  $options['Accept-Ranges'] ==  1) {
      //FIXME: Is this the correct value ... spec says 1#range-unit
      header("Accept-Ranges: " . mb_strlen($tmp, '8bit'));
    }

    echo  $tmp;
    flush();
  }
1233861
def execute(self):
        
        if self.direct:
            if self.file_type == 'pdf':
                raise IOError(u"Direct output mode is not available for PDF "
                               "export")
            else:
                print(self.render().encode(self.encoding))
        else:
            self.write_and_log()

            if self.watch:
                from landslide.watcher import watch

                self.log(u"Watching %s\n" % self.watch_dir)

                watch(self.watch_dir, self.write_and_log)
916038
def generate_content
      @pdf = Prawn::Document.new(
        info: self.metadata,
        top_margin: @format[:header_size] + @format[:top_margin],
        bottom_margin: @format[:footer_size] + @format[:bottom_margin]
      )
      add_page_body
      add_page_header
      add_page_footer
      add_page_numbering
    end
1349385
public function stream($filename = "document.pdf", $options = array())
    {
        if (headers_sent()) {
            die("Unable to stream pdf: headers already sent");
        }

        if (!isset($options["compress"])) $options["compress"] = true;
        if (!isset($options["Attachment"])) $options["Attachment"] = true;

        $this->_add_page_text();

        $debug = !$options['compress'];
        $tmp = ltrim($this->_pdf->output($debug));

        header("Cache-Control: private");
        header("Content-Type: application/pdf");
        header("Content-Length: " . mb_strlen($tmp, "8bit"));

        $filename = str_replace(array("\n", "'"), "", basename($filename, ".pdf")) . ".pdf";
        $attachment = $options["Attachment"] ? "attachment" : "inline";
        header(Helpers::buildContentDispositionHeader($attachment, $filename));

        echo $tmp;
        flush();
    }
550972
function runHtmlCodeSniffer() {
			return new Promise((resolve, reject) => {
				window.HTMLCS.process(options.standard, window.document, error => {
					if (error) {
						return reject(error);
					}
					resolve(window.HTMLCS.getMessages());
				});
			});
		}
93495
def pdf_result(pdf_binary: bytes,
               extraheaders: TYPE_WSGI_RESPONSE_HEADERS = None,
               filename: str = None) -> WSGI_TUPLE_TYPE:
    
    extraheaders = extraheaders or []
    if filename:
        extraheaders.append(
            ('content-disposition', 'inline; filename="{}"'.format(filename))
        )
    contenttype = 'application/pdf'
    if filename:
        contenttype += '; filename="{}"'.format(filename)
    # log.debug("type(pdf_binary): {}", type(pdf_binary))
    return contenttype, extraheaders, pdf_binary
747103
def check_ocrmypdf(input_file, output_file, *args, env=None):
    ""

    p, out, err = run_ocrmypdf(input_file, output_file, *args, env=env)
    if p.returncode != 0:
        print('stdout\n======')
        print(out)
        print('stderr\n======')
        print(err)
    #assert p.returncode == 0
    #assert os.path.exists(output_file), "Output file not created"
    #assert os.stat(output_file).st_size > 100, "PDF too small or empty"
    return output_file
655578
def dump(self, stream):
        
        if self.prettyprint:
            self.indent(self.xml)
        document = etree.ElementTree(self.xml)
        header = '<?xml version="1.0" encoding="%s"?>' % self.encoding
        stream.write(header.encode(self.encoding))
        document.write(stream, encoding=self.encoding)
910212
function stream($filename, $options = null) {
		//Helpers::dompdf_debug("trace", "($filename, $options)");

		// Add page text
		$this->_add_page_text();
		$this->_add_internal_links();

		// TCPDF expects file name with extension (cf. Cpdf expects file name without extension) //***
		if (!preg_match('/\.pdf$/', $filename))
			$filename .= ".pdf";

		$options["Content-Disposition"] = $filename;

		if ( isset($options["compress"]) && $options["compress"] == 0 )
		$compress = false;
		else
		$compress = true;

		$this->_pdf->SetCompression($compress);

		$this->_pdf->Output($filename, $options["Attachment"] ? "D" : "I"); // ***
	}
872858
def Main(url):
    '''
    
    '''
    # The object of Web-scraping.
    web_scrape = WebScraping()
    # Set the object of reading PDF files.
    web_scrape.readable_web_pdf = WebPDFReading()
    # Execute Web-scraping.
    document = web_scrape.scrape(url)
    # The object of automatic sumamrization.
    auto_abstractor = AutoAbstractor()
    # Set tokenizer. This is japanese tokenizer with MeCab.
    auto_abstractor.tokenizable_doc = MeCabTokenizer()
    # Object of abstracting and filtering document.
    abstractable_doc = TopNRankAbstractor()
    # Execute summarization.
    result_dict = auto_abstractor.summarize(document, abstractable_doc)
    # Output summarized sentence.
    [print(sentence) for sentence in result_dict["summarize_result"]]
333685
function PDFDocument_checkHeader() {
      var stream = this.stream;
      stream.reset();
      if (find(stream, '%PDF-', 1024)) {
        // Found the header, trim off any garbage before it.
        stream.moveStart();
        // Reading file format version
        var MAX_VERSION_LENGTH = 12;
        var version = '', ch;
        while ((ch = stream.getByte()) > 0x20) { // SPACE
          if (version.length >= MAX_VERSION_LENGTH) {
            break;
          }
          version += String.fromCharCode(ch);
        }
        if (!this.pdfFormatVersion) {
          // removing "%PDF-"-prefix
          this.pdfFormatVersion = version.substring(5);
        }
        return;
      }
      // May not be a PDF file, continue anyway.
    }
1205640
def output(self):
        
        return luigi.LocalTarget(path=self.path(digest=True, ext='html'))
910178
def emit_pdf(outputs, options):

    ''''''

    cmd = options.pdf_cmd
    cmd = cmd.replace('%o', options.pdfname)
    if len(outputs) > 2:
        cmd_print = cmd.replace('%i', ' '.join(outputs[:2] + ['...']))
    else:
        cmd_print = cmd.replace('%i', ' '.join(outputs))
    cmd = cmd.replace('%i', ' '.join(outputs))

    if not options.quiet:
        print('running PDF command "{}"...'.format(cmd_print))

    try:
        result = subprocess.call(shlex.split(cmd))
    except OSError:
        result = -1

    if result == 0:
        if not options.quiet:
            print('  wrote', options.pdfname)
    else:
        sys.stderr.write('warning: PDF command failed\n')
1243363
def fetch(url, binary, outfile, noprint, rendered):
	'''
	
	'''
	with chrome_context.ChromeContext(binary=binary) as cr:
		resp = cr.blocking_navigate_and_get_source(url)
		if rendered:
			resp['content'] = cr.get_rendered_page_source()
			resp['binary'] = False
			resp['mimie'] = 'text/html'

	if not noprint:
		if resp['binary'] is False:
			print(resp['content'])
		else:
			print("Response is a binary file")
			print("Cannot print!")

	if outfile:
		with open(outfile, "wb") as fp:
			if resp['binary']:
				fp.write(resp['content'])
			else:
				fp.write(resp['content'].encode("UTF-8"))
746933
def output(self, output, accepts, set_http_code, set_content_type):
		

		graph = Decorator._get_graph(output)
		if graph is not None:
			# decide the format
			output_mimetype, output_format = self.format_selector.decide(accepts, graph.context_aware)
			# requested content couldn't find anything
			if output_mimetype is None:
				set_http_code("406 Not Acceptable")
				return ['406 Not Acceptable'.encode('utf-8')]
			# explicitly mark text mimetypes as utf-8
			if 'text' in output_mimetype:
				output_mimetype = output_mimetype + '; charset=utf-8'

			# format the new response
			serialized = graph.serialize(format=output_format)
			set_content_type(output_mimetype)
			return [serialized]
		else:
			return output
1243886
protected function output()
    {
        if ($this->canSendHeaders() || $this->send_headers == false) {
            if ($this->send_headers) {
                // only send the content-type headers if no headers have been output
                // this will ease debugging on misconfigured servers where warnings
                // may have been output which break the image and prevent easily viewing
                // source to see the error.
                header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
                header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
                header("Cache-Control: no-store, no-cache, must-revalidate");
                header("Cache-Control: post-check=0, pre-check=0", false);
                header("Pragma: no-cache");
            }

            switch ($this->image_type) {
                case self::SI_IMAGE_JPEG:
                    if ($this->send_headers) header("Content-Type: image/jpeg");
                    imagejpeg($this->im, null, 90);
                    break;
                case self::SI_IMAGE_GIF:
                    if ($this->send_headers) header("Content-Type: image/gif");
                    imagegif($this->im);
                    break;
                default:
                    if ($this->send_headers) header("Content-Type: image/png");
                    imagepng($this->im);
                    break;
            }
        } else {
            echo '<hr /><strong>'
                .'Failed to generate captcha image, content has already been '
                .'output.<br />This is most likely due to misconfiguration or '
                .'a PHP error was sent to the browser.</strong>';
        }

        imagedestroy($this->im);
        restore_error_handler();

        if (!$this->no_exit) exit;
    }
747198
def output(self, stream, disabletransferencoding = None):
        
        if self._sendHeaders:
            raise HttpProtocolException('Cannot modify response, headers already sent')
        self.outputstream = stream
        try:
            content_length = len(stream)
        except Exception:
            pass
        else:
            self.header(b'Content-Length', str(content_length).encode('ascii'))
        if disabletransferencoding is not None:
            self.disabledeflate = disabletransferencoding
        self._startResponse()