If you have a rich text field that contains a fair amount of information it will print nicely, but when it exceeds a certain amount of information each text paragraph will be printed on a separate page which causes a printout that normally would be of two pages to turn up on 40-50 pages. Really annoying and a waste of trees!
The solution to this problem is to enclose the rich text field in a table which compresses the content in the rich text field and prints nicely.
While testing, look at the print preview which shows the same result as the actual printing.
Technorati tags:
Lotus Notes, Domino, Rich text, Richtext, Print
October 31, 2007
Problem printing rich text fields
Posted by Niklas Waller at 8:10 AM 2 comments
October 23, 2007
Prevent pasting documents into a view
Short tip today!
If you want to prevent documents from being pasted into a view, click on section 'Querypaste' for the view and type Continue=False in the sub routine.
Technorati tags:
Lotus Notes, Domino, View, Paste documents
Posted by Niklas Waller at 3:41 PM 4 comments
October 18, 2007
Print selected documents and attachments from a view
I have been trying to figure out how to print a document and its attachments when marking it in a view. A colleague had an agent which did the works as long as the attachments only are word documents. But if you don't know if it is a word, pdf, rtf, jpg or any other attachment the code gets long, uggly and still you proabably haven't covered all possible cases. I have however found a solution thanx to Charles Robinson who shows how to shell a windows application to open the attachments.
I have used my existing code with this one and the result is an agent that can run on selected documents in a view, print the documents and each document's attachments. It is run through a view action.
The code is not ultimate at all and there are still some minor problems left like when no application gets associated with the attached file nothing is printed out and that acrobat reader doesn't close when done. Probably fixable, but I am satisfied for now.
As you can see below I have used a sleep command. This might have to be adjusted depending on many different things, but it is needed or else the documents and attachments competes who gets to the printer first and everything is unsorted.
Here's the code. Hope someone can enjoy it!
In Options add Uselsx "*lsxlc"
In Declarations add Charles Robinsons code:
Const SEE_MASK_NOCLOSEPROCESS = &H40
Const SEE_MASK_FLAG_NO_UI = &H400
Private Type SHELLEXECUTEINFO
cbSize As Long
fMask As Long
hwnd As Long
lpVerb As String
lpFile As String
lpParameters As String
lpDirectory As String
nShow As Long
hInstApp As Long
lpIDList As Long
lpClass As String
hkeyClass As Long
dwHotKey As Long
hIcon As Long
hProcess As Long
End Type
Declare Function ShellExecuteEx Lib "shell32.dll"_
Alias "ShellExecuteEx" (SEI As SHELLEXECUTEINFO) As Long
Declare Function TerminateProcess Lib "kernel32"_
Alias "TerminateProcess" (Byval hProcess As Long, Byval uExitCode As Long) As Long
In Initialize add the following code:
On Error Goto ErrorHandler
Dim SEI As SHELLEXECUTEINFO
SEI.cbSize = Len(SEI)
SEI.fMask = SEE_MASK_NOCLOSEPROCESS Or SEE_MASK_FLAG_NO_UI
SEI.lpVerb = "print"
SEI.nShow = 1
SEI.hInstApp = 0
SEI.lpIDList = 0
Dim s As New NotesSession
Dim session As New LCSession
Dim db As NotesDatabase
Dim object As NotesEmbeddedObject
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim downloadfolder As String
Dim extrachar As String
Dim filecounter As Integer
Dim filecount As Integer
Dim filen As Variant
Dim antalfiler As Variant
Dim i As Integer, x As Integer, y As Integer
Dim sFile As String
Dim uidoc As NotesUIDocument
Dim ws As New NotesUIWorkspace
Dim success As Variant
' Create a folder for temporary storage of files
downloadfolder = Environ("tmp")
Set db = s.CurrentDatabase
Set dc = db.UnprocessedDocuments
For i = 1 To dc.Count
Set doc = dc.GetNthDocument( i )
' Print document
Set uidoc = ws.EditDocument( False , doc , True , )
Call uidoc.Print(1)
' Get all attachments and print them
filen=Evaluate("@AttachmentNames",doc)
antalfiler=Evaluate("@Attachments", doc)
Call uidoc.Close
Delete uidoc
If antalfiler(0)>0 Then
For filecounter=0 To antalfiler(0)-1
x=x+1
Set Object = doc.GetAttachment( filen(filecounter) )
If ( object.Type = EMBED_ATTACHMENT ) Then
fileCount = fileCount + 1
If Dir(downloadfolder+"\"+ filen(filecounter))="" Then
extrachar=""
Else
' Extra character in case there are attachments with the same name
extrachar=Left(doc.universalid,4)+"___"
End If
Call object.ExtractFile (downloadfolder+"\"+extrachar+ filen(filecounter) )
End If
Next filecounter
End If
For y = 0 To filecounter-1
sFile = downloadfolder+"\"+extrachar+ filen(y)
SEI.lpFile = sFile
Call ShellExecuteEx(SEI)
Call session.Sleep(2000)
Next
' Delete all files
Call session.Sleep(5000)
For y = 0 To filecounter-1
sFile = downloadfolder+"\"+extrachar+ filen(y)
Kill sFile
Next
'Call TerminateProcess(SEI.hProcess, 0)
Next
Exit Sub
ErrorHandler:
msgbox Error$ & " on line " & Cstr(Erl) & " in " & Lsi_info(12)
Exit Sub
Technorati tags:
Lotus Notes, Domino, Shell, Print attachments
Posted by Niklas Waller at 6:11 PM 1 comments
October 13, 2007
Java references
I decided to create a Java references page as well (see Lotus N/D references for Lotus Notes/Domino and Sametime references) for my own use and possibly for someone else as well. Feel free to leave comments if you have suggestions to other reference pages and I will update this page.
Below is some of what I have come across so far.
Tutorials/References/APIs/Examples:
- Reference documentation
- Java2 Platform Standard Edition 5.0 API Specification
- The Java Tutorials
- The Java Developers Almanac 1.4
Tools/plug-ins for Java conventions:
- Checkstyle
- Checkstyle plug-in for eclipse
- Mobilefish Checkstyle configuration file
- Jalopy - Source code formatter
- SCJP FAQ
- SCJP Tiger Study Guide
- JavaBlackBelt - Java Certification Community
- JavaBeat - SCJP Mock exams
- eXamulator
- SCJP 5.0 preparation article
- nsf tools - Java Tips
- Using Lotus Notes with Eclipse to manage and run your Java programs
- Lotus Notes and Java
- Domino Javadoc Generator
Eclipse:
- Eclipse
- Eclipse Plugin Central
- Plugin: LotusScript Editor for Eclipse
- 10 Eclipse Navigation Shortcuts Every Java Programmer Should Know
Other:
Technorati tags:
Java, References, Code convention, Development, Certification, Notes and Java
Posted by Niklas Waller at 7:48 AM 0 comments
October 12, 2007
Conventions for Java code
I like the structure with Java. Although you can create structure with any language it somehow feels as it comes with Java, so it feels easier to accomplish and is kind of satisfying (in a really geeky way). So included in my personal project to be a kick-ass java developer (;-) I am also aiming towards writing nice, readable code that is based on predefined code conventions and guidelines both for the programming part but also for commenting.
You might have heard that really good written code doesn't need commenting. Maybe that's a bit exaggerated but in some sense true. If all variables, methods, classes and so on are named after specific conventions they will be more readable to you and other programmers that might inherit your code some day.
Take a look at the conventions for coding and commenting here:
- Code conventions for the Java Programming Language
- Java Programming Style Guidelines (another format of the above)
- How to write doc comments for the JavaDoc Tool
Technorati tags:
Java, Code convention, JavaDoc, naming, Programming Style Guidelines
Posted by Niklas Waller at 8:50 AM 4 comments
October 11, 2007
XHTML Character Entity Reference
For all of the web developers out there. Here's an Ajax-based structured reference tool for XHTML Character entities. It lists the allowed entities in HTML 4 and XHTML 1.0 as outlined by W3C.
Seems like it could be of good use at occasions!
Technorati tags:
Reference, Character entity, XHTML
Posted by Niklas Waller at 7:20 AM 0 comments
October 03, 2007
Get started with Dojo
Did you know that you could do this on any web page and fairly quickly? All you need to do is to access some javascript source files and add your own pictures. I might add the fisheye example to this blog later when I have more time.
With Dojo someone else has done the work for you to use for free and it works in any browser (or at least the most common ones).
I am currently looking into dojo and playing with it and I really like the way it's heading. An API (0.4.2) already exists much like Java's although they can't really be compared since the documentation certainly could be better with examples and references and it takes quite a lot of time to understand what to do with the objects if you're new to the toolkit. A really good thing is that you, as in Java, can choose what to include in your webpage. That is you don't have to import the entire library but only for example the widget functionality (dojo.widget.*).
Follow the link to dojo below to get started with several good tutorials and examples. But just to mention it, all you need to do is to download a zip-file and extract it to your file system. Then create a html-file, include dojo javascript source files and you're up and running.
Further on, and this is really interesting, there is a rumour that says that Dojo will be installed by default on the next version of Domino. Now if that's going to happen or not, I don't know, but it certainly gives me another reason to start looking at this.
If anyone knows any other good references or examples that you recommend please leave a comment.
- Dojo
- The Dojo Project's JotSpot wiki
- Alpha API (for Dojo 0.9)
- Dojomino: Info and tutorials for using Dojo with Domino
- The Dojo book, 0.9
- The Lotus Quickr templates contains a lot of dojo code I've been told.
Technorati tags:
dojo, JavaScript, Toolkit, Lotus Quickr
Posted by Niklas Waller at 11:50 AM 2 comments