Re: [Pharo-project] PDF Rendering
Hi Ben, yes I am lurking :-) About manipulating PDFs - this is really easy and people have done that: Aik-Siong Koh needed to split large PDFs into one-page PDFs and Holger Kleinsorgen answered on vwnc with the following code to do that: | inputStream inputPDF pageNumber | inputStream := 'ReleaseNotes7.7.pdf' asFilename readStream binary. [ inputPDF := PDF.File readFrom: inputStream. pageNumber := 1. inputPDF trailer Root pagesDo: [ : page | | targetFilename onePageDocument | onePageDocument := PDF.Document new. onePageDocument root addPage: page. targetFilename := (pageNumber printString, '.pdf') asFilename. onePageDocument saveAs: targetFilename. pageNumber := pageNumber + 1. ]. ] ensure: [ inputStream close ]. Bob Nemec (Author of Report4PDF) needed to add a document to another. The how-to is on the docs wiki: http://www.freelists.org/post/pdf4st/Append-another-PDF-document Lately, I had to put a chart onto an existing PDF page which contained background (with shadows which I cannot do yet) and I was surprised myself how easy that was (just add another content stream to the existing one). All this is nice and easy, because PDF is so well structured - I love it :-) Cheers, Christian
-----Ursprüngliche Nachricht----- Von: pharo-project-bounces@lists.gforge.inria.fr [mailto:pharo-project- bounces@lists.gforge.inria.fr] Im Auftrag von Ben Coman Gesendet: Sonntag, 31. März 2013 13:46 An: Pharo-project@lists.gforge.inria.fr Betreff: Re: [Pharo-project] PDF Rendering
Hi Christian, Didn't realize you were on list. Thanks for the clarification.
Do you think that PDF4Smalltalk would be suited to build a tool for splitting/joining pages, and perhaps also adding watermarks to pages? For instance, I often use tools like pdfmerge [1] for this. These are quite popular tools and would gain a lot of interest from the "general user" community.
[1] http://download.cnet.com/PdfMerge/3000-2351_4-75766462.html
cheers -ben
Christian Haider wrote:
My name is Haider (sticky fingers are not polite with proper names...).
My PDF library has nothing to do with rendering (putting the graphics on the screen) and I doubt that Artefact will do that. IMHO, rendering PDF is quite a challenge...
Cheers, Christian (HAIDER)
Ben Coman wrote:
Thanks Stef. Actually I have had some recent discussion with Christian about porting to Pharo. He seems open to the idea but for a while he is committed to other earn-a-living activities. However back to my original question, I believe neither Artefact or PDF4Smalltalk yet do PDF rendering to screen pixels. Although I think that PDF4Smalltalk would make a good base for this. As a distant goal I dream of having a PDF Editor inside Pharo. First just being able to split/join pages and later being able to draw on top of existing documents. cheers -ben
stephane ducasse wrote:
Else there is also the work of Christian Haidler. Artefact developers will release soon a 0.9 version once they fix the jpeg inclusion Stef
I was looking around for PDF rendering libraries that might be used with NativeBoost and they all seem to be licensed GPL, which is not compatible with Pharo's preference for the MIT license. Then I came across Apache licensed pdf.js [1] which sparked my curiosity.... There are a few projects to have Smalltalk run on top of Javascript, but has anyone looked at the reverse, running javascript inside a Smalltalk image? Perhaps handing the Javascript off via NativeBoost to a Javascript VM like SquirrelFish [2]. Or is that just a bad idea?
cheers -ben
[1] http://andreasgal.com/2011/06/15/pdf-js/ [2] https://www.webkit.org/blog/189/announcing-squirrelfish/
Maybe you already knew about Artefact - a PDF framework for Pharo
http://forum.world.st/Artefact-a-PDF-framework-td4585877.html
A solution in Smalltalk is more useful in the long term, IMHO, in the sense that it can then be read, understood, maintained by the community instead of being a black box.
Sven
-- Sven Van Caekenberghe http://stfx.eu Smalltalk is the Red Pill
participants (1)
-
Christian Haider