Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Origami is a pure Ruby library to parse, modify and generate PDF documents.

License

NotificationsYou must be signed in to change notification settings

gdelugre/origami

Repository files navigation

Gem VersionDownloadsBuild StatusLicense: LGPL v3

Overview

Origami is a framework written in pure Ruby to manipulate PDF files.

It offers the possibility to parse the PDF contents, modify and save the PDFstructure, as well as creating new documents.

Origami supports some advanced features of the PDF specification:

  • Compression filters with predictor functions
  • Encryption using RC4 or AES, including the undocumented Revision 6 derivation algorithm
  • Digital signatures and Usage Rights
  • File attachments
  • AcroForm and XFA forms
  • Object streams

Origami is able to parse PDF, FDF and PPKLite (Adobe certificate store) files.

Requirements

As of version 2, the minimal version required to run Origami is Ruby 2.1.

Some optional features require additional gems:

Quick start

First install Origami using the latest gem available:

$ gem install origami

Then import Origami with:

require'origami'

To process a PDF document, you can use thePDF.read method:

pdf=Origami::PDF.read"something.pdf"puts"This document has#{pdf.pages.size} page(s)"

The default behavior is to parse the entire contents of the document at once. This can be changed by passing thelazy flag to parse objects on demand.

pdf=Origami::PDF.read"something.pdf",lazy:truepdf.each_pagedo |page|page.each_fontdo |name,font|# ... only parse the necessary bitsendend

You can also create documents directly by instanciating a new PDF object:

pdf=Origami::PDF.newpdf.append_pagepdf.pages.first.write"Hello",size:30pdf.save("example.pdf")# Another way of doing itOrigami::PDF.write("example.pdf")do |pdf|pdf.append_pagedo |page|page.write"Hello",size:30endend

Take a look at theexamples andbin directories for some examples of advanced usage.

Tools

Origami comes with a set of tools to manipulate PDF documents from the command line.

  • pdfcop: Runs some heuristic checks to detect dangerous contents.
  • pdfdecompress: Strips compression filters out of a document.
  • pdfdecrypt: Removes encrypted contents from a document.
  • pdfencrypt: Encrypts a PDF document.
  • pdfexplode: Explodes a document into several documents, each of them having one deleted resource. Useful for reduction of crash cases after a fuzzing session.
  • pdfextract: Extracts binary resources of a document (images, scripts, fonts, etc.).
  • pdfmetadata: Displays the metadata contained in a document.
  • pdf2ruby: Converts a PDF into an Origami script rebuilding an equivalent document (experimental).
  • pdfsh: An IRB shell running inside the Origami namespace.

Note: Since version 2.1,pdfwalker has been moved to aseparate repository.

License

Origami is distributed under theLGPL license.

Copyright © 2019 Guillaume Delugré.

About

Origami is a pure Ruby library to parse, modify and generate PDF documents.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp