Archive for January, 2008

Adding a pagebreak in a RichTextBox for printing

I found a creative way to force a new page when printing from .NET using a RichTextBox.
Here's some C# code to show you how i did it. It's not working copy paste ready code, it just shows the idea.


rtfText = getSomeRTFTextFromDatabaseFunction();
printingTextBox = new RichTextBoxEx();
printingTextBox.SelectedRtf = rtfText.Replace("newpage", "\\page");

As you can see when you put the text "newpage" somewhere in your rtf text, it will replace it with a rtf command \page which forces a new page when printing.

No Comments »

SVN copy repository

This script makes it possible to copy your SVN repository while generating a new UUID. It also sets up SVN DAV.
You may need to tweak it to work on your setup.
I use it to copy a template repository with all hooks to a new repository.


#!/usr/local/bin/bash

SVNBASE=/export/svn
SVNADMIN=/usr/local/bin/svnadmin
SVNUSER=www
SVNGROUP=www
TEMPFILE=/var/tmp/svn.dump
RM=/bin/rm
CHOWN=/usr/sbin/chown
APACHESVNCONF=/usr/local/etc/apache22/svn.conf
APACHERESTART="/usr/local/etc/rc.d/apache22 restart"
COPY=/bin/cp

#Dump source repository to file
echo "Dump source repository"
$SVNADMIN dump $SVNBASE/$1 > $TEMPFILE

#Create new repository
echo "Create new repository"
$SVNADMIN create $SVNBASE/$2

#Load dumped repository into newly created repository forcin new uuid
echo "Read dump into new repository"
$SVNADMIN load --force-uuid $SVNBASE/$2 < $TEMPFILE

#Delete source repository dump file
echo "Delete tempfile"
$RM $TEMPFILE

#Copy hooks from source to new repository
echo "Copy hooks from source to destination repostitory"
$COPY -R $SVNBASE/$1/hooks/* $SVNBASE/$2/hooks/

#Change ownerships
echo "Set ownerships"
$CHOWN -R $SVNUSER:$SVNGROUP $SVNBASE/$2

#Display result
echo "Copy completed.."

#Addin repository to apache conf
echo "Set up apache config for $2"
echo "" >> $APACHESVNCONF
echo " DAV svn" >> $APACHESVNCONF
echo " SVNPath /export/svn/$2" >> $APACHESVNCONF
echo "
" >> $APACHESVNCONF
echo "" >> $APACHESVNCONF

#Restart apache
echo "Restart apache"
$APACHERESTART

#Done
echo "Done..."

No Comments »