Makes a pdf from a passed in string.

 Returns PDF as a stream, so we can use send_data to shoot
 it down the pipe using Rails.
489033
def pdf_from_string(string, output_file = '-')
      with_timeout do
        pdf = initialize_pdf_from_string(string, output_file, {:output_to_log_file => false})
        pdf.close_write
        result = pdf.gets(nil)
        pdf.close_read
        result.force_encoding('BINARY') if RUBY_VERSION >= "1.9"

        result
      end
    end
821270
def pdf_copy(input: str, output: str, pages: [int], yes_to_all=False):
    
    if not os.path.isfile(input):
        print("Error. The file '%s' does not exist." % input)
        return

    if os.path.isfile(output) and not yes_to_all and not overwrite_dlg(output):
        return

    with open(input, "rb") as inputfile:
        reader = PdfFileReader(inputfile)
        outputfile = open(output, "wb")
        writer = PdfFileWriter()
        if pages is None:
            pages = range(len(reader.pages))
        else:
            pages = parse_rangearg(pages, len(reader.pages))
        for pagenr in sorted(pages):
            page = reader.getPage(pagenr)
            writer.addPage(page)
            writer.write(outputfile)
        outputfile.close()
277750
def combine_pdf_as_bytes(pdfs: List[BytesIO]) -> bytes:
    
    writer = PdfWriter()
    for pdf in pdfs:
        writer.addpages(PdfReader(pdf).pages)
    bio = BytesIO()
    writer.write(bio)
    bio.seek(0)
    output = bio.read()
    bio.close()
    return output
447375
def pdf(self, text=TEXT):
        
        self.logger.debug("Generating the PDF report...")
        html = HTML(string=self.html())
        css_file = self.css or join(dirname(abspath(__file__)),
                                    "{}.css".format(self.theme))
        css = [css_file, CSS(string=PAGE_CSS % self.__dict__)]
        html.write_pdf("{}.pdf".format(self.filename), stylesheets=css)
38251
def generate_pdf(template_id, submission_data, opts = {})
      data, _status_code, _headers = generate_pdf_with_http_info(template_id, submission_data, opts)
      data
    end
560339
def pdf_preprocess(pdf, batch=False):
    
    if batch:
        return [pdf_preprocess(doc, batch=False) for doc in pdf]

    if os.path.isfile(pdf):
        # a filepath is provided, read and encode
        return b64encode(open(pdf, 'rb').read())
    else:
        # assume pdf is already b64 encoded
        return pdf
140261
def save_pdf(opts = {})
      range = Args::CardRange.new(opts[:range], deck_size: size)
      sheet = Args::Sheet.new(custom_colors, { file: 'output.pdf' }).load!(opts, expand_by: size, layout: layout, dpi: dpi)
      sprue_file = Args::SprueFile.new.load!(opts, expand_by: size)

      if sprue_file.sprue.nil?
        Graphics::SavePDF.new(self).render_pdf(range, sheet)
      else
        tmpl = Sprue.load sprue_file.sprue, dpi
        Graphics::SaveSpruePDF.
          new(self, tmpl, sheet).
          render_sheet(range)
      end
    end
1073115
def serve_concatenated_pdf_from_disk(
        filenames: Iterable[str],
        offered_filename: str = "crate_download.pdf",
        **kwargs) -> HttpResponse:
    
    pdf = get_concatenated_pdf_from_disk(filenames, **kwargs)
    return serve_buffer(pdf,
                        offered_filename=offered_filename,
                        content_type=MimeType.PDF,
                        as_attachment=False,
                        as_inline=True)
266750
def create_stream(name, **header):
    
    assert isinstance(name, basestring), name
    return CreateStream(parent=None, name=name, group=False, header=header)
922503
def serve_pdf_from_html(html: str,
                        offered_filename: str = "test.pdf",
                        **kwargs) -> HttpResponse:
    
    pdf = get_pdf_from_html(html, **kwargs)
    return serve_buffer(pdf,
                        offered_filename=offered_filename,
                        content_type=MimeType.PDF,
                        as_attachment=False,
                        as_inline=True)
317907
def convert()
      errors = ""
      output = ""
      
      if @user_pwd 
        cmd = "pdftohtml -stdout #{@format} -upw #{@user_pwd}" + ' "' + @path + '"'    
      elsif @owner_pwd 
        cmd = "pdftohtml -stdout #{@format} -opw #{@owner_pwd}" + ' "' + @path + '"'
      else
        cmd = "pdftohtml -stdout #{@format}" + ' "' + @path + '"'
      end
      
      output = `#{cmd} 2>&1`

      if (output.include?("Error: May not be a PDF file"))
        raise PDFToHTMLRError, "Error: May not be a PDF file (continuing anyway)"
      elsif (output.include?("Error:"))
        raise PDFToHTMLRError, output.split("\n").first.to_s.chomp
      else
        return output
      end
    end
687977
def extract_pdf(file_name):
    

    rsrcmgr = pdfminer.pdfinterp.PDFResourceManager()
    sio = StringIO()
    laparams = LAParams()
    device = TextConverter(rsrcmgr, sio, codec='utf-8', laparams=laparams)
    interpreter = pdfminer.pdfinterp.PDFPageInterpreter(rsrcmgr, device)

    # Extract text from pdf file
    with open(file_name, 'rb') as fp:
        for page in PDFPage.get_pages(fp, maxpages=20):
            interpreter.process_page(page)

    text = sio.getvalue()

    # Cleanup
    device.close()
    sio.close()

    return text
1366575
function generatePDF(req, res, next) {
  req.appformsResultPayload = req.appformsResultPayload || {};

  //If there is already a submission result, render this. This is useful for cases where the submission is fetched from another database and rendered elsewhere.
  var existingSubmission = req.appformsResultPayload.data;

  var params = {
    _id: req.params.id,
    pdfExportDir: req.pdfExportDir,
    downloadUrl: '' + req.protocol + '://' + req.hostname,
    existingSubmission: existingSubmission,
    environment: req.environment,
    mbaasConf: req.mbaasConf,
    domain: req.user.domain,
    filesAreRemote: req.filesAreRemote,
    fileUriPath: req.fileUriPath,
    location: req.coreLocation,
    pdfTemplateLoc: req.pdfTemplateLoc,
    maxConcurrentPhantomPerWorker: req.maxConcurrentPhantomPerWorker
  };

  logger.debug("Middleware generatePDF ", {params: params});

  forms.generateSubmissionPdf(_.extend(params, req.connectionOptions), function(err, submissionPdfLocation) {
    if (err) {
      logger.error("Middleware generatePDF", {error: err});
      return next(err);
    }

    logger.debug("Middleware generatePDF ", {submissionPdfLocation: submissionPdfLocation});

    //Streaming the file as an attachment
    res.download(submissionPdfLocation, '' + req.params.id + ".pdf", function(fileDownloadError) {

      //Download Complete, remove the cached file
      fs.unlink(submissionPdfLocation, function() {
        if (fileDownloadError) {
          logger.error("Middleware generatePDF ", {error: fileDownloadError});
          //If the headers have not been sent to the client, can use the error handler
          if (!res.headersSent) {
            return next(fileDownloadError);
          }
        }
      });
    });
  });
}
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
1166399
def to_document(input, context = {}, result = nil)
      result = call(input, context, result)
      HTML::Pipeline.parse(result[:output])
    end
795104
def from_buffer(string, config_path=None):
    '''
    
    '''
    status, response = callServer('put', ServerEndpoint, '/detect/stream', string,
                                  {'Accept': 'text/plain'}, False, config_path=config_path)
    return response
1297924
def to_pdf(*args)
      options = extract_options!(args)
      datasource = args[0]
      _JasperPrint                 = Rjb.import('net.sf.jasperreports.engine.JasperPrint')
      _JasperExportManager         = Rjb.import('net.sf.jasperreports.engine.JasperExportManager')
      _JasperExportManager._invoke('exportReportToPdf', 'Lnet.sf.jasperreports.engine.JasperPrint;', prepare(datasource))
    end