balacode / one-file-pdf Goto Github PK
View Code? Open in Web Editor NEWA minimalist Go PDF writer in 1982 lines. Draws text, images and shapes. Helps understand the PDF format. Used in production for reports.
License: MIT License
A minimalist Go PDF writer in 1982 lines. Draws text, images and shapes. Helps understand the PDF format. Used in production for reports.
License: MIT License
In SaveFile, ioutil.WriteFile is used to save the file without any file attributes. Therefore, the file cannot be read until one performs a chmod
to set reasonable attributes.
var err = ioutil.WriteFile(filename, pdf.Bytes(), 0)
should be
var err = ioutil.WriteFile(filename, pdf.Bytes(), 0644)
Release 1.0.1 seems to be restricted to pure ASCII.
Would it be possible to extend it to PDF encoding as described on https://gist.github.com/zmughal/5130211 ?
Unless it diverts work away from full unicode support of course.
I tried to use one-file-pdf for Swedish in https://github.com/jonasgit/pdfhw but it seems to fail. Unless I did something wrong?
The flower icon in the hello.pdf file is not rendered on Debian while using the default PDF viewer. But ZapfDingbats is a standard PDF font. Probably, this may be a Debian issue, but I would appreciate any info if you experienced something similar on your OS, or PDF reader app. #
Hello, first of all, I like this library, minimal yet powerful.
I have one question; does the API support streaming the pdf to disk, that way one could write lots of data to the PDF without being held in memory all at once?
The generated png_images.pdf is about 6MB in size,
but based on my estimates it should be under 3MB:
dice.png is 420 x 315 pixels = 132,300 pixels
132,300 pixels x 3 colors = 396,900 bytes for RGB data
396,900 x 5 background varieties = 1,984,500 bytes
gophers.png is 600 x 476 pixels = 285,600 pixels
285,600 x 3 colors = 856,800 bytes for RGB data
Additional data for PDF commands, let's say 200K
The file size should be about 3MB,
but the generated demo is 6MB
** What to consider: **
I tried to use nextline() and the x was zeroed but the Y was set o 2019.987654.
Something is not correct in the compute or the various devfaults.
Unicode support is essential in modern software, so we are going to implement some kind of Unicode support in this PDF writer. If you know or can link to any information about font embedding (to enable Unicode) or just referencing external fonts installed on the system in order to use Unicode, please let me know. Thanks for your attention.
How to know that SaveFile failed except by reading log?
Please return errors instead of logging them.
Application code should log, libraries should not log but return errors.
Other than that good library looking forward using it. Thanks.
Noticeable time (about 1 second) is spent when generating png_images.pdf
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.