Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Am 24.06.2011 18:28, schrieb lee:
Alexander Thurgood<alex.thurgood@gmail.com>  writes:

Le 24/06/11 15:13, lee a écrit :

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
|
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 ...



--
Unsubscribe instructions: E-mail to users+help@global.libreoffice.org
In case of problems unsubscribing, write to postmaster@documentfoundation.org
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.