using fields in a text document

Hi,

I have a text document with mostly static data, and since it's kind of a
letter, there are a few things that are variable data, like a company
name, street, city, eventually a persons name and a salutation.

Now I would like to make it so that I can press a button and be
presented with a form or the like that lets me fill in the variable
data, inserts the data at the appropriate places into the document,
saves the document to a file I specify and exports the document as PDF
with a password for access rights to the PDF file set.

How do I do that? Does it take some kind of advanced programming?

Hi Lee

Its called "mailmerge" you will love it.

Tools > Mailmerge

regards

John

John B <johnb@email2.me> writes:

Hi Lee

Its called "mailmerge" you will love it.

Tools > Mailmerge

Please don't top-post.

The mailmerge tool requires an address list, which is something I don't
have and don't want to create in this case.

Hi Lee,

Now I would like to make it so that I can press a button and be
presented with a form or the like that lets me fill in the variable
data, inserts the data at the appropriate places into the document,
saves the document to a file I specify and exports the document as PDF
with a password for access rights to the PDF file set.

How do I do that? Does it take some kind of advanced programming?

If you don't want to go down the mailmerge route, then the answer is
yes, you will need to be able to program it in Basic or some other
scripting language that LibO knows how to interpret (Javascript or
Python for example) and can bind with UNO dialog components.

Really, the simplest way would be to use a Calc spreadsheet to hold the
data, and then bind those fields to your text document. Even here
though, if you want it to automatically export your filled in text
document as a password protected PDF, you will need to learn some kind
of programming to automate it.

Alternatively, use text placeholders in your document, but this will
force you to type in each time for each and every different data set.

Alex

In lotus wordpro - which is next to pure perfection - you have "click here boxes", which you place strategically in the places you need to type your data. They typically say ">click here to enter the date<" the when you do, it jumps to the next box. All my fax heders and letterheads have them.

Also built in to Lotus Wordpro is an internal mini mail merge simply by typing "<a new field name>" wherever you need the data , it will save all your contact details as you go (mail merge on the fly).

I have to say as yet I have not seen either of these 2 facilities in LO, however, I would have thought "click here boxes" were universal and I am just not looking hard enough.

regards

John B

PS - I am trained in all circumstances to be on top!

Dear Lee

Using my new found wealth of knowledge supplied be Tom - It looks like:>> "this is how to do it"

http://www.libreoffice.org/get-help/documentation/

goto chapter 15 - "using Forms in writer" and it explains how to do it

you also have to turn on a tool bar for it (who knew)

View > toolbars > form design

I would be so pleased to know if you get this to work.

regards

John B

John B <johnb@email2.me> writes:

John B<johnb@email2.me> writes:

The mailmerge tool requires an address list, which is something I don't
have and don't want to create in this case.

In lotus wordpro - which is next to pure perfection - you have "click
here boxes", which you place strategically in the places you need to
type your data. They typically say ">click here to enter the date<"
the when you do, it jumps to the next box. All my fax heders and
letterheads have them.

Also built in to Lotus Wordpro is an internal mini mail merge simply
by typing "<a new field name>" wherever you need the data , it will
save all your contact details as you go (mail merge on the fly).

I have to say as yet I have not seen either of these 2 facilities in
LO, however, I would have thought "click here boxes" were universal
and I am just not looking hard enough.

Thank you for bottom-posting :slight_smile:

Hm, that sounds like a nice feature; it's similar to what I'm doing,
just without the fields. It's a little more complicated, though, since
some of the data I'm entering is repeated at two places (and I enter it
twice manually). There would have to be fields that are pointers to
other fields already filled in --- perhaps Lotus Wordpro has something
like that as well.

Please accept my apologies for my last posting to you.

It was on top and I see you really like bottom postings, I will try not to do it again

regards

John B

Please accept my appologies for my last posting to you.

It was on top and I see you really like bottom postings, I will try not to do it again

regards

John B

Alexander Thurgood <alex.thurgood@gmail.com> writes:

Hi Lee,

Now I would like to make it so that I can press a button and be
presented with a form or the like that lets me fill in the variable
data, inserts the data at the appropriate places into the document,
saves the document to a file I specify and exports the document as PDF
with a password for access rights to the PDF file set.

How do I do that? Does it take some kind of advanced programming?

If you don't want to go down the mailmerge route, then the answer is
yes, you will need to be able to program it in Basic or some other
scripting language that LibO knows how to interpret (Javascript or
Python for example) and can bind with UNO dialog components.

Well, I'm thinking about using it, I just don't see yet how I could make
it really useful.

Really, the simplest way would be to use a Calc spreadsheet to hold the
data, and then bind those fields to your text document.

That is exactly what I'm trying to avoid. The workflow is like:

while(webpages) {

  check out the web page

  decide whether to send my document or not

  if(I send it) {
    create a new directory to save the document in // this is already
                                                   // automated by a
                                                   // shell script

    paste a unique reference number generated by the shell script into
    the document

    copy and paste some data like a company name and address and a
    persons name into the document

    adjust the salutation as needed

    go to another place in the document and enter the companys name and
    city

    save the document in the directory created by the shell script with
    a meaningful file name (like "<documentname>-<company>")

    export the document as pdf with a permissions password set

    create an email by editing an email template appropriately to send
    the pdf file by email

    save the webpage in the same directory as the LO document

    make a note in a text file that the document was sent in response to
    the particular web page
  }
}

I can hear this crying for (at least some more) automation from 10 miles
away ...

It is possible to gather the data inserted into the document in
advance. The problem is that when I do that, I think it would become
rather difficult to keep track of what happens. And I need to keep track
of what happens because I have to do some of the steps manually because
it would be too much effort to automate all of them.

Perhaps there is way to make things easier that I just don't see? I'm
free to change the workflow in whatever way I like, only the outcome
needs to be the same.

Even here though, if you want it to automatically export your filled
in text document as a password protected PDF, you will need to learn
some kind of programming to automate it.

Hm, I think someone here posted about commandline options for converting
to PDF. Perhaps I can use those ...

Alternatively, use text placeholders in your document, but this will
force you to type in each time for each and every different data set.

Placeholders ... can you address placeholders from the commandline? For
example, I'd create a document that has 5 placeholder fields and tell LO
on the commandline to process the document so that the data for the
fields I supply on the commandline is inserted into the document. Then
the document is converted to a PDF file.

Or can I use sed to modify the content.xml file and then use LO
commandline options to turn the file into a PDF? If that's possible, I
could make a script to produce the PDF files I need automatically ...

John B <johnb@email2.me> writes:

Dear Lee

Using my new found wealth of knowledge supplied be Tom - It looks
like:>> "this is how to do it"

http://www.libreoffice.org/get-help/documentation/

goto chapter 15 - "using Forms in writer" and it explains how to do it

you also have to turn on a tool bar for it (who knew)

View > toolbars > form design

I would be so pleased to know if you get this to work.

Thanks, I'll check it out and see if I can get it to work :slight_smile: I'll let
you know.

John B <johnb@email2.me> writes:

Please accept my apologies for my last posting to you.

It was on top and I see you really like bottom postings, I will try
not to do it again

No problem, it just makes things a lot easier to read, thanks :slight_smile:

Hi John,

John B wrote (24-06-11 16:46)

In lotus wordpro - which is next to pure perfection - you have "click
here boxes", which you place strategically in the places you need to
type your data. They typically say ">click here to enter the date<" the
when you do, it jumps to the next box. All my fax heders and letterheads
have them.

Writer does have fields that more or less work like that.
Look on this page, http://www.libreoffice.org/get-help/documentation/
Writer Guide Chapter 14.

Cheers,

John B wrote (24-06-11 17:48)

http://www.libreoffice.org/get-help/documentation/

goto chapter 15 - "using Forms in writer" and it explains how to do it

Ah, missed this one - sorry :slight_smile:

Alexander Thurgood<alex.thurgood@gmail.com> writes:

Hi Lee,

Now I would like to make it so that I can press a button and be
presented with a form or the like that lets me fill in the variable
data, inserts the data at the appropriate places into the document,
saves the document to a file I specify and exports the document as PDF
with a password for access rights to the PDF file set.

How do I do that? Does it take some kind of advanced programming?

If you don't want to go down the mailmerge route, then the answer is
yes, you will need to be able to program it in Basic or some other
scripting language that LibO knows how to interpret (Javascript or
Python for example) and can bind with UNO dialog components.

Well, I'm thinking about using it, I just don't see yet how I could make
it really useful.

Really, the simplest way would be to use a Calc spreadsheet to hold the
data, and then bind those fields to your text document.

That is exactly what I'm trying to avoid. The workflow is like:

while(webpages) {

   check out the web page

   decide whether to send my document or not

   if(I send it) {
     create a new directory to save the document in // this is already
                                                    // automated by a
                                                    // shell script

     paste a unique reference number generated by the shell script into
     the document

     copy and paste some data like a company name and address and a
     persons name into the document

     adjust the salutation as needed

     go to another place in the document and enter the companys name and
     city

     save the document in the directory created by the shell script with
     a meaningful file name (like "<documentname>-<company>")

     export the document as pdf with a permissions password set

     create an email by editing an email template appropriately to send
     the pdf file by email

     save the webpage in the same directory as the LO document

     make a note in a text file that the document was sent in response to
     the particular web page
   }
}

I can hear this crying for (at least some more) automation from 10 miles
away ...

This is crying for for some macros and for a database.
if you already know how to use shell scripts, it's not hard to learn to program some macros.
and you can use command-line commands inside macros as well.
so you can integrate your scripts into the macros. ( Coder : shell ( command-line command , options , ,).
If you make a database in Base with a table(or better more, with are linked together) with a column for each entry you have to make in the writer-document (and some more for information and ID) ,
you can connect the fields (columns) to text-boxes in the document (with invisible borders).
create a form (in Base), to insert the new data.
Then you need a macro to
Sub.....

     -create a new directory to save the document in
     -paste a unique reference number generated by the shell script (bette the macro)
      into the document (better the database)
     -save the document in the directory created by the macro with
      a meaningful file name (like "<documentname>-<company>"(use the database to find this name)
     -export the document as pdf
     -save the PDF with a permissions password (schell command inside the Macro)
     -create an email by editing an email template(using again the data from the database) to send
      the pdf file by email
     -save the webpage in the same directory as the LO document
     -make a note in the database that the document was sent in response to
      the particular web page
End Sub

regards
Frieder

Alexander Thurgood<alex.thurgood@gmail.com> writes:

Hi Lee,

Now I would like to make it so that I can press a button and be
presented with a form or the like that lets me fill in the variable
data, inserts the data at the appropriate places into the document,
saves the document to a file I specify and exports the document as PDF
with a password for access rights to the PDF file set.

How do I do that? Does it take some kind of advanced programming?

If you don't want to go down the mailmerge route, then the answer is
yes, you will need to be able to program it in Basic or some other
scripting language that LibO knows how to interpret (Javascript or
Python for example) and can bind with UNO dialog components.

Well, I'm thinking about using it, I just don't see yet how I could make
it really useful.

Really, the simplest way would be to use a Calc spreadsheet to hold the
data, and then bind those fields to your text document.

That is exactly what I'm trying to avoid. The workflow is like:

while(webpages) {

   check out the web page

   decide whether to send my document or not

   if(I send it) {
     create a new directory to save the document in // this is already
                                                    // automated by a
                                                    // shell script

     paste a unique reference number generated by the shell script into
     the document

     copy and paste some data like a company name and address and a
     persons name into the document

     adjust the salutation as needed

     go to another place in the document and enter the companys name and
     city

     save the document in the directory created by the shell script with
     a meaningful file name (like "<documentname>-<company>")

     export the document as pdf with a permissions password set

     create an email by editing an email template appropriately to send
     the pdf file by email

     save the webpage in the same directory as the LO document

     make a note in a text file that the document was sent in response to
     the particular web page
   }
}

I can hear this crying for (at least some more) automation from 10 miles
away ...

It is possible to gather the data inserted into the document in
advance. The problem is that when I do that, I think it would become
rather difficult to keep track of what happens. And I need to keep track
of what happens because I have to do some of the steps manually because
it would be too much effort to automate all of them.

Perhaps there is way to make things easier that I just don't see? I'm
free to change the workflow in whatever way I like, only the outcome
needs to be the same.

Even here though, if you want it to automatically export your filled
in text document as a password protected PDF, you will need to learn
some kind of programming to automate it.

Hm, I think someone here posted about commandline options for converting
to PDF. Perhaps I can use those ...

ther is a Basic example for a macro to export to PDF
its not clean code, but it should work:

sub export_to_PDF

rem define variables
dim document as object
dim dispatcher as object
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim args1(3) as new com.sun.star.beans.PropertyValue
args1(0).Name = "URL"
args1(0).Value = "file:///G:/test/test.pdf" ' you can use a variable to hold the path
args1(1).Name = "FilterName"
args1(1).Value = "calc_pdf_Export"
args1(2).Name = "FilterData"
args1(2).Value = Array(Array("UseLosslessCompression",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("Quality",0,90,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("ReduceImageResolution",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("MaxImageResolution",0,300,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("UseTaggedPDF",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("ExportNotes",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("UseTransitionEffects",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("IsSkipEmptyPages",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("FormsType",0,1,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("Selection",0,com.sun.star.beans.PropertyState.DIRECT_VALUE))
args1(3).Name = "SelectionOnly"
args1(3).Value = true
dispatcher.executeDispatch(document, ".uno:||ExportDirectToPDF||", "", 1, args1())
end sub

if you want I can translate this code in clean code without using the dispatcher

regards frieder

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I have a text document with mostly static data, and since it's kind
of a letter, there are a few things that are variable data, like a
company name, street, city, eventually a persons name and a
salutation.

Now I would like to make it so that I can press a button and be
presented with a form or the like that lets me fill in the
variable data, inserts the data at the appropriate places into the
document, saves the document to a file I specify and exports the
document as PDF with a password for access rights to the PDF file
set.

How do I do that? Does it take some kind of advanced programming?

I do *some* of that on a regular basis in my law office, since I send
out a lot of letters that are virtually identical ("Dear <TITLE>
<FIRSTNAME> <LASTNAME>, This letter is to remind you that your
<HEARING_TYPE> is scheduled to take place on <HEARING_DATE> at
<HEARING_TIME> before Judge <JUDGENAME> . . .").

What I ended up doing is just putting a blank page at the beginning of
the document where I list all the variables, then I just fill them in
there. I do the same thing when I know I'll have several documents to
print using the same information: for instance, initiating certain
kinds of lawsuits (where I'll have an initial demand letter, a copy of
the first draft of the complaint, a proposed settlement agreement, a
summons, and envelopes that will all contain pretty much all of the
same information) and for doing intake of criminal defense cases
(where I'll have the engagement letter, my client intake form, my
Appearance, the demand for information known to the prosecuting
attorney, retainer agreement, and so on). I just make all of those
documents part of a single LibO document, typing in the information on
the blank page at the beginning, and printing them out. To create the
PDF, I just export all of the pages except the initial blank data page.

I don't know if this is EXACTLY what you're looking for, but it might
accomplish much of the same thing.

- --
Steven Shelton

lee <lee@yun.yagibdah.de> writes:

I have a text document with mostly static data, and since it's kind of
a letter, there are a few things that are variable data, like a
company name, street, city, eventually a persons name and a
salutation.

Now I would like to make it so that I can press a button and be
presented with a form or the like that lets me fill in the variable
data, inserts the data at the appropriate places into the document,
saves the document to a file I specify and exports the document as PDF
with a password for access rights to the PDF file set.

How do I do that? Does it take some kind of advanced programming?

I'm making this a subthread in the hope that the progress in pursuing
different approaches is easier to follow when different approaches are
in different subthreads.

This subthread is about using the mailmerge tool to solve above problem.

What I found is that the mailmerge tool does produce results that can be
useful. Unfortunately, there seems to be a bug with remembering the data
sources:

Using the mailmerge wizard, I entered fields into my document as
needed. The data source for the fields was an LO spreadsheet. I was able
to produce PDF documents as I needed them.

The problem is that the documents can be produced only as long as the
data source, i. e. the spreadsheet, isn't modified. Once I put more
entries into the spreadsheet and save it, the fields appear from it as a
data source. The spreadsheet itself still shows up in the list of data
sources, though.

Since the modified spreadsheet still has the same name ("mm-testdata"),
LO adds a number to its name as a data source when adding it again, and
I now have two data sources: "mm-testdata" and "mm-testdata1". There
doesn't seem to be a way to remove a data source, and after two tries,
none of the two data sources contain any fields.

Since the name of the data source has changed --- or rather because the
fields in the data source the fields in the document are referring to
have disappeared -- the fields in the documents produced with the
mailmerge tool remain empty.

This means that each time I need to produce the PDF documents, I really
would have to gather all data in the spreadsheet in advance and to
recreate the "master" document from which to produce the PDF files with
mailmerge. After a while, I would end up with a multitude of broken
datasources, and it won't save me much work having to re-create the
"master" document every time.

So mailmerge is unfortunately broken, at least when using an LO
spreadsheet as a data source. I haven't tried to use something else
yet.

If I could use mailmerge, it would still leave me with the problem of
somehow saving additional data, i. e. the web pages, together with the
documents produced. I could probably find a solution for this, using the
reference numbers I already have.

Does someone know which datasources do work reliably for mailman?

planas <jslozier@gmail.com> writes:

Hi Lee

Hi Lee,

> Now I would like to make it so that I can press a button and be
> presented with a form or the like that lets me fill in the variable
> data, inserts the data at the appropriate places into the document,
> saves the document to a file I specify and exports the document as PDF
> with a password for access rights to the PDF file set.

[...]

Another possibility that works very well when you need a document that
needs the same type of content is to use an Input Field.

To do so:

>>>>OTHER (or CTRL F2) click on Functions Tab then click on
Input. Enter the name of the field in the Reference Box. Click Insert
and Dialog Box opens. Your cursor should be in the large empty box, if
not, click on the large box. Type the place holder text you want that
will displayed when SHOW FIELDS is active. Click OK then click Close.

Do this for every location you want insert text. I would save this
document as a template.

When you open this template Writer will ask you to enter data for each
field in the order they were created.

This is nice, only I'm not asked for what to put into the fields when
opening the document. Perhaps that was changed in more recent versions?
I have:

lee wrote (24-06-11 22:41)

Is there another way to make LO ask for the contents of the input fields
than opening the document?

Ctrl-Shft-F9 (from my memory).