creating pdf with dynamic images from server

66 views
Skip to first unread message

adi baron

unread,
Nov 3, 2020, 3:51:56 AM11/3/20
to Prawn
Hello, Im new to the group.
In my service i would need to create a PDF with external images - from server or file system.
I should not embed the image inside the PDF itself.

I have found xobjects  which i believe should give solution but cannot find how to use it.
Would be great if i could be reference with an example for using it.

Thank you in advance,
Adi

Thomas Leitner

unread,
Nov 3, 2020, 6:54:30 AM11/3/20
to prawn...@googlegroups.com
On 2020-11-03 00:44 -0800 adi baron wrote:
> Hello, Im new to the group.
> In my service i would need to create a PDF with external images -
> from server or file system.
> I should not embed the image inside the PDF itself.

In general a PDF includes everything to display it, so images are
always embedded. This is one of the main features of a PDF file.

> I have found *xobjects *which i believe should give solution but
> cannot find how to use it.
> Would be great if i could be reference with an example for using it.

You have found the one exception :) However, support for external Form
XObjects is marginal at best and needs to be explicitly configured in
e.g. Adobe Reader. As far as I remember you even need to explicitly
allow each domain from which an external XObject is going to be loaded.

So for this work you need control over the client's PDF reader
application and this application additionally needs to support external
Form XObjects.

If you aren't developing for a tightly controlled business environment,
you are out of luck.

The good news is that you can tell whoever told you to just link the
images that it is just not (easily) possible.

All the best,
Thomas

adi baron

unread,
Nov 3, 2020, 1:17:07 PM11/3/20
to Prawn
Thank you Thomas for the detailed answer.

You wrote:
If you aren't developing for a tightly controlled business environment,
you are out of luck.

Well, 
I am developing for a tightly controlled environment - a big print house which needs to process images before printing, thus they have the tools to read such pdfs.
I could not find an example for using the xobjects.
it would be great if i could be referenced with such.

Adi Baron.


Thomas Leitner

unread,
Nov 3, 2020, 6:21:07 PM11/3/20
to prawn...@googlegroups.com
On 2020-11-03 10:17 -0800 adi baron wrote:
> Well,
> I am developing for a tightly controlled environment - a big print
> house which needs to process images before printing, thus they have
> the tools to read such pdfs.
> I could not find an example for using the xobjects.
> it would be great if i could be referenced with such.

Have a look at section 8.10.4 of the PDF 1.7 specification which talks
about reference XObjects.

Since Prawn doesn't directly support this, you would need to create the
needed PDF objects yourself and manually add them to the Prawn
document's PDF store.

Cheers
Thomas
Reply all
Reply to author
Forward
0 new messages