Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for embedded PDFs (e.g., for vectorial images) #1020

Closed
gioele opened this issue Apr 3, 2017 · 4 comments
Closed

Support for embedded PDFs (e.g., for vectorial images) #1020

gioele opened this issue Apr 3, 2017 · 4 comments

Comments

@gioele
Copy link

gioele commented Apr 3, 2017

It would be nice if Prawn could embed existing PDFs files into the PDF being generated. In my particular case, this would be useful to embed drawings, logos and other kinds of vectorial images inside Prawn-generated PDFs.

Right now Prawn's #image does not support any kind of vectorial images, only two raster formats: JPEGs and PNGs. In LaTeX-land the common formats used for vectorial images are EPS and PDF (they are natively supported by includegraphics inside pdftex). SVGs are also very common in other settings (web pages, for instance).

It seems to me that supporting PDF would be easiest way to support vectorial images in prawn. Supporting EPS and SVG would require writing decoders or transcoders for these formats.

IIUC, Prawn used to support templates that could be used to embed PDFs, as suggested by @practicingruby in issue #91. This does not seem to be the case anymore.

Proof-of-concept code by @yob against an old (2012) version of Prawn can be found at https://github.com/yob/prawn/commits/pdf_images.

@gettalong
Copy link
Member

@gioele Using PDFs as image format requires a PDF parser which Prawn doesn't have. However, Prawn can use the pdf-reader and prawn-templates gems for using PDFs as template for a page. Maybe this functionality could be reused for image support? @bvogel might know more about this.

@bvogel
Copy link

bvogel commented Apr 4, 2017

@gioele you can still use PDF-Templates via prawn-templates, however you are limited to one template per page and if you want to draw on top of the template it is recommended to fit the template size to the required page size. The code basically creates an additional content stream with the help of pdf-reader that sits in the background. The overall ramifications of this approach are above my level of understanding of the PDF specifications.

@pointlessone
Copy link
Member

There's a prawn-svg gem for embedding vector graphics.

@pointlessone
Copy link
Member

I'm calling out of scope for this request. There are prawn-eps and prawn-svg extensions maintained by wonderful people in the community. Those can be used to draw vector images in your documents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants