Attachments in pdf ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Jan
Reply | Threaded
Open this post in threaded view
|

Attachments in pdf ?

Jan
Is it possible to generate a pdf containing attachments ? That is, embedding files into the document.

My specific case is a generated pdf based on a data set. I'd like to include the csv of the data set into the document. So they always stay together.

Thx,

Jan

Reply | Threaded
Open this post in threaded view
|

Re: Attachments in pdf ?

mojavelinux
Administrator
The only way I know to do this is to put the CSV in a listing block, though I wouldn't recommend it if the data is large.

I found some mentions of embedded files in the PDF/A specification discussions, but I don't know if it was accepted. Even if so, prawn / pdf-core (https://github.com/prawnpdf/pdf-core) would have to support it in order for us to make use of it in Asciidoctor PDF. (Though, there's also the possibility of adding prawn extension in Asciidoctor PDF, if someone was able to figure it out).

Cheers,

-Dan

On Thu, Dec 14, 2017 at 1:16 AM, Jan [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Is it possible to generate a pdf containing attachments ? That is, embedding files into the document.

My specific case is a generated pdf based on a data set. I'd like to include the csv of the data set into the document. So they always stay together.

Thx,

Jan




If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Attachments-in-pdf-tp6083.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Attachments in pdf ?

abelsromero
I am thinking this could be done with a Java Postprocessor and PdfBox. But the PostProcessor (https://github.com/asciidoctor/asciidoctorj/blob/master/asciidoctorj-core/src/main/java/org/asciidoctor/extension/Postprocessor.java) uses Strings, which I don't think works for PDFs.

Btw, attachments are not supported by PDF/A standard. You can create a PDF/A with attachments and PDF readers will say it's fine, but is not legal according to specification.
Reply | Threaded
Open this post in threaded view
|

Re: Attachments in pdf ?

mojavelinux
Administrator
Thanks for the insight, Abel!

Actually, the Postprocessor works on the output of convert, which is only guaranteed to be an object. In the PDF converter, this is the Prawn document object. I remember discussing this with Robert at some point, but I'm not sure if it ever got mapped in AsciidoctorJ that way.

Cheers,

-Dan

On Thu, Dec 14, 2017 at 2:51 AM, abelsromero [via Asciidoctor :: Discussion] <[hidden email]> wrote:
I am thinking this could be done with a Java Postprocessor and PdfBox. But the PostProcessor (https://github.com/asciidoctor/asciidoctorj/blob/master/asciidoctorj-core/src/main/java/org/asciidoctor/extension/Postprocessor.java) uses Strings, which I don't think works for PDFs.

Btw, attachments are not supported by PDF/A standard. You can create a PDF/A with attachments and PDF readers will say it's fine, but is not legal according to specification.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Attachments-in-pdf-tp6083p6086.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Attachments in pdf ?

abelsromero
OK, short answer: NO is not possible to write a Java PDF Postprocessor to manipulate the PDF.

Found the issue, (https://github.com/asciidoctor/asciidoctorj/issues/387) and it discusses the exact issue we have here. And it still happens with Asciidoctor 1.6.0.x, I wrote an extension for PDF and it fails with:
org.jruby.exceptions.RaiseException: (TypeError) cannot convert instance of class org.jruby.RubyObjectVar9 to class java.lang.String
Since the ouput object received is a #<Asciidoctor::Pdf::Converter>, the only way to interact with it is via Prawn or as Robert mentioned writting a whole PDF wrapper in Java. Last options is just reivneting the wheel to me, way out of our scope.
But if instead of String it provided a Stream with the processed data, one could redirect it to any other API to manipulate it.

Btw, I am laughing at Robert's sentece:
 I'm also fine to stay with the current situation as it seems that no one really had these problems yet.
Sooner or later, `yet` alwasy gets you.
Jan
Reply | Threaded
Open this post in threaded view
|

Re: Attachments in pdf ?

Jan
Never say "never" indeed. :-)