PDF conversion on the Web

To preview the PDF Converter's web functionality follow these simple steps:

  • Copy SWING PDF Converter database (PDFConverter.nsf) to your server.

  • Open Domino Administrator, navigate to PDFConverter.nsf and sign the application with Active Server's ID.

  • Open PDFConverter.nsf in Lotus Notes and enter your serial key.

  • In Application properties (5th tab) set "When opened in browser: Open designated Frameset" -> "Frameset: MainWeb".

  • Open the application in your web browser and click the Create PDF button.

  • PDF Converter will now extract all required files. Please restart your Domino server to complete installation.

  • You should be able to use PDF Converter on the web now

How it works

SWING PDF Converter web example UI form is stored in Swing PDF Converter database, in "FaxWeb" form. Back end code is in the "FaxWeb" agent.

Here's a brief explanation how web conversion works: Form "FaxWeb" is a Notes form that is optimized for web display.

When user clicks on the button "Create PDF", simple formula code that saves the document and closes window is executed: @Command([FileSave]); @Command([FileCloseWindow])

There is an event trigger defined which executes when the document is being saved ("WebQuerySave" event): @Command([ToolsRunMacro];"FaxWeb") This event executes LotusScript agent "FaxWeb".

Agent "FaxWeb" initializes Swing PDF Converter, converts the document and constructs output HTML from PDF document path.

This HTML code is printed to the clients browser.

Sample code

Here's the "FaxWeb" agent source code:

Option Public
Option Declare
Use "SwPDFMain"
Sub Initialize
    Dim s As New NotesSession, docContext As NotesDocument
    Dim swPDF As New SwPDFCreator, swPDFDoc As SwPDFDocument, pdfErr As SwPDFError
    Dim rtitem As NotesRichTextItem, PDFFileName As String, HrefUrl As String
	
    PDFFileName = "test.pdf"
	
    Set docContext = s.DocumentContext
    If Not docContext Is Nothing Then
	If swPDF.Init("") Then
            ' Set alternate form and default file name used for PDF conversion
	    swPDF.PDFSettings.AlternateForm = "Fax"
	    swPDF.PDFSettings.IncludeWebAttachments = True
			
	    swPDF.FileName = PDFFileName
	    ' enable font embedding for non ascii characters
	    swPDF.PDFSettings.EnableFontEmbedding = True
	    'enable console logging
	    swPDF.PDFSettings.ConsoleLogging = True
	    ' Convert doc to PDF
	    Set swPDFDoc = swPDF.ProcessDocument(docContext)
			
	    If Not swPDFDoc Is Nothing Then
		' Finally, get generated PDF as RTItem and store it in document for further reference
		Set rtitem = swPDFDoc.GetAsRTItem()
	    	Call rtitem.CopyItemToDocument(docContext, "")
		Call docContext.Save(True, True)
				
		Call swPDFDoc.Recycle()
				
		' Construst a URL and display generated PDF in a web browser
		HrefUrl = "0/" & Cstr(docContext.UniversalID) & "/$File/" & PDFFileName
		Print |You can download a copy of PDF file from here
 | & Chr$(13) & ||
	    Else
		' There was an error in PDF conversion
		Set pdfErr = swPDF.GetError()
		Print "ERROR: " & pdfErr.Message & ""
	    End If
        Else
	    ' There was an error in PDF initialization
	    Set pdfErr = swPDF.GetError()
	    Print "ERROR: " & pdfErr.Message & ""
        End If
    End If
End Sub

About "Pass-Thru HTML"

SWING PDF Converter does not support "Pass-Thru HTML" content on Lotus forms.

Rendering those forms to PDF will result in PDF document showing the plan HTML/JavaScript source code.

To work around this issue you may design an alternate Notes form that shows the same content but without using HTML.

More on alternate forms:

Last updated