DominoPDF from Notes client sample

DominoPDF can be installed on a Domino server but still called from a Notes client.

A sample database which can be downloaded demonstrates this process. Provided below is how it works in detail.

Requirements

- DominoPDF software installed on the Domino server

- The Domino HTTP task running on the Domino server

- The aforementioned sample database installed on the Domino server in the \Data directory.

- Sign the agents in the sample database with a Notes ID authorised to execute agents etc.

Usage

- Open the sample database located on the server from a Notes client (not a browser)

- You will be presented with a view containing "Contact" documents. Open any document and click the "Convert PDF" action located on the action bar.

- For the sake of the demonstration you will be prompted for the HTTP domain that is valid on your server.

It defaults to http://127.0.0.1/ but you should change this as appropriate for your Domino HTTP server. For example; http://www.dominopdf.com/ ensuring the trailing backslash is included.

- An agent will run which executes another agent server side to convert the document to a PDF.

- Once the PDF is created it is attached to a document which is presented to the Notes client. The document has "launch first attachment" enabled so the attached PDF is automatically opened and presented.

How it works

- The "Convert PDF" action button on the Contact document runs 3 agents;

@PostedCommand([ToolsRunMacro]; "RunOnServer1");
@PostedCommand([ToolsRunMacro]; "RunOnServer2");
@PostedCommand([ToolsRunMacro]; "PDFRunOnServer")

The 1st agent "RunOnServer1" simply tries to determine the HTTP domain automatically. In production you probably won't need this step as you'll know your domain.

The 2nd agent "RunOnServer2" prompts the user to confirm or update the HTTP domain. In production you probably won't need this step as you'll know your domain.

The 3rd agent "PDFRunOnServer" creates a NotesAgent variable in order to run a 4th agent named "DominoPDFAgent";

Set agent = db.GetAgent("DominoPDFAgent")

The 3rd agent then creates a "dummy" document ready to hold the newly created PDF file. The Form used by the document is named "PDFView".

Set oDoc = New NotesDocument(db) oDoc.Form = "PDFView"
Call oDoc.Save(True, False)

The NoteID of the document is stored so that it can be passed to the 4th agent which will run "server-side".

paramid = oDoc.Noteid

The 4th agent is then run from the 3rd agent in order to generate the PDF.

If agent.RunOnServer(paramid) = 0 Then

Once the server-side agent has finished execution is returned and we display the document we created (hopefully with the PDF attached) to the user.

Set oDoc = Nothing Set oDoc = db.GetDocumentById(paramid)
Dim ws As New NotesUIWorkspace
If Not oDoc Is Nothing Then
Call ws.EditDocument(False, oDoc, False, "")
End If

As mentioned above the Form named "PDFView" automatically launched the first attachment. If you don't wish this to happen simply edit the form properties before running the action.

The server-side agent named "DominoPDFAgent" runs as a normal agent and contains the interface to DominoPDF. It simply buils a URL for the Notes document, passes it to DominoPDF for conversion to PDF and then attaches the PDF to the document which is returned to the user.

v = Evaluate(|@Unique|, oDoc)
sFile = s + "\" + v(0) + ".pdf"
sURL = sHost & sDBPath & |/Contacts/| & oDoc.UniversalID & |?OpenDocument|
Call DoPDF(sURL, sFile, "LeftMargin=20;RightMargin=20;TopMargin=20;BottomMargin=20")
Set PDFDoc = oDB.GetDocumentById(NoteId)
If Not PDFDoc Is Nothing Then
'Attach PDF to document...
Set rtItem = New NotesRichTextItem(PDFDoc, "Body")
Call rtItem.embedObject(EMBED_ATTACHMENT,"", sFile)
Call PDFDoc.Save(True, False)
End If
Kill sFile

Conclusion

As you can see the power of Domino and LotusScript together with DominoPDF provides a flexible means of server AND client side PDF creation.

How To Resize Images When Converting To PDF

We have a customer who operates in the insurance industry and needed to convert large dimension images to PDF.

By default DominoPDF would split the large image over a number of pages to ensure the content could be seen, however the customer wanted to resize the image to fit onto a single page.

Their developer kindly provided the LotusScript code they used to achieve this and we reproduce it below.

How to set page / background colour of a PDF?

As DominoPDF converts the HTML representation of a form / document to PDF you have a number of options to meet your requirements.

1. Set the background colour of the Form to the "parchment" colour you desire.

2. Set the background image of the Form to the "parchment" image you desire. Note, that in earlier versions of Domino the "tiling" options were not supported for HTML output so ensure your document appears correct in a browser.

3. Add HTML code to the BODY tag of the form to add your image background. For example; "BACKGROUND=\"parchment.gif\"" (note the escape slashes that @Formula language needs.

What we're trying to achieve is to tell DominoPDF that the HTML used for PDF conversion will have some form of background effect, either colour or an image. DominoPDF will then render this appropriately when output to PDF.

Option 3 is prefered as it gives better control over the output but all should work accordingly.

iNotes to PDF with DominoPDF

Lotus iNotes is a rich Web client for Lotus Domino e-mail, calendar, and collaboration applications.

As iNotes is web based and makes heavy use of frames and JavaScript certain considerations have to be made when using DominoPDF for PDF conversion via an iNotes implementation.

Page 1 of 2

JoomShaper