16 ms·
OpenPDF 1.3.0
- bsaul 7y agoPdf so badly needs a standard open source reference implementation. the problem with java is that it isn’t easy to reuse in other programming environment... something in C, or anything that compiles through LLVM would probably be a better choice i think.
- MartinMond 7y agoGoogle's PDFium which is used in Android and ChromeOS is fast becoming the reference implementation to target: https://opensource.google.com/projects/pdfium https://opensource.google.com/projects/pdfium
- jokowueu 7y agoIs there a standalone client based on pdfium ?
- merb 7y agopdfium has literally no documentation. but the good thing is that it is c which can be called from many languages.
- jsty 7y ago"No documentation" seems a bit harsh - there's a Getting Started guide in docs/ [0] and fairly good commenting on the interfaces in public/ [1] [0] https://pdfium.googlesource.com/pdfium/+/refs/heads/master/docs/ https://pdfium.googlesource.com/pdfium/+/refs/heads/master/d... [1] https://pdfium.googlesource.com/pdfium/+/refs/heads/master/public/ https://pdfium.googlesource.com/pdfium/+/refs/heads/master/p...
- bla3 7y agoWhat's wrong with pdfium?
- hannob 7y agoIt uses custom google build systems that are difficult to use independent of a chromium build. Last time I tried I was unable to get it to build. It's not packaged as far as I can tell separately from chromium and chromium doesn't ship it as a reusable library. Not sure if it has a stable interface, probably not. It doesn't have any frontend other than chromium.
- bla3 7y ago> Not sure if it has a stable interface Their docs say "The public/ directory contains header files for the APIs available for use by embedders of PDFium. We endeavor to keep these as stable as possible." The rest are valid points though!
- yjftsjthsd-h 7y ago> We endeavor to keep these as stable as possible. That sounds more like best-effort.
- pferde 7y agoThat is actually what I thought this OpenPDF thing was. I feel that the name is very unfortunately chosen - it's too generic, should have had a "J" in it at least to denote that it is a Java library. JOpenPDF, perhaps.
- maskros 7y agoThere's already plenty of open source implementations of PDF parsing: Ghostscript, MuPDF, XPDF, Poppler, Pdfium, just to name the first few that come to mind.
- marcthe12 7y agoAll do not support typewriter or forms. This makes easier to fill up forms
- swiley 7y agoMuPDF supposedly supports forms in the latest version. I’ve never seen it work though.
- kxyvr 7y agoAlright, so I noticed this before and just tried it again. While I can fill in forms, does anyone know how to save them? The man page says "S", but that doesn't work and I remember this causing issues for me in the past.
- kxyvr 7y agoEvince can handle forms most of the time. That said, Acrobat allows things like Livecycle (XFA) forms, which are nonstandard and will break just about everything outside of Acrobat. Outside of that, pdftk can handle forms using the forms data format (FDF): https://www.iso.org/obp/ui/#iso:std:iso:19444:-1:ed-1:v1:en https://www.iso.org/obp/ui/#iso:std:iso:19444:-1:ed-1:v1:en Though, it was mostly an exercise in frustration. That said, IRS forms used to work great with this. However, long story short, Evince works most of the time.
- kuu 7y agothe problem with java is that it isn’t easy to reuse in other programming environment. Isn't one of the advantages of Java exactly being multi-platform?
- gdfasfklshg4 7y agoMore that Java is a platform. You target the JVM. So Java libraries are awkward to call from e.g. C++ or Python.
- tonyedgecombe 7y agoI doubt many people will want to add a jvm dependency just to support a PDF library.
- merb 7y agoYou can compile java to LLVM or create dll/so files. * https://www.graalvm.org/ https://www.graalvm.org/ * https://www.graalvm.org/docs/reference-manual/aot-compilation/ https://www.graalvm.org/docs/reference-manual/aot-compilatio... You only need to pass `--shared`. (You can also define multiple exports via public static ... and some annotations https://github.com/oracle/graal/blob/master/substratevm/README.md#images-and-entry-points https://github.com/oracle/graal/blob/master/substratevm/READ...) of course it's a little bit akward to first create a "JVM" library and then call that library from native code, but it's not impossible.
- IloveHN84 7y agoThat's a bad idea and Windows is still experimental.
- JackC 7y agoI really feel this when working in python. It feels like there are a million tools that each support 1/3 of the standard. E.g. I recently needed to convert raw OCR files to PDF -- place TIFs on each page without recompressing, place invisible text on top, add bookmarks, save. I ended up stringing together three python libraries (img2pdf for efficient image combining, reportlab to place text, PyPDF2 to merge the two), which was both clunky and slow. Second pass was scripting command line tools (tiffcp + tiff2pdf + reportlab + pdftk), which was still clunky but at least faster. It would be awesome if there was one solid, fast implementation that lots of language ecosystems could wrap and contribute back to. I haven't looked around much outside of Python -- maybe that's OpenPDF with Graal, or PDFium, or something else mentioned in the sibling comments? But there are so many usecases for PDF, I wouldn't be surprised to find that those also fail to cover the whole field. Y'know what I can imagine working is a package ecosystem that uses a common in-memory data structure, so you have one base package that does the reading and writing and low-level manipulation, and someone else can come along and write the equivalent of img2pdf or reportlab as separate packages that compose without any efficiency loss. That could work in any language but it feels like the kind of thing Rust is doing really well these days. It might just take some good branding around "hey, here's a low-level FooPDF data structure that is easy to write high-level libraries against -- make sure to mention in your docs that you're compatible with FooPDF." Sort of an Apache Arrow approach.
- bscphil 7y ago> Pdf so badly needs a standard open source reference implementation Similarly, I would like to see more attention given to PDF/A and high quality reference implementations and libraries targeting it. It solves many of the most common complaints here on HN about PDF: no audio / video, no javascript, no XML forms, all fonts have to be embedded, etc. - and it's an ISO standard. We really need solid support for a document format that has readers that aren't constantly getting CVE'd from supporting too much of a bloated specification.
- bsaul 7y agoabsolutely. I developped a pdf parser myself and only discovered pdf/a on HN after almost a year working on it. Pdf/a needs a LOT more publicity.
- tonyedgecombe 7y agoIt would be nice to have something with a permissive license. There are a lot of commercial offerings but the costs make them prohibitive for my projects.
- lsllc 7y agoGo has a number of PDF libraries including GoFPDF which is actually really good and very well rounded. These days you can easily build a "C" interface to a shared library implemented in Go. https://github.com/jung-kurt/gofpdf https://github.com/jung-kurt/gofpdf
- cetra3 7y agoI tried to find a good comparison to PDFBox but came up short!
- _JamesA_ 7y agoFrom my experience OpenPDF is better at formatting and layout. PDFBox is a lot lower level. OpenPDF [1]: document.add(new Paragraph("Hello World")); PDFBox [2]: contentStream.beginText(); contentStream.setFont( font, 12 ); contentStream.moveTextPositionByAmount( 100, 700 ); contentStream.drawString( "Hello World" ); contentStream.endText(); [1]: https://github.com/LibrePDF/OpenPDF/blob/master/pdf-toolbox/src/test/java/com/lowagie/examples/general/HelloWorld.java https://github.com/LibrePDF/OpenPDF/blob/master/pdf-toolbox/... [2]: https://pdfbox.apache.org/1.8/cookbook/documentcreation.html https://pdfbox.apache.org/1.8/cookbook/documentcreation.html
- roschdal 7y agoI'm one of the maintainers of OpenPDF. Please give it a try and post your feedback. Also, if you are using iText 1.2.x, it's time to update to OpenPDF, which should be compatible. https://github.com/librepdf/openpdf https://github.com/librepdf/openpdf
- mkl 7y agoIs there a version of PDFtk based on OpenPDF? PDFtk's original GCJ-compiled iText isn't well supported any more.
- roschdal 7y agoThanks for the suggestion. I have forwarded this request to Sid in PDF Labs.
- mgreenleaf 7y agoGreat work, thank you for the effort you have put into this.
- spapas82 7y agoIs it possible to digitally sign a PDF with OpenPDF? If yes is there a tutorial somewhere or could you give a hint on how it's done or where to look at the Java API? Thanks in advance!
- dhollenbeck 7y agoNew Pure JavasScript low-level implementation to create and edit PDF files: https://github.com/Hopding/pdf-lib https://github.com/Hopding/pdf-lib
- mkl 7y agoTangential question: Do you know of a method to render PDFs to HTML canvas other than PDF.js? PDF.js seems too slow for my purposes, though I haven't tested very thoroughly yet. I'm hoping with wasm Skia now available, there might be some other options coming.
- aloer 7y agohow does Skia and pdf work together? I know there is a pdf backend but the way I understand it is that it just outputs pdf instead of an image I recently started playing around with wasm Skia/CanvasKit but I have a hard time wrapping my head around what exactly it is supposed to be used for, as well as Skia in general. For example, Skia allows text rendering and I could naively assume that if I want to build some high performance 2D UI that Rendering text with Skia would work reasonably well. But at what level would text interactivity like selecting text happen? I’m afraid this is a very generic question. Are you familiar with any pdf or text related project that uses Skia and could help me better understand what role Skia plays?
- mkl 7y agoPDFium has a Skia backend, where Skia is used to do the actual drawing. Interactivity happens at a higher level.
- bhl 7y agoThere's pdf2htmlex, albeit it's an archived project.
- anahoneymaria 7y agoGreat, Thank you
- tasty_freeze 7y agoMy particular needs for PDF creation are somewhat unusual, so I'm not surprised that Acrobat Pro seems to be the only thing that suits my needs. If anyone knows of a PDF creation library that has good support for the various image compression schemes supported by PDF, I'd love to know about it. Currently I'm using a 10 year old paid version of Acrobat Pro because I'm unwilling to spend another $500 to get a modern copy simply to compress images. I use it for scanning and archiving old computer manuals. In many cases jbig on 1bpp images is good enough; other times I want to use one of the more sophisticated hybrid schemes so I can have B&W or color images interspersed on the page with 1bpp text. Acrobat does a pretty good job of auto-deskewing images and doing analysis to figure out which compression type to use in different sections of the same page.
- kxyvr 7y agoThis doesn't completely fix your issue, but since you mentioned deskewing, I clean up my scanned documents using ScanTailor Advanced: https://github.com/4lex4/scantailor-advanced https://github.com/4lex4/scantailor-advanced I find the autodeskewing algorithm to work well, but it allows hand adjustment as well, which I like. As I've gotten better as using it, I've been able to get the size of my scanned documents down considerably by cleaning up the scans. This includes some old manuals. As far as the pdf encoding itself, I use both mutool, from mupdf, and qpdf. I just checked and it looks like while they both compress their streams, it may not have the same flexibility with Acrobat Pro. For me, I'll decompress, edit, and recompress streams on the files and that's been fine for my use. That said, if someone knows of a better tool for compressing streams in a PDF, I'd be interested to hear about it as well.
- dunham 7y agoI'd be interested if anything open source exists that can do jbig/jpeg2k pdfs (separation + compression) like DjVU. I think archive.org ships PDFs like this, but don't know what they're using to do it (possibly something commercial?).
- bArray 7y agoIt sounds like you are using Windows, but if you happen to be using Linux [1]: ps2pdf LARGE.pdf SMALL.pdf I believe it compresses all of the images independently, instead of converting the entire thing to an image as I believe Imagick does (I could be wrong though). This tool doesn't appear to have any intelligent auto-deskewing though. (On a slightly different note, it's questionable whether you want to do this for archiving as it'll undoubtedly be a lossy operation.) The reason I use this: Many websites for conferences have upload limits at around 10MB, a size you can easily reach with a handful of images from a modern device in your paper. [1] https://www.shellhacks.com/linux-compress-pdf-reduce-pdf-size/ https://www.shellhacks.com/linux-compress-pdf-reduce-pdf-siz...
- gibsonf1 7y agoWe use this with great success in production: https://pdfbox.apache.org/ https://pdfbox.apache.org/
- jokoon 7y agoCan this render PDF form fills? Because PDF.js can't read them, and I must use either PDFmaster or adobe. Other question: Is it possible to build a document format similar to PDF around SVG?
- getpolarized 7y agoI've been heads down in PDF for about 6 months and looking at all the various and supported libraries. Within Polar (https://getpolarized.io https://getpolarized.io) we support pdf.js which is rather nice but ONLY supports viewing of the PDF and text extraction. You can't create NEW PDFs. Our plan is to use something like OpenPDF to get the best of both worlds. Editing PDFs for doing things like exporting could be done on the server and the rest done on the client.
- no_wizard 7y agoIs this a good library for doing automated PDF form filling (like via FDF?) If not, is there any that are recommended? PDFTK is really showing its age in an application we have (its slow, and often unreliable in large batch jobs)
- charliebrownau 7y agoPlease consider supporting gitlab instead of github Github supports censorship