speedata / publisher

speedata Publisher - a professional database Publishing system
https://www.speedata.de/
GNU Affero General Public License v3.0
296 stars 36 forks source link

about extending `AttachFile` #376

Closed pr-apes closed 2 years ago

pr-apes commented 2 years ago

@pgundlach,

I have just learnt that there is an AttachFile command, but only implemented for https://github.com/speedata/publisher/blob/7a422e778aeb0973ca37a6b7547a873bac98fbaf/src/lua/publisher/commands.lua#L207-L212

How about extending it to attach PDF documents (to start with)?

I mean, in some PDF documents, being able to attach other (PDF) documents may be an essential feature.

One may send a letter with an invoice and/or a report attached to it (just to name an example).

Many thanks for your help.

pgundlach commented 2 years ago

This is surely possible to extend. Just waiting for someone that really needs this.

(Development is currently prioritised for https://github.com/speedata/boxesandglue - if there is an urgent need for a feature here, I'll add it of course)

pr-apes commented 2 years ago

Sorry for not being explicit, I asked because I need this.

Not every document has attachments, but there are some types that need them.

But first I have to make Publisher work for my needs.

I’m closing the issue. When I’m ready to use attachments (because everything else is fine on my side), I’ll reopen it.

pr-apes commented 2 years ago

I have just discovered that name allows non Unicode characters and description doesn't handle them right.

<AttachFile filename="invoice.xml" name="χαλεπἀ.xml" description="ñÜß" type="ZUGFeRD invoice"/>

I think utf8_to_utf16_string_pdf() is missing. But replacing this line contents

https://github.com/speedata/publisher/blob/d056caa40ff24c076fc3d8693bbde811623c9d57/src/lua/publisher.lua#L7147-L7155

with this line content works fine:

   /Desc %s 
   /EF << 
     /F %d 0 R 
     /UF %d 0 R 
   >> 
   /F (%s) 
   /Type /Filespec 
   /UF %s 
 >>]],utf8_to_utf16_string_pdf(description), fileobjectnum,fileobjectnum,destfilename,utf8_to_utf16_string_pdf(destfilename))) 

In short, /Desc %s should read /Desc %s and escape_pdfstring(description) should read utf8_to_utf16_string_pdf(description).

Sorry for the mess, but providing a patch (without writing rights in this repository) has been in the past a pain for both you and me.

I hope it helps.

pr-apes commented 2 years ago

BTW, I would really appreciate having attachment abilities for PDF and other document types.

But we can discuss that later.

pgundlach commented 2 years ago

Sorry for the mess, but providing a patch (without writing rights in this repository) has been in the past a pain for both you and me.

Thank you, next version will have this patch.

pr-apes commented 2 years ago

Thank you, next version will have this patch.

Great news.

pr-apes commented 2 years ago

Closing, since I'd try a different approach.