NOTESSIDAN

Allt om Lotus Notes & Domino




Notes data to PDF - From order to digital invoice
I have blogged about exporting notes data to word before and here is another easy guide for getting data out from Notes into a pdf file. Let's say you have a database containing orders from customers and want to send them a PDF invoice for each order. no problem, just follow this guide
All you need is word 2010 or later


1. Create a new word document and do your layout (or use an existing one already layed out )
2. Add the text placeholders you want to add notes data to , select it and click [bookmark]
3. Type the name of the placeholder/bookmark and click [add] and continue to do this for all the placeholders you want in your word document
4. save the word document as a template and name it c:\wordtemplate.dotx





5. Create new agent in the database where you have the Notes data and paste the following Lotusscript code


Sub Initialize

On Error GoTo e
Dim session As New NotesSession,dc As NotesDocumentCollection, i As Integer
Dim templatePath As String,pdfpath As String,pdffilename As string
Dim db As NotesDatabase, d As NotesDocument, c As integer
set db = session.currentdatabase

templatePath = "c:\wordtemplate.dotx"
pdfpath = "c:\"

Set dc = db.Unprocesseddocuments
c = dc.count

' create a pdf for every doc in view
For i = 1 To c
Set d = dc.getnthDocument(i)

' create a new word object
Set wdApp = CreateObject("Word.Application")
wdApp.Visible = false
Set wordDocs = wdApp.Documents

' create a new worddoc based on template
Call wordDocs.Add(templatepath, False )
Set wdDoc = wdApp.Application.ActiveDocument
wdDoc.Activate

' give the pdf a name
pdffilename = "pdf" + CStr(i) + ".pdf"

' insert bookmarks into new worddoc
' add a new line for each field you have in your notes document
' and for each bookmark you have in your word template

Call insertBkm("FirstName",d.Fld1(0))
Call insertBkm("LastName",d.Fld2(0))

' create pdf file
wdDoc.ExportAsFixedFormat pdfpath + pdffilename, 17

' close the word doc without saving
wdDoc.saved = True
wddoc.close

Set wddoc = Nothing
wdApp.Quit
Set wdApp = Nothing

Next
MsgBox "Agent Done - Created " + CStr(c)+ " pdf files in " + pdfpath,64,"Info"

Exit Sub
e:
Print Error,Erl
End Sub

Sub InsertBkm(sBookmark As String,sText As String )
On Error GoTo e
If sBookmark <> "" Then
If wdDoc.Bookmarks.Exists(sBookmark) Then
wdDoc.Bookmarks(sBookmark).Select
If Trim(sText) = "" Then
wdApp.Selection.TypeText ""
'wdApp.Selection.Delete
Else
wdApp.Selection.TypeText sText
End If
End If
End If
Exit Sub
e:
Print Error,erl
End Sub



6. from the action menu in Notes run the agent on selected document





7. Look in your file system for your newly created pdf files containg your notes data




The Resulting PDFs , the placeholders/bookmarks you added to word have been replaced by the fields in the notes document. If you format your word template nicely with headers, footers tables, logo, background etc these will be added to the pdf as well

Next step would be to store all your created pdfs in a database and mail them automatically to the customer.





Relevanta Poster på Notessidan:



Fler Poster om:

Fler bloggar om:

Technorati:

Delicious:
Publicerad 2014-03-14 | Kommentarer: 0 | Läsningar:

Kommentarer

No documents found



Sök på Notessidan
Thomas Adrian
ThomasCertifierad utvecklare och administratör inom Notes & Domino

Kontakta mig







Senaste Sökningarna på Notessidan
Sön - sharepoint (R:1)
Sön - räkna and antal and besökare (R:0)
Sön - browser (R:17)
Sön - stoppar and mail (R:1)
Sön - korrupt (R:3)
Sön - böcker (R:0)
Sön - kalendern (R:12)
Sön - feature (R:15)
Sön - print and mime (R:2)
Sön - länka (R:0)
Sön - databasen (R:94)
Sön - access (R:47)
Sön - outlook (R:15)
Sön - webanvändare (R:0)
Sön - google and maps (R:6)
Sön - juffe (R:2)
Sön - uidoc.print (R:1)
Sön - java and lotusscript (R:26)
Sön - besök (R:0)




Databasstatistik Blogg
Uppdateras var 15:e Minut

Antal Poster:562
Antal Kommentarer: 1381
Alla sidvisningar idag:
Unika Besökare idag:
Databasstorlek: 186,75Mb
Fixup: 2019-07-23 00:31:06
FT:2019-07-24 04:13:53
DB Procent använd: 99,5
Antal Agenter: 42
Antal Formulär: 65
Antal Vyer: 60
Antal Dokument: 7938
Antal Image Resources: 108
Antal Subformulär: 18
Antal Scriptbibliotek: 11
Totalt Antal Designelement: 576
Antal Attachments: 159
Antal Konflikter: 0
Server version 1: 405
Server version 2: Release 9.0.1FP9|August 14, 2017
Server Plattform: Windows/64
Ändrad: 2019-07-24 05:09:27
Server Tidszon: Z=-1$DO=1$DL=3 -1 1 10 -1 1$ZX=131$ZN=W. Europe
Region:
Kommentarsspam Idag: 7
Kommentarsspam Totalt: 17974


BlogRankers.com

Top Sites at iWEBTOOL.com

Fight Spam! Click Here!

Bloggtoppen.se

Listed on BlogShares

Increase website traffic

Top Internet Blogs

Site Checker