*print the original webpage*

        **Return:**
            - ``pdfPath`` -- the path to the generated PDF
485894
def _print_original_webpage(
            self):
        
        self.log.debug('starting the ``_print_original_webpage`` method')

        if not self.title:
            r = requests.get(self.url)
            title = bs4.BeautifulSoup(r.text).title.text
            print title
        else:
            title = self.title

        # CONVERT TO PDF WITH ELECTON PDF

        url = self.url
        pdfPath = self.folderpath + "/" + title + self.append + ".pdf"
        electron = self.settings["executables"]["electron path"]
        cmd = """%(electron)s -i "%(url)s" -o "%(pdfPath)s" --printBackground """ % locals()
        p = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
        stdout, stderr = p.communicate()
        self.log.debug('output: %(stdout)s' % locals())
        if len(stderr):
            print stderr

        exists = os.path.exists(pdfPath)
        if not exists:
            print "%(pdfPath)s was not generated for some reason - please investigate" % locals()
            sys.exit(0)

        self.log.debug('completed the ``_print_original_webpage`` method')
        return pdfPath
1215455
def view_pdf(name=None):
    
    if name is None:
        return view_meta_index()

    files = glob.glob("{0}.rst".format(name))
    if len(files) > 0:
        file_handle = open(files[0], 'r')
        dest_filename = name + '.pdf'
        doctree = publish_doctree(file_handle.read())
        try:
            produce_pdf(doctree_content=doctree,
                        filename=dest_filename)
        except:
            raise
        else:
            return static_file(dest_filename,
                               root='',
                               download=True)
    else:
        return abort(404)
760471
def get_pdf_from_html(html: str,
                      header_html: str = None,
                      footer_html: str = None,
                      wkhtmltopdf_filename: str = _WKHTMLTOPDF_FILENAME,
                      wkhtmltopdf_options: Dict[str, Any] = None,
                      file_encoding: str = "utf-8",
                      debug_options: bool = False,
                      debug_content: bool = False,
                      debug_wkhtmltopdf_args: bool = True,
                      fix_pdfkit_encoding_bug: bool = None,
                      processor: str = _DEFAULT_PROCESSOR) -> bytes:
    
    result = make_pdf_from_html(
        on_disk=False,
        html=html,
        header_html=header_html,
        footer_html=footer_html,
        wkhtmltopdf_filename=wkhtmltopdf_filename,
        wkhtmltopdf_options=wkhtmltopdf_options,
        file_encoding=file_encoding,
        debug_options=debug_options,
        debug_content=debug_content,
        debug_wkhtmltopdf_args=debug_wkhtmltopdf_args,
        fix_pdfkit_encoding_bug=fix_pdfkit_encoding_bug,
        processor=processor,
    )  # type: bytes
    return result
456393
def renderLink(self, relpath=""):
        
        # return from cache if available
        cachekey, html = self.checkCache('Link', relpath)
        if html is not None:
            return html
        # else regenerate
        html = CachingRenderer.renderLink(self, relpath)
        if self.headerfile is not None:
            html += """ (<A HREF="%s">header</A>)""" % quote_url(relpath + self.headerfile)
        # save to cache
        return self.writeCache(cachekey, html)
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
735186
def get_page_text(self, page):
        
        url = self.get_page_text_url(page)
        return self._get_url(url)
370937
def pprint(self, raw=False):
        
        tags = self.wrapper if not raw else self.wrapper.raw
        print u'{}:'.format(self.path)
        names = tags.keys()
        names.sort()
        w = max(len(k) for k in names)
        fmt = u'    {{:<{}}} : {{}}'.format(w)
        for k in names:
            v = tags[k]
            try:
                v = unicode(v)
            except UnicodeDecodeError:
                v = repr(v)
            print fmt.format(k, cutoff(v, 100))
249021
def get(self, request, *args, **kwargs):
        
        if 'html' in request.GET:
            # Output HTML
            content = self.render_html(*args, **kwargs)
            return HttpResponse(content)

        else:
            # Output PDF
            content = self.render_pdf(*args, **kwargs)

            response = HttpResponse(content, content_type='application/pdf')

            if (not self.inline or 'download' in request.GET) and 'inline' not in request.GET:
                response['Content-Disposition'] = 'attachment; filename=%s' % self.get_filename()

            response['Content-Length'] = len(content)

            return response
606690
def extract_pdftotext(self, filename, **kwargs):
        """"""
        if 'layout' in kwargs:
            args = ['pdftotext', '-layout', filename, '-']
        else:
            args = ['pdftotext', filename, '-']
        stdout, _ = self.run(args)
        return stdout
120268
def pdfFromPOST(self):
        
        html = self.request.form.get('html')
        style = self.request.form.get('style')
        reporthtml = "<html><head>%s</head><body><div id='report'>%s</body></html>" % (style, html)
        return self.printFromHTML(safe_unicode(reporthtml).encode('utf-8'))
348618
def write_pdf(pdf_obj, destination):
    
    reader = PdfFileReader(pdf_obj)  # Create new PDF object
    writer = PdfFileWriter()

    page_count = reader.getNumPages()

    # add the "watermark" (which is the new pdf) on the existing page
    for page_number in range(page_count):
        page = reader.getPage(page_number)
        writer.addPage(page)

    # finally, write "output" to a real file
    with open(destination, "wb") as outputStream:
        writer.write(outputStream)
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"))
253391
def _page_gen(self):
        
        track = ""
        for page in self.__pages__:
            track += "/{page}".format(page=page)
        return track
914241
def path_to_text(self, path):
        '''
        

        '''
        rsrcmgr = PDFResourceManager()
        retstr = StringIO()
        codec = 'utf-8'
        laparams = LAParams()
        device = TextConverter(rsrcmgr, retstr, codec=codec, laparams=laparams)
        fp = open(path, 'rb')
        interpreter = PDFPageInterpreter(rsrcmgr, device)
        password = ""
        maxpages = 0
        caching = True
        pagenos = set()

        pages_data = PDFPage.get_pages(
            fp,
            pagenos,
            maxpages=maxpages,
            password=password,
            caching=caching,
            check_extractable=True
        )

        for page in pages_data:
            interpreter.process_page(page)

        text = retstr.getvalue()
        text = text.replace("\n", "")

        fp.close()
        device.close()
        retstr.close()
        return text
629790
function getPDFTemplate(output, type) {
    var filePath = 'pdf_' + type + '.html';
    var outputRoot = output.getRoot();
    var engine = WebsiteGenerator.createTemplateEngine(output, filePath);

    // Generate context
    var context = JSONUtils.encodeOutput(output);
    context.page = {
        num: '_PAGENUM_',
        title: '_SECTION_'
    };

    // Render the theme
    return Templating.renderFile(engine, 'ebook/' + filePath, context)

    // Inline css and assets
    .then(function(tplOut) {
        return Promise.nfcall(juice.juiceResources, tplOut.getContent(), {
            webResources: {
                relativeTo: outputRoot
            }
        });
    });
}
807317
def split_pdf(pdf_path):
  '''  '''
  pdf = PdfFileReader(pdf_path)
  pdf_list = []

  for page_num in range(pdf.numPages):
    page = pdf.getPage(page_num)

    pdf_writer = PdfFileWriter()
    pdf_writer.addPage(page)

    with NamedTemporaryFile(prefix='pyglass', suffix='.pdf', delete=False) as tempfileobj:
      pdf_writer.write(tempfileobj)
      page_path = tempfileobj.name

    pdf_list.append(page_path)

  return pdf_list
11793
def _logpdf(self, **kwargs):
        
        if kwargs in self:
            return numpy.log(self._pdf(**kwargs))
        else:
            return -numpy.inf