Scribus Forums

Scribus => PDF Generation => Topic started by: mike9000 on October 08, 2011, 09:39:13 pm

Title: How can I give several text fields the same name, please? Why? - read on...
Post by: mike9000 on October 08, 2011, 09:39:13 pm
I am creating pdf files for a business which has to send out a number of different paper forms containing a lot of the same information (e.g customer name and address) to various different organisations.

I started using Foxit PhantomPDF business and found that if I gave two text fields the same name, I only had to fill in the first field and the same information would automatically appear in the second.

Now, some items of information (e.g. the customer's name) have to appear in 8 different forms. I thought that if:

(1) I put all of the forms in one long file
(2) Called all of the fields that required the customer's name, 'c_name'

I would only have to enter this information once.

Using the same tactic for other recurring information - e.g. customer's address would save a lot of time, and it has worked quite well.

I would love to switch to Scribus, so that I do this job under Linux instead of Windows. However, Scribus refuses to let me use the same name (right-click and select  'Properties') for two or more text fields.

Normally, this would be a feature. For me, however, it is an obstacle. Does anyone if there is a way around it, please?


Title: Re: How can I give several text fields the same name, please? Why? - read on...
Post by: Meho R. on October 09, 2011, 02:51:18 pm
Even if Scribus allowed same names of text frames, this wouldn't solve anything. What you need here is JavaScript. Here's an example what you can do (note: I'm not acquainted with JS, so there might be an easier and more elegant solution than this one I'm presenting here):

1. Create all necessary text fields, but for boxes where one should enter data don't use "Insert Text Frame", but "Insert PDF Text Frame" instead. So, e.g., you'll have on the left a simple text frame containing "First Name:" entry, and on the right should be a placeholder in which a user will enter his/her name; this placeholder should be a PDF text frame, not a simple text frame.

2. Double click on created PDF Text Frame which will be placeholder for all other similar entries, then give it a unique name (eg. FN1 for this first "master" box containing First Name which will be entered manually, then FN2 for the second First Name PDF frame etc.) In the example attached, I used FN notation for "First Name", and SN for "Second Name". Of course, you can adapt this to your liking.

3. Now, for FN1 you don't have to do anything, but for FN2 ... FNn you'll have to enter a simple script which will make sure content of FN1 is displayed in FN2 ... FNn. To do so, double click on FN2 PDF text frame, go to "Calculate" tab, check "Custom calculation script" > "Edit..." and enter this code:
Code: [Select]
var a = this.getField("FN1").value;
this.getField("FN2").value = a;
This basically defines a variable, here named "a" as an example (var a), which will be content of FN1 PDF frame and which will be automatically filled in FN2 (thus "value = a" in the second line of the code). After you've entered the code, go to "File > Save and Exit".

That's all. Export the file to PDF and test it.