Archive for April, 2007

Demo integration Lotus Notes and activePDF

I received some questions on a previous article on integrating Lotus Notes / Domino with activePDF.

A quick wrapup: yes via LotusScript you can make a connection with activePDF’s server products (in this case I use activePDF server and activePDF Toolkit professional which you can download for evaluation here). With activePDF you can create, stitch, write on PDF’s. Lotus Notes / Domino we use as web-engine, configurator & database to store created PDF’s for furture handling.

In the demo itself I only demonstrate how to write a text-line to a PDF but in the original article you find more examples how to add text area’s, pictures & drawings to a PDF.

How to get it running?

  • Copy the database to your data directory and open the database in Notes.
  • In the ‘Edit DB Settings’ menu-link (which you see if you apply ‘Enforce consistant ACL on all replicas’) you enter a correct path where you want to extract files to.
    • in this path we extract the template PDF we use with already added a nice background
    • this path we also create new PDF’s in which we later delete when we embed them in a Notes document
  • In the DB Settings profile document we also specify which fonts are available we can use in the card profile document. The card profile documents are a more or less the card templates the user can create a PDF from.
    • In the database there is already a card profile document created so you can use that in the demo.
  • Open the database in a browser and ‘F-CardRequest?OpenForm’ in the URL after the database filename.

This is what you will be presented:

card request form

After filling in the requested fields a PDF will be created and presented to you. The result might look like this: (card sample PDF).

I have uploaded the database somewhere and if everything goes you right you should be able to download it here. Please let me know if you have any difficulties opening the location.

So what are possible business solutions?

Solutions I have worked on are:

  • a business cards application
  • a poster / leaflet application where dealers can create personalized marketing material based upon defined corporate standards
  • an application to print out certificates after a workshop
  • ‘new baby born’ cards

Well basically let your creative imagination run free :-)

The nice part of Lotus Notes is that you can distribute the (Notes) documents containing the PDF or add an ordering form to it.

The downpart is that if I understood it correctly activePDF uses a ‘bottom up’ approach so it locates a x-y location from the left bottom of the PDF and writes the information to it. It does not count if the content of this information oversizes the bottom of the PDF file. So it will just keep on writing one one single PDF file.

Leave a Comment

A sortable Bob Obringer view

You know what they say about customers: If you give them one finger, they’ll take your hand.

After implementing Bob Obringer’s approach to add page navigation to a view I get the request to make the columns sortable.

Normally I offer customers sortable columns as clickable headers in a table, like described here. But this approach makes the documents presented in the table part of the sorting. So if your table displays 30 documents based upon a server setting, only these 30 presented documents are part of the sorting process.

If you implement this approach in Bob’s solution which is based on showing only a subset of documents at a time the function will also only sort the documents presented at that time.

When looking at the parameter Notes adds when clicking a sortable Notes viewcolumn it will be

  • &ResortAscending=
  • &ResortDescending=

followed by the number of the column you clicked on.

Don’t ask why but this parameter seems to be displayed always before the number of documents shown, if you manually change the order of parameters it will present the same result. So:

  • &Count=30&ResortDescending=3 equeals
  • &ResortDescending=3&Count=30

So in order to make a column in Bob’s approach sortable you need to rewrite the follwoing sections in the JS part:

function buildLink(pageNum, text) {
…. 
linkHTML = linkHTML + “onclick=document.location.href=’” + viewAlias + “?OpenView&Start=” + startLinkDoc + “&Count=” + docsPerPage + “‘>” + text + “</td>”;

}

into:

function buildLink(pageNum, text) {

linkHTML = linkHTML + “onclick=document.location.href=’” + viewAlias + “?OpenView” + sortQuery + “&Start=” + startLinkDoc + “&Count=” + docsPerPage + “‘>” + text + “</td>”;

}

and

function getPage(event, field) {
…  
document.location.href = dbPath + viewAlias + “?OpenView&start=” + (((newPage – 1) * docsPerPage) + 1) + “&count=” + docsPerPage

}

into:

function getPage(event, field) {

document.location.href = dbPath + viewAlias + “?OpenView” + sortQuery + “&start=” + (((newPage – 1) * docsPerPage) + 1) + “&count=” + docsPerPage

}

So what is in the sortQuery variable?

In the HTMLHead Content section I define:

varColumnAsc:=@Left(@Right(Query_String_Decoded;”&ResortAscending=”);2);
varColumnAsc:=@If(@Right(varColumnAsc;1)=”&”;@Left(varColumnAsc;1);varColumnAsc);

varColumnDesc:=@Left(@Right(Query_String_Decoded;”&ResortDescending=”);2);
varColumnDesc:=@If(@Right(varColumnDesc;1)=”&”;@Left(varColumnDesc;1);varColumnDesc);

sortQuery:=
@If(@Contains(Query_String_Decoded;”Ascending”);”&ResortAscending=” + varColumnAsc;
 @If(@Contains(Query_String_Decoded;”Descending”);”&ResortDescending=” + varColumnDesc;”"));

I also define in the HTMLHead Content:

“<script language=’javascript’>” + @NewLine +
 ”var sortQuery = ‘” + sortQuery + “‘” + @NewLine +
“</script>”

The code assumes you have less than 100 columns in the view. If you have less than 10 columns for example 9:

@Left(@Right(Query_String_Decoded;”&ResortAscending=”);2);

results in ‘9&’, ’&’ is the beginning of the next parameter ‘&Count=’.

Therefor I correct this with:

@If(@Right(varColumnAsc;1)=”&”;@Left(varColumnAsc;1);varColumnAsc);

so the ‘&’ gets cut.

sortable column

Comments (2)

Scroll function on your page

Here is a simply function I implemented a long long time ago.

Example scroll on form

What it does is basically places the content of a form in a <div> section and places another <div> section besides it. The second section contains two arrows, one for scrolling up, one for scrolling down. When moving over the button, based upon the location of your first section (‘contentLayer’) the div scrolls up or down.

End of scroll

What do you need to implement?

Here is what is placed on my form:

scroll form

And in the JSHeader write:

function verScroll(dir, spd, loop) {
 loop = true;
 direction = “up”;
 speed = 10;
 scrolltimer = null;
 if (document.layers) { var page = eval(document.contentLayer); }
 else {
  if (document.getElementById) { var page= eval(“document.getElementById(‘contentLayer’).style”);  }
 else {
  if (document.all) { var page = eval(document.all.contentLayer.style); }
    }
}

direction = dir;
speed = parseInt(spd);
var y_pos = parseInt(page.top);

if (loop == true) {
 if (direction == “dn”) { page.top = (y_pos – (speed)); }
 else {
  if (direction == “up” && y_pos < 10) { page.top = (y_pos + (speed)); }
  else {
   if (direction == “top”) { page.top = 10;  }
     }
 }
 scrolltimer = setTimeout(“verScroll(direction,speed)”, 1);
   }
}

function stopScroll() {
 loop = false;
 clearTimeout(scrolltimer);
}

That’s all! Please let me know if you experience any difficulties.

Ps. The nice icons can be found here.

Comments (2)

Re: Collapse a categorized embedded View by default

I have received some questions how to implement the functionality to collapse an embedded categorized view by default.

I think it would be most easy to add some screendumps, so ‘happy typing’ wished!

globals declared

Figure 1. Globals declared

Postopen form

Figure 2. Postopen event on Form with embedded View

Action button script

Figure 3. Code under Actionbutton

Collapse function

Figure 4. Collapse function

Comments (2)

Print all attachments from documents

I received a request from a customer to be able to print out documents including all the attached files. A little search led me to the posting of Andrew Jones on OpenNTF which enables to print attachments with OLE Automation or a WindowsAPI.

In the posting it is assumed that attachments lay in a Rich Text field, in my case all the documents are being created from a web browser so Notes store the attachments in separate $File fields.

I was able to reuse most of the code, I only had to rewrite the follwoing sections:

 Dim rtitem As notesrichtextitem
 
 If doc Is Nothing Then Exit Sub
 If doc.HasItem (“Body”) = False Then Exit Sub
 Set rtitem = doc.GetFirstItem( “Body” )
 If ( rtitem.Type = RICHTEXT ) = False Then Exit Sub
 If Isempty(rtitem.EmbeddedObjects) Then Exit Sub
 
 Forall o In rtitem.EmbeddedObjects ‘ loops through all attachments
  If ( o.Type = EMBED_ATTACHMENT ) Then
   Call PrintAttachment (o)
  End If
 End Forall

 into:

 If doc.HasEmbedded Then
  Forall o In Doc.Items   
   ’1048 means ATTACHMENT
   If o.Type = 1084 Then
    Call PrintAttachment (o)
   End If   
  End Forall
 End If

Note: the EmbeddedObjects property of the document would generate a list of embedded objects which you have to filter (links versus attachments)

If doc.HasEmbedded Then
 Forall o In doc.EmbeddedObjects
  … filter …
 End Forall
End If

In the PrintAttachment function I changed

fname = GetTmpDir + o.Source
Call o.ExtractFile ( fname )

into:

Dim object As NotesEmbeddedObject
fname = GetTmpDir + o.Values(0) 
Set object = o.Parent.GetAttachment(o.Values(0)) 
Call object.ExtractFile(fname )

Since Notes has no doc.Print method I had to rewrite the code in the Agent that uses the ScriptLibrary from:

While Not(doc Is Nothing)
Call PrintAllAttachments(doc)
Set doc = collection.GetNextDocument(doc)
Wend

into:

 While Not(doc Is Nothing)  
  ’to print a document it has to be presented in the UI
  Set uidoc = workspace.EditDocument(False, doc)
  Call uidoc.Print
  Call uidoc.Close  
  Call PrintAllAttachments(doc)
  Set doc = collection.GetNextDocument(doc)
 Wend

This opens the standard Print dialog for each document. A bit user-unfriendly. If you have suggestions to print documents on the background I am happy to receive them.

Comments (10)