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

Limited, yet memory-leak-free Go wrapper for a Poppler PDF library

License

NotificationsYou must be signed in to change notification settings

johbar/go-poppler

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A simple wrapper for thePoppler PDF lib for Golang.

This go module exports a limited subset of Popplers functions, specifically only those needed to extract text from PDFs.It drops support for images in favor of also dropping thelibcairo dependency.

Install dependencies

In order to use this module you need to install two packages. In Debian/Ubuntu this is done by:

# Debian-based OSapt-get install libpoppler-glib-dev

Usage

go get github.com/johbar/go-poppler

Improvements and performance considerations

This is a fork oftimsat/go-poppler which is derived ofcheggaaa/go-poppler.

This fork fixes a couple of memory leaks that the upstream libs included.In addition it usesfinalizers as a safeguard against memory leaks.This enables you not to calldocument.Close() andpage.Close() but let the GC do the clean-up work instead.

This might add a significant memory overhead in long-running high-throughput processes (like a web service or batch processor), when a lot ofPoppler objects in unmanaged/off-heap memory are being created.They are evicted by the finalizer but the GC might run too late to prevent a OOM as it doesn't take these into account when it schedules the next cycle.

One advantage of relying on finalizes solely might be an improved CPU utilization because they run on their own goroutine.So your main routine doesn't need to handle the clean-up. (But you can achieve this in many other ways,I guess, e.g. by writing your own goroutine and using channels.)

Tl;dr: Be careful when relying on finalizers; do some (load) tests and watch your RAM!

About

Limited, yet memory-leak-free Go wrapper for a Poppler PDF library

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go100.0%

[8]ページ先頭

©2009-2025 Movatter.jp