Archive | editing RSS for this section

File creation from command line in Libreoffice

I would like to be able to just type

$ libreoffice /path/to/filename.odt

and create as well as open an odt file. This would save messing around with GUI file dialogues.

This is sort of possible.

$ libreoffice newfile.odt

does not work.

$ libreoffice --writer newfile.odt

does not work.

$ libreoffice -n newfile.odt

does not work.

$ soffice --writer newfile.odt

does not work.

$ soffice --writer 

or

$ libreoffice --writer

opens a blank Writer screen but you then have to use the Save dialogue to name the file.

$ touch /path/to/filename.odt

$ libreoffice /path/to/filename.odt &

sort of works. touch creates an empty file, which libreoffice (or soffice) will open as a text file. If you hit Ctrl-s within LibreOffice you will have to tell it to save as odt, but you don’t have to navigate to the folder you want.

Sadly, giving an extension (odt, odp, ods) does not help LibreOffice choose the right program to use to open the file. They are always treated like plain text and always opened in Writer, even if you type something like

$ touch test.odp

$ libreoffice --impress test.odp

So that’s less than optimal. if one can be bothered, there is a bodge that lets this happen more cleanly. I opened LibreOffice Writer and created a blank file, called blank_writer_doc.odt and put it in ~/bin, and similar for Calc. I don’t use the other tools enough to bother.

Then in ~/bin created the following script, called Writer:

$ cat Writer
if [ -f "$FILE" ]; then
  echo "File $FILE exists. Replace? y for yes, anything else for no."
  read replace
  replace=q$replace
  if [ $replace = "qy" ]; then
    echo "File $FILE overwritten with blank document."
    cp ~/bin/blank_writer_doc.odt "$FILE"
    libreoffice "$FILE" &
  else
    echo "Opening existing file."
    libreoffice "$FILE" &
  fi
else
  echo "File $FILE does not exist. Created."
  cp ~/bin/blank_writer_doc.odt "$FILE"
  libreoffice "$FILE" &
fi

And now I can type

$ Writer newfile.odt$

and it works.

The bit with adding ‘q’ to the response means that the response is never empty, so the if does not barf if the user just hits ‘Enter’. (If if is asked to work on an empty response, you get:

 line 5: [: =: unary operator expected

Writer.

Advertisements

Successful science writing and editing

Recently I attended a workshop called ‘Successful science writing and editing‘, facilitated by Kath Kovac, a freelance editor and trainer who often works with Biotext, my employer. Kath did a great job. She has a lot of experience in writing and editing technical material, built up over many projects working with CSIRO and many other organisations. She wears the erudition lightly, which is great.

While a lot of the material was familiar — after all, I work in the area — it was good to see how another professional thinks about it and talks about it. Every editor has their own set of things that irk them. It seemed to me Kath is particularly attuned to pointless openings to sentences. Sentences that begin with ‘There are’ or ‘There is’ or (worse) stuff like ‘It should be noted that’.

For example:

Instead of: There are many sentences that, like this one, are longer than necessary.

How about: Many sentences, like this one, are longer than necessary.

It seems like a small change, but if every sentence gets a little sharpening, the whole document gets an amazing lift. It becomes more engaging, clearer and easier to read and understand. Some writers do this instinctively, the rest of us have to make conscious checks.

I also enjoyed the contributions of the attendees. No matter how familiar the material, the people are always new when you’re training or educating, and that keeps it fresh. A microbiologist gave us the definition of biosolids. We explored structuring documents, and the example was a fact sheet about the benefits of eating quoll.

All in all, a very enjoyable and illuminating experience! Though we never got to taste quoll.

I even got a certificate.

 

Training

 

A document about inserting nonkeyboard glyphs when working in Microsoft products

See djg.altervista.org for a PDF. It’s just a short document about inserting nonkeyboard characters into Word documents and other Microsoft products.


That’s it, f-f-folks.

PDF booklet-y stuff using pdfjam and pdftk

Say you scan an A5 booklet by opening it flat and scanning each pair of pages. You can then print it out in landscape, stapled on the left and you can read the whole booklet in order. But the pages are out of order if you want to make a new saddle-stapled booklet.

So, let’s say I have a PDF like this one: http://site.xavier.edu/polt/typewriters/quietriter.pdf

Scrteenshot of the pdf, showing the arrangement of pages.

Spread from the PDF of the booklet — pages 4 and 5 scanned onto a single landscape A4 or letter paper page.

And I want to rearrange it so that I can make it into a proper (roughly A5-sized) booklet, stapled in the middle rather than along the edge. Well, there might be a tool for this, but …

(1) We open it in gv and find out that it’s 788 wide, half of which is 394. It’s also 598 high.

(2) Use pdfcrop.sh to make 2 PDFs, one of the left half and one of the right half.

$ pdfcrop.sh -t "0 0 394 0" quietriter.pdf quietriter1.pdf
$ pdfcrop.sh -t "394 0 0 0" quietriter.pdf quietriter2.pdf

Looks good. (Hint: Some PDF viewers don’t view the cropped files correctly — if it looks wrong, try a different viewer before messing with the dropping commands).

Page order in quietriter1.pdf is: back cover (24) inside front cover (2) 4 6 8 10 12 14 16 18 20 22
Page order in quietriter2.pdf is: front cover (1) 3 5 7 9 11 13 15 17 19 21 23

(3) Now, for booklet order, the simplest thing to do would be to put these in order (1, 2, 3, …, 24) then use pdfbook (part of pdfjam).

Sounds like a job for pdftk …

First, we’ll put the first page of quietriter1.pdf to the back. From what I can see, this should work:

$ pdftk quietriter1.pdf cat 2-12 1 output quietriter1a.pdf

(This conCATenates the selected page ranges in the order given.)

(4) Then we interleave 1a and 2 using shuffle, which is designed for just this sort of job:

$ pdftk A=quietriter1a.pdf B=quietriter2.pdf shuffle B A output quietriter_inorder.pdf

(5) Then we use pdfbook to reorder into booklet order.

pdfbook quietriter_inorder.pdf

That gives quietriter_inorder-book.pdf.

(6) We print the file double-sided with flip on long edge. (I just printed it from Acrobat, having done the command line manipulation running the PDF tools within Cygwin.)

(7) Looks good! Of course, there are no bleeds, but a quick saddle staple and then trimming with a guillotine and it looks very nifty, and a lot like an original booklet.

photo of the typewriter and manual.

The Remington Rand (Sperry Rand) Letter-Riter (what a terrible name for a typewriter!) with a facsimile of the manual, produced as outlined here.

 

Booklet.

***king Articulate360

Just a note that as of June 2018 Articulate Storyline or 360 or whatever it’s called does some weird and dangerous file handling.

[Note: Apparently the sudden loss of your precious precious work can be mitigated by avoiding unusual characters in file names (spaces being considered unusual) and by working on a local drive (“C:” in Windows world) rather than a networked drive. I am currently trying this to see if it helps.]

So … the context … I am working away, modifying an existing presentation. I click somewhere, and suddenly get bounced back several slides and all my changes for the last X minutes get lost — even if I have saved the file!

The first time it happened I thought, right, I better save the file every change. But that does not help! It is like it is reverting my last few changes and then forgetting them so I cannot redo them — sometimes as many as 6 slides of work is lost!

This is just not acceptable. Especially since people have been having similar problems for years.

In the end, I find I have to save regularly (like every minor change unless I want to repeat it) and after any big changes I close down the program completely then reopen it. I also work on local files (ie on my computer, not the server).

So far, that seems to have reduced the issue to manageable proportions.

Also, no nonbreaking spaces. In 2018, no nbsp. Not impressed.

As of 2018 Alt-0160 does not work in Storyline360, whether using number row or numeric keypad or even the Symbol menu where it is called ‘NO-BREAK SPACE’. Pretty underwhelming — though that is not to say they are not taking the issue seriously — they are.

Does not work regardless of Num Lock setting. I have tried inserting Alt-0160 with and without Num Lock and using Insert → Symbol and choosing character 0160 from the character map. Just does not work. I get a space, but it’s a breaking one, I’ve tried inserting a nonbreaking space in a word document and then copying and pasting that into the Articulate document (this works in PowerPoint, for example) and that does not work either.

Pasting from Word using the different options (like Keep Source Formatting) does not work either.

If I paste a nonbreaking space in from Word (or PPT) and then copy and paste it back from Articulate into Word (or PPT), it turns into a regular space. So Articulate is somehow converting it to being the wrong character. FWIW, en rule Alt-0150 works fine.

I installed the program less than a week ago, so it is completely up to date.

Anyway, that’s my experience of this thing — that they want to charge over $1000 for!

Far out.

Thanks anyway.

Printing PowerPoints with notes two (or more) to a page (repeat)

This is just a text-only version of the previous iteration with some new details. Just for the record. I had to work up the documentation, so why not post it?

This is what I did to print out PowerPoint slides two per page including the notes underneath.

There is (as of 2018) no option in the PowerPoint print dialogue for this. Note also that I do not have access to a full version of Adobe Acrobat Professional or whatever they are calling it at the moment.

(1) ‘Designed’ notes text in PPT; something like 12 pt for notes and 9 pt for refs/sources (Myriad Pro, though Univers works well too). Formatted notes consistently. To work with the slide notes in the text block under the slide, used ‘Notes Page’ under View. Can resize and so on and get WYSIWYG while formatting.

(2) Used CutePDF (http://cutepdf.com/) to print to PDF file. Went into Advanced settings for CutePDF and made sure paper was A4. Set Print Quality to ‘1200 DPI’, Set TrueTypeFont setting to ‘Download as Softfont’. Under PostScript Options set PostScript Output Options to ‘Optmimize for Portability’ and TrueType Font Download Option to ‘Native TrueType’. Other PDF print options might be acceptable; don’t know. Mac tends to work better with PDF than Windows. Cannot just use ‘Save as PDF’ option from the File menu because that does not give the notes pages.

The Print settings for PowerPoint (rather than the printer) were:
* Color (sic)
* Portrait
* Collated
* Notes Page (Print slides with notes)
* Print all slides (or the range you want)
* Printer: CutePDF
* No header or footer

Then printed and saved the file.

(3) I decided to crop the resulting PDF using a command line tool, because that is highly reproducible — I can get exactly the same cropped box every time.

I used pdfcrop.sh in Cygwin. Cygwin (https://www.cygwin.com/) is a Unix-like environment for Windows; pdfcrop.sh would probably work seamlessly in a command line terminal on a Mac if the software tools it draws on were already installed, possibly through Macports or similar.

pdfcrop.sh is available from https://askubuntu.com/questions/270493/how-to-crop-a-multi-page-image-scanned-pdf-file-which-wont-crop-with-pdfcrop, and also from https://darrengoossens.wordpress.com/2018/02/25/crop-every-page-in-a-multipage-pdf-file.

The pdfcrop.sh command looked like this:

$ pdfcrop.sh -t "105 112 105 112" infile.pdf outfile.pdf

The four numbers are how much to crop from left, top, right, bottom; I worked them out by opening the PDF in GSview (http://pages.cs.wisc.edu/~ghost/gsview/), a Windows-based viewer for PostScript and PDF files that gives coordinates of the pointer, so I could just move my mouse to where I wanted to crop and note down the coordinates.

I know there are graphical cropping tools, but this works and can do lots of pages. Feel free to use whatever tool works for you, but keep in mind that the ability to make exactly the same crop box every time is very useful. An automatic cropping of white space is not ideal since might vary from slide to slide or vary with alterations of the PPT file. It will also fail to remove any page numbers or footers/headers that are present.

(4) I now had a PDF file with the pages, including notes, cropped to have narrow margins. The next step was to put two onto a single landscape page. You can do this by opening the cropped PDF in say Acrobat and then printing to PDF again, after selecting ‘2 pages per sheet’ or equivalent in the print dialogue.

My preference was to use a command line tool. pdfnup (version 2.08 when I used it) is part of pdfjam, which in turn builds on the pdfpages stuff that is part of LaTeX:

$ pdfnup --batch --suffix '2up' outfile.pdf

This takes the ‘outfile’ from the pdfcrop.sh step and makes a new PDF with two pages per page and adds the suffix ‘2up’ to the file name, so the final file is ‘outfile-2up.pdf’

I have noticed that pdfnup gives less white space around the slides (and thus bigger images and text) than printing two per page using Acrobat.

Darren Goossens
darren.goossens@biotext.com.au

29 May 2018

VT220 time

Note that the quote marks work fine if I force ‘straight quotes’ rather than smart ones — the is my mistake, not the font author’s…

quotes.png

Font of the week: Glass TTY VT220, a font to look like a DEC VT220 screen, obtained by reference to how the glyphs were actually implemented by the CRT.

File is: Glass_TTY_VT220.ttf

Available from: http://sensi.org/~svo/glasstty/

Here’s an example, just screengrabbed from LibreOffice — and I forgot to turn off curly quote marks..

bitmap image showing the text sample; text of sample is repeated below in readable form.

An example of the font Glass TTY VT220, a TrueType font to mimic a DEC VT220 terminal. I suggest viewing at full size.

Here’s the text:

Hello, here is my amber screen, looking pretty good, eh? The font is Glass TTY VT220, available from http://sensi.org/~svo/glasstty/.
It is designed to mimic what you’d see on the screen of a DEC VT220 serial terminal from about 1985. Not all the characters are available, although everything that could be entered on such a terminal is there.

!@#$%^&*()_+1234567890-=
qwertyuiop[]\QWERTYUIOP{}|
asdfghjkl;’ASDFGHJKL:”
zxcvbnm,./ZXCVBNM<>?

You’ll note the quote marks don’t quite cut it, but otherwise it’s pretty nifty.

As noted, the quote marks do cut it. Maybe I’ll suck it into FontForge and see if I can come up with some ‘smart’ quote marks that match the spirit of the font.

Nice, though.

Printing PowerPoints with notes two (or more) to a page

I want to print out PowerPoint slides with the notes under each one, but I want more than one slide per page, which is the only PPT option.

Here are the steps I used.

(1) ‘Designed’ notes text in PPT; something like Univers 12 pt for notes and 9 pt for refs/sources. Formatted notes consistently.

To work with the slide notes in the text block under the slide, used ‘Notes Page’ under View. Can resize and so on and get WYSIWYG while formatting.

Screenshot.

PPT in Notes Page view.

(2) Used CutePDF to print to PDF file. Made sure paper was A4. Set to high DPI. Other settings in Printer Properties that might help if font issues arise are arrowed in green in the image.

Screenshot.

CutePDF dialog boxes.

The Print settings for PowerPoint (rather than the printer) were:

  • Color (sic)
  • Portrait
  • Collated
  • Notes Page (Print slides with notes)
  • Print all slides (or the range you want)
  • Printer: CutePDF
  • No header or footer

Then printed and saved the file.

(3) Used pdfcrop.sh in Cygwin:

$ pdfcrop.sh -t "40 100 40 100" infile.pdf outfile.pdf

(The four numbers are how much to crop from left, top, right, bottom; I worked them out by opening the PDF in GSview, which gives coordinates of the pointer.) I know there are graphical cropping tools, but this ‘just works’ and can do lots of pages.

Can also use Heiko Oberdiek’s pdfcrop:

$ pdfcrop --clip --margins "9 9 -80 -120" temp.pdf
PDFCROP 1.38, 2012/11/02 - Copyright (c) 2002-2012 by Heiko Oberdiek.
==> 127 pages written on `temp-crop.pdf'.

In this case, set the margins to be added to the area that a tight crop of all white pixels would do if done automatically. That means I ended up adding a 9 bp margin top and left. The clip right and bottom was determined by the page number in the bottom right corner, so the -80 goes 80 in from the outside edge of the page number, and similar for the 120. It’s a bit messy but reviewing the results in gv and then iterating works well enough.

(4) Opened cropped file in Acrobat and printed to PDF again, also using CutePDF, again checking for A4 paper, this time landscape, Multiple 2×1.

OR

In Cygwin, used something like

$ pdfnup --batch --suffix 'twoup' infile.pdf

Note that this gives different margins around the combined pages — pdfnup makes for bigger slides and less white space than Acrobat (note, I only have the reader, not Professional).

screengrab

Notes and slides 2 up using pdfnup; grey around the edges is my desktop, not part of the result.

Works for me. 

YMMV.

Getting a2ps to work

Installing a2ps on my Debian Linux box.

sudo apt-get install a2ps

and since I’d been printing from the GUI, had to define the default printer

$ lpstat -p -d

printer Brother-HL-5350DN is idle.  enabled since Thu 19 Apr 2018 20:31:20 AEST
printer Stylus-TX100 is idle.  enabled since Fri 06 Apr 2018 20:23:28 AEST

$ lpoptions -d Brother-HL-5350DN

Then tested a file using a2ps and got this on the printed sheet:

ERROR NAME;
   undefined
COMMAND;
   Helvetica-Bold
OPERAND STACK;

which is not very helpful. Tried changing font by specifying a different prologue; same problem.

Can test by sending output to a file:

$ a2ps input.txt  -o output.ps

$ gv output.ps

Output to a file looks fine. So problem is that it is not a PostScript printer. Duh! Took me too long to twig, but I got there in the end. Plain text works fine — I can lp the file, for example, and get a good result.

So what to do?

$ info a2ps

and hunt around.

My printer is a PCL printer (printer command language, like most HP-clone ones) and a good reliable subset of PCL can be obtained by pretending it is a LaserJet 4  (ljet4 in GhostScript) (600 dpi is enough for this).

So, here is my a2ps config file:

$ cat .a2ps/a2psrc
Options: --medium=A4
Options: --sides=2
Options: -2
Options: -d Brother-HL-5350DN
Options: --prologue=fixed
Printer: Brother-HL-5350DN \
       | gs -q -dNOPAUSE -sDEVICE=ljet4 -sOutputFile=- - -c quit\
       | lp -d Brother-HL-5350DN

And this gives me the output I wanted. I might need to add ‘tumble’.

PostScript

Shrink a PDF — if downsampling is OK

Converting back and forth between PostScript and PDF can sometimes shrink a PDF substantially. But sometimes not; depends on text to image ratios and so on. If it’s ok to lower image resolution, try this:

gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dDetectDuplicateImages=true -sOutputFile=outfile.pdf infile.pdf

The bit ‘-dPDFSETTINGS=/screen’ chooses and image resolution suitable for viewing on screen. Given that screens are typically 96 dpi these days, that means few pixels to store. ‘-dDetectDuplicateImages=true’ does what the name says on the box; it is particularly good if each page has a watermark or image in a header or footer, since it will store the image once for the document instead of once per page.

‘-dCompatibilityLevel=1.4’ basically sets the version of PDF. Newer versions give smaller files with more features, older versions are more likely to be viewable on all systems. I tried it with all settings and found that once I got to 1.3 or above it made no difference, but 1.2 was quite a bit bigger and 1.1 was too old to work for the PDF I was processing.

I changed the line to this and put it in a script:

cat ~/bin/pdf_downsample.sh
echo "gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dDetectDuplicateImages=true -sOutputFile=screen_$1 $1"
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dDetectDuplicateImages=true -sOutputFile=screen_$1 $1

So I just call ‘pdf_downsample.sh filename.pdf’ and it creates screen_filename.pdf

Useful.