Page 1 of 1

Email "Button" to send a .pdf formular via mail

Posted: Wed Dec 06, 2017 12:46 pm
by davin
Hello everybody,

hopefully you can help me with my issue. Got a little problem and i'm kinda stuck atm.
First of all I want to say I'm a beginner in OpenOffice.

I made a formular for our costumers so we can evaluate the costumer satisfaction rate. I've made pretty good progress with the formular so far but now I want to add a e-mail button where the costumer can send his fully filled formular back to our office e-mail adress. The problem is I have no idea how to solve that.

Any ideas? :roll:

Grateful in advance

davin

Re: Email "Button" to send a .pdf formular via mail

Posted: Wed Dec 06, 2017 2:08 pm
by John_Ha
Welcome to the forum.

If you include " mailto:fred@example.com " in your form then, when someone clicks on " mailto:fred@example.com " in the PDF, it opens an email addressed to fred@example.com. See attached PDF. This does not create a subject line nor does it attach the PDF. Also, I think the user has to allow mailto: to open an email - I think it is default behaviour, but it can be prevented.

See mailto in wiki for more ideas.

As a new poster you will find much useful information in the Writer FAQ, the Writer Tutorials, the up to date Writer guide and the Writer Manual (especially Chapter 15 - Using Forms in Writer). When a pop-up window opens, click the Help button for extensive help on that function - it is often more comprehensive than the manual.

Also try searching the forum with email pdf form. Try Googling with email pdf form.

If your problem is solved please view your first post in this thread and click the Edit button (top right in the post) and add [Solved] in front of the subject.

Re: Email "Button" to send a .pdf formular via mail

Posted: Thu Dec 07, 2017 9:22 am
by davin
Thank you for your quick reply John!

Okay I see. Tested it and I can do this.
But - isn't there any option that the (saved) pdf file is attached to the email ? Our costumers are mainly older people who aren't used to attaching a file in an email. We fear that we won't get any respond.
I mean I know I could do this but this doesn't really solve my problem: mailto:fred@example.com?subject=my report&body=see attachment&attachment="/my_location_virtual_path/myfile.lis"

I googled a lot but didn't find the right answer tbh - same for the forum.

Thank you very much!

Re: Email "Button" to send a .pdf formular via mail

Posted: Thu Dec 07, 2017 12:29 pm
by musikai
I think this solution with pdf is difficult. To fill out the pdf a pdf-reader like adobe or pdfxchange or foxit must already be installed on the system. If you have a fresh installed windows 10 then the pdf will be opened in the browser app that isn't capable of filling out pdfs. Even when the person managed to fill out the pdf how are you going to know where he saved it? So either give detailed instructions or let the people give answeres directly in the email or create a website with form.

Edit: ok, there seems to be a way for PDFs to send themselve back to an email address:
Acrobat JavaScript mailDoc() method
But you can't create Javascript Buttons with OpenOffice AFAIK.
Scribus might work:
http://forums.scribus.net/index.php?topic=1368.0

Edit:
With scribus you can create your form and a button with this Javascript:

Code: Select all

this.mailDoc({
bUI: false,
cTo: "your email address",
cCC: "cc email address",
cSubject: "Order Form - Books",
cMsg: "Thanks for placing this order. We appreciate your business."
});
This will work.

Re: Email "Button" to send a .pdf formular via mail

Posted: Thu Dec 07, 2017 12:32 pm
by John_Ha
Once you can get the command to work you can convert it to a link by highlighting it and going Insert > Hyperlink ...

The problem is I cannot get the command to work :crazy:

I think Googling will be your best bet - if you can find how to do it in MS Word the same should work in Writer.

Re: Email "Button" to send a .pdf formular via mail

Posted: Fri Dec 08, 2017 1:23 pm
by musikai
Hi John,
You were quite close.
What works is giving Subject and body. Attachments are not supported by "mailto"-protocoll.
So for automatically attaching files to an answer one would have to use Scribus as posted before.
Good thing is you can import your OO_PDf with forms into Scribus and just add the javascript-button there (as described in earlier post).

Re: Email "Button" to send a .pdf formular via mail

Posted: Fri Dec 08, 2017 1:30 pm
by John_Ha
Excellent. Your PDF works for me - it opens an addressed email with the PDF attached.
Good thing is you can import your OO_PDf with forms into Scribus and just add the javascript-button there (as described in earlier post).
Inspect the PDF files with and without the button - you might find you can just edit the PDF file created by AOO with Notepad or Notepad++ (better) and insert the required content, copied from the Scribus PDF, to do what you want.

If your problem is solved please view your first post in this thread and click the Edit button (top right in the post) and add [Solved] in front of the subject. Also it should be form, not formula, in the subject.

Re: Email "Button" to send a .pdf formular via mail

Posted: Fri Dec 08, 2017 2:06 pm
by musikai
John_Ha wrote: Inspect the PDF files with and without the button - you might find you can just edit the PDF file created by AOO with Notepad or Notepad++ (better) and insert the required content, copied from the Scribus PDF, to do what you want.
Have you tried that? I always find it difficult to read PDF-code.

Re: Email "Button" to send a .pdf formular via mail

Posted: Fri Dec 08, 2017 2:42 pm
by John_Ha
musikai wrote:Have you tried that? I always find it difficult to read PDF-code.
A PDF is a mix of flat ASCII and binary.

If you could upload a minimal PDF (just one or two words) saved in Scribus without the button; and then add the button, and save it in Scribus, the "added button" code should be the only difference in the two PDFs and, even if it is binary, it may be able to be isolated.

I searched the PDF you uploaded but could not find the email ID so I think the "button" must be coded in binary.

See Understanding the Portable Document Format (PDF)

Re: Email "Button" to send a .pdf formular via mail

Posted: Fri Dec 08, 2017 8:37 pm
by musikai
Hi John,
Thank you for the "Understanding PDF" link!!!
To get a readable PDF I uncompressed the Scribus PDFs with PDFtk and could examine the bit about the added Java script.

Now I tried this:
Out of OO I exported a PDF only with a button(no action) (left side of the pic). Then with Notepad++ changed the action to run the added Javascript object. (right side of the pic). The result is a PDF with a workin button but somewhat incorrect xref-datastreams (as PDFXchange Editor tells me. Saving again in PDFXchange Reader would correct this).
Surely one would have to be more precise about how adding stuff to PDF works to get all correct.
So this was only a dirty hack and shouldn't be used at least this way :-) Better one uses Scribus.
Hacked PDF
Hacked PDF

Re: Email "Button" to send a .pdf formular via mail

Posted: Fri Dec 08, 2017 9:12 pm
by John_Ha
musikai wrote:So this was only a dirty hack and shouldn't be used at least this way :-) Better one uses Scribus.
I agree. But was worth having a look ...

I tried copying 7 + 23, and renaming 23 to 21, and replacing 7 + 21, but I got an error opening the PDF. I also changed the 23 in Object 7 to 21 but still got the error.

I doubt we are very wrong - I expect there is just a little mismatch somewhere...

Re: Email "Button" to send a .pdf formular via mail

Posted: Fri Dec 08, 2017 9:29 pm
by John_Ha
Got it!

1. Copy 7 0 obj ... endobj and 23 0 obj ... endobj from the PDF with the javascript
copy this.png
2. Delete 7 0 obj ... endobj in the PDF without the javascript, and replace it with what was copied
replace this.png
It now works ...

... but is a nasty hack. It looks like 7 0 obj item has the location co-ordinates for the box so they need to be correct for the new document. But you could always edit them to put the box where you want ... 8-)

Re: Email "Button" to send a .pdf formular via mail

Posted: Fri Dec 08, 2017 11:22 pm
by musikai
Hi John,
works but PDFXchange still complaints about xref structure.
I think hacking the PDF really is the hard way. Also I found out that the javascript-Button doesn't work in Foxit-Reader (Scribus and Openoffice PDFs).
But here is a solution that works in PDFXchange and Foxit Reader. AND is native OpenOffice way.
It doesn't send back the whole PDF but the form_data (.fdf) that can easily be read with a text editor.
https://www.libreoffice-forum.de/viewto ... 6379#p8223

You can create a button in OO, double click on it and set its action property to "submit form".
Button_Property_Action.PNG
To assign your email address right click on the button and choose "Form"
Form-properties.PNG
Form-properties.PNG (18.37 KiB) Viewed 16235 times
Now when the button is clicked in the PDF, the email program will be started with the email-address and the form-data.fdf attached.
The subject and body text can't be set. They will be filled by the PDF-Reader. It mostly reads:
subject: Data from "pdfname.pdf"
body: The attached file contains data which was filled into a form...

I simply reattach the files from the other forum here.

Re: Email "Button" to send a .pdf formular via mail

Posted: Sat Dec 09, 2017 12:43 pm
by musikai
Hahaha,
this was really a circle walk!
You can get the forms sent back as PDF as well. Just set it in the PDF-Export-Options:
FDF_PDF_HTML_XML.PNG
4 formats are possible:
1.FDF
(is said to be recommended for greatest compatibility)
2.PDF
(is said to make sometimes trouble on Acrobat Readers. Don't know. )
3.HTML
4.XML
XML will create a .xfdf which is nicer formatted than FDF. Can also be dragged into PDF-Readers.
It also looks like the best format when somebody wants to import the datas into a database. But I haven't found any project for OpenOffice that does that.

Re: Email "Button" to send a .pdf formular via mail

Posted: Sat Dec 09, 2017 11:45 pm
by musikai
For the .xfdf-files that one gets back by using the "XML" Option in the PDF Export-Options I wrote a Converter to CSV:
viewtopic.php?f=21&t=91524&p=433685#p433685
Please test!

Re: Email "Button" to send a .pdf formular via mail

Posted: Sun Dec 10, 2017 5:09 pm
by musikai
Hey Guys and Girls :-)
I modified the code above so you can collect all the .xfdf-answeres, put them in a folder and create 1 merged csv from them that gives you a nice table.
I searched the web for such an app and it seems you can save quite some bucks and spend for xmas instead ;-)

Re: Email "Button" to send a .pdf formular via mail

Posted: Sun Dec 17, 2017 2:05 pm
by musikai
Updated the converter to work with multiselection lists.
If you get sent back PDFs then you can create a CSV-Summery with this macro (using PDFtk):
viewtopic.php?f=21&t=91588