[Scribus] How to bold first word in every paragraph

Calum Polwart scribus
Fri Jun 23 20:37:42 CEST 2006


On Fri, 2006-06-23 at 06:43 +0200, tomjas at poczta.onet.pl wrote:

> Thanks - I hoped there might be solution for doing this job automatically.
> tomjas
> --

You can... (Everyone says you can't because I don't think it was ever
planned to work and I still don't understand how it works!)  I haven't
made my description clear enough though because I forgot a step.  It is
possible to automate this, but you need to do a little work...

Link your database into OO.o (I assume you know how - again ask if
stuck).  Your database will need some way to identify the first word
(i.e. the first word [would it always be just ONE word?] needs a
different field).  Some classifieds use first few words depending on the
add in which case you'd need to structure your data entry screen to
identify the relevant words...  However, that's immaterial

Set up a mail merge using the database so that the layout is something
like this:
<<First Word>> <<Rest of advert>> <next ad>
Then apply bold to the <<First Word>> bit like this:
<<First Word>> <<Rest of advert>> <next ad>
(Sorry haven't actually used OO.o mailmerge but I know this can be done
- so this may be a bit wooley - but ask if not clear)

Now run the merge and save the finsihed output as HTML, NOW COMPLETELY
CLOSE OO.o and re-open it (no idea why but you have to!) and open the
HTML file.  Now export the HTML file as an SXW file (possibly ODT will
work haven't tried, will when I write the wiki).  (Before you go to lots
of effort try it with a three line example typed by hand...

Alternative (possibly better!) - if you struggle with OO.o doing it
would be to write some PHP to do it from the SQL database?  and then
save the output webpage as an html file? Then open that in OO.o and
export it as SXW.
But the crucial thing (no mater how you create the html) will be to get
the first word into a seperate field. this bit of PHP should 'roughly'
work (untested):  [there may be slicker ways]

                
                <?php
                // Connect to the MqSQL Database - insert your connection details here
                
                // Read the next advert into a text string - substitute for your own selection code!!
                $query = "SELECT AdvertText FROM AdvertTable WHERE AdvertID = '1' ";  //replace table / field etc as appropriate, you'll also need to create a loop for each advert entry.
                $text= mysql_query ($query);
                
                // Spilt the text string into an array with each word as a separate array
                $words = explode( " ", $text );  //this creates the 'advert' as an array with each word as a new 'sub-array' (there is a space in the quotes)
                
                // Identify the first word
                $firstword =$words(1) ; //if that produces second word use $words(0)
                
                // Identify the other words
                // First delete the first word
                $words(1) = "";
                $otherwords = implode (" ", $words);
                
                //print the advert on screen with the first word in bold
                echo "<b>".$firstword."</b>".$otherwords."<br />";
                
                // you could also save these into a new SQL table if you wanted?
                ?>

If you set up the select above to come from a form that queries the data
for say  'current' adverts in some way then you should be able to use
this to create the html in a fairly 'automated way' and then all you
need to do is import it... I'm confident this will work!

Summary steps:
============
Create HTML File
Open HTML file in OO.o
Export HTML file to SXW
'Get Text' from SXW file in scribus


Calum

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://nashi.altmuehlnet.de/pipermail/scribus/attachments/20060623/493c84d4/attachment.html 



More information about the scribus mailing list