July 2007 Archives

How to use iText in Lotus Notes

| No Comments

iText was introduced in iText and Lotus Notes, there are some important steps.
1. Download iText 1.3.6, if you use Notes 6.x.
2. Import the Jar to Script Library.
3. Write your PDF Java program for iText. I write Two page into One page effect that refer TwoOnOne.java . My TwoOnOne.java code.
4. Then, use LotusScript to create java object and run. LS2J Example DB is a good material.
My LotusScript:
Option Public
Option Explicit

Uselsx "*javacon"
Use "iText-Merge"

Sub Initialize
On Error Goto processError
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Set uidoc = ws.CurrentDocument

Dim rtitem As NotesRichTextItem
Dim filename() As String
Dim index As Integer
index = 0
If uidoc.IsNewDoc Then
Call uidoc.Save
Else
Set doc = uidoc.Document
Call doc.Save(False, False)
End If
Set doc = uidoc.Document
Call uidoc.Close
Set uidoc = ws.EditDocument(True, doc)
Set rtitem = doc.GetFirstItem("Body")
If Isempty(rtitem.EmbeddedObjects) Then
Msgbox "未放入PDF附件,請放入後重新執行!", 16, "錯誤訊息"
Exit Sub
End If
Dim nameflag As Boolean
nameflag = True
If ( rtitem.Type = RICHTEXT ) Then
Forall o In rtitem.EmbeddedObjects
If ( o.Type = EMBED_ATTACHMENT ) Then
If Right(o.Source, 3) = "pdf" Then
Redim Preserve filename(index)
Call o.ExtractFile( "c:\temp\" & o.Source )
filename(index) = o.Source
index = index + 1
nameflag = False
End If
End If
End Forall
End If
If nameflag Then
Msgbox "未放入PDF附件,請放入後重新執行!", 16, "錯誤訊息"
Exit Sub
End If

Java code for iText

Dim jSession As New JavaSession
Dim PDFClass As JavaClass
Dim PDFClass1 As JAVACLASS
Dim PDFObj As JavaObject
Dim PDFobj1 As JavaOBject
Dim jError As JavaError

Set PDFClass = jSession.GetClass("Concatenate")

Dim v As String
Dim x As Integer
For x = 0 To Ubound(filename)
v = v & filename(x) & "|"
Next
v = v & "FinalPDF.pdf"

Set PDFObj = PDFClass.CreateObject("(Ljava/lang/String;)V", v)
If PDFObj.merge() Then
Set PDFClass1 = jSession.GetClass("TwoOnOne")
Set PDFObj1 = PDFClass1.CreateObject("(Ljava/lang/String;)V", "C:\\TEMP\\FinalPDF.pdf")
If PDFObj1.print() Then
Msgbox "PDF合併列印完成,請列印NOTESDONE.PDF檔案!", 64, "執行結果"
Else
Msgbox "PDF合併列印發生錯誤,請通知資訊處NOTES經辦!", 16, "錯誤訊息"
Exit Sub
End If
Else
Msgbox "PDF合併檔案發生錯誤,請通知資訊處NOTES經辦!", 16, "錯誤訊息"
Exit Sub
End If
Dim rtitem1 As NotesRichTextItem
Dim object As NotesEmbeddedObject
Set rtitem1 = New NotesRichTextItem( doc, "Body1" )
Set object = rtitem1.EmbedObject( EMBED_ATTACHMENT, "", "C:\Temp\notesdone.pdf")
Call doc.Save(False, False)
Call uidoc.Close
Set uidoc = ws.EditDocument(True, doc)
Exit Sub

processError:
'** report any errors we get and keep on going
Set jError = jSession.getLastJavaError()
If (jError.errorMsg = "") Then
Print "Notes Error at line " & Erl & ": " & Error$
Else
Print "Error at line " & Erl & ": " & jError.errorMsg
jSession.ClearJavaError
End If
End Sub

I suggest using Eclipse to check your Java code. Notes IDE is poor for Java coding.


GaudiKML.jpg

之前看到Steven Ho貓空纜車,便好奇Google Earth還能怎樣的應用,剛好想起最愛的建築師-高第,沒空又沒錢去西班牙巴塞隆納,只好透過Google Maps來查看看,透過衛星圖來過過乾癮,突然便想到,何不把所有高第的建築皆標示起來,再透過Google Earth呈現,觀看Google Earth上提供全球的人拍攝之建築照,更可彌補書上照片的不足和地理資訊的遺漏。而在Google 3D Warehouse更可找到一些高第的3D建築,可在Google Earth上隨心所欲觀看,如米拉之家,透過這樣的虛擬旅行,下載
高第建築導覽KML檔(需先安裝Google Earth)、Google Maps的高第建築標示,可讓人更清楚了解高第偉大的建築。下次考慮再增加Frank Gehry的建築導覽。

iText and Lotus Notes

| No Comments

If you need to generate PDF from Lotus Notes, iText is best choice. But, Must select match version to your Notes version. Java JRE of Notes 6.x is 1.3.1, so iText 1.3.6 could work well in 6.x. If not they will be compile error.

Shell:
Dim result As Integer
result = Shell("CMD.EXE", 1)
Console:
consoleReturn$ = notesSession.SendConsoleCommand( serverName$, consoleCommand$ )

October 2008

Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

Archives

Pages

Powered by Movable Type 4.21-en

About this Archive

This page is an archive of entries from July 2007 listed from newest to oldest.

June 2007 is the previous archive.

September 2007 is the next archive.

Find recent content on the main index or look in the archives to find all content.