GithubHelp home page GithubHelp logo

soegaard / racket-poppler Goto Github PK

View Code? Open in Web Editor NEW
24.0 4.0 6.0 5.98 MB

Racket bindings for Poppler (library for reading and generating pdfs)

Racket 19.91% HTML 63.37% CSS 14.16% JavaScript 2.56%
racket poppler pdf

racket-poppler's Introduction

racket-poppler

This package allows you to read pdf files, render them to a drawing context and more.

As an application this package includes render-tex, which allows you to convert snippets of TeX into scalable picts. This can be used to make pretty mathematical formuals in slideshow and scribble.

The underlying work horse of this package is Poppler. Poppler is a C libary for rendering pdfs via Cairo. The license of Poppler is GPL.

In order for the rendering to work the Poppler library needs to be compiled to use the same version of Cairo as Racket uses. For that reason racket-poppler is distributed with Poppler precompiled for Windows and OS X. Thanks to Matthew Flatt for providing the binaries. The license of Poppler is GPL, so it can't be distributed with Racket.

Note: Use the development version of Racket - which uses a newer version of Cairo than the current release.

The racket-poppler package is based on code by Michael Wilber (https://github.com/gcr/pdf-render).

Example (assumes latex is installed):

> (require racket-poppler/render-tex)
> (latex-path "/usr/local/texlive/2013/bin/universal-darwin/pdflatex")
> (define p (latex->pict "$\\sqrt{x^2+y^2}$"))
> (pict->bitmap p)

nice picture in DrRacket

Now let's do something with the picture:

> (define beside hc-append)
> (define above  vc-append)

> (pict->bitmap (above (beside (rotate p (- pi (/ pi 3))) (rotate p    (/ pi 3)))
                       (beside (rotate p (+ pi (/ pi 3))) (rotate p (- (/ pi 3))))))

nice picture in DrRacket

This renders the formula of Pythagoras as a pdf, converts it into a pict, which is then rotated. The rotated pict is converted into a bitmap, and finally DrRacket shows the bitmap.

Note: DrRacket will currently not display the picts generated by latex->pict or pdf->pict directly. Wrap the picts in pict->bitmap to see them in DrRacket. (The cause of this is fact that pdf->pict draws directly the Cairo drawing context. DrRacket "copies" picts using a record-dc% and recording contexts doesn't record drawing operations that draw directly to the Cairo context.)

See Michael Wilber's original documentation for some ideas on how to use this library, but note that the API has changed slightly. In racket-poppler all operations are safe. http://planet.racket-lang.org/package-source/gcr/pdf-render.plt/2/2/planet-docs/main/index.html

For an extensive example see "examples/test-pdf-functions.rkt".

Warning: The documentation in doc/ has not been updated yet.

[1] OS X binaries for libpoppler and friends https://github.com/soegaard/racket-osx-libs/tree/master/lib

/soegaard

racket-poppler's People

Contributors

florence avatar leifandersen avatar mflatt avatar samth avatar soegaard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

racket-poppler's Issues

DrRacket 8.12 crashes

After installing today
MacBook-Pro:~ tbh$ raco pkg install poppler-aarch64-macosx Resolving "poppler-aarch64-macosx" via https://download.racket-lang.org/releases/8.12/catalog/ Resolving "poppler-aarch64-macosx" via https://pkgs.racket-lang.org Downloading repository https://github.com/soegaard/poppler-libs.git?path=poppler-aarch64-macosx commit 029c07225d55593ee38c1bc3fcce2a8a1dd6cdc6 raco setup: version: 8.12

Running this
#lang racket (require racket-poppler )
causes DrRacket to crash.
[
2024-05-08_tbh_DrRacket_racket-poppler_crash.pdf
](url)
cf.
https://racket.discourse.group/t/using-pdf-read-package-to-extract-text-from-pdf-file/2685/28?u=tbhanson

raco setup fails

I tried to install your package and got this:

% raco pkg install racket-poppler
.....
.....
raco setup: 0 running: /racket-poppler/racket-poppler/main.scrbl
default-load-handler: cannot open module file
module path: (lib "main.scrbl" "racket-poppler")
path: /Users/matthias/plt/racket/share/pkgs/racket-poppler/racket-poppler/main.scrbl
system error: No such file or directory; errno=2
context...:
standard-module-name-resolver
/Users/matthias/plt/pkgs/racket-pkgs/racket-index/setup/scribble.rkt:895:0: load-doc/ensure-prefix
/Users/matthias/plt/pkgs/racket-pkgs/racket-index/setup/scribble.rkt:1146:13
/Users/matthias/plt/racket/collects/setup/parallel-do.rkt:420:20: loop

raco setup: --- installing collections ---

I am on Mac OS X 10.7+++. Let me know whether you need anything else.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.