# 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.

![](https://3331713008-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MlCAurE6RSGoCmtmAET%2F-MlFtr_-3bv9x1wsfsrX%2F-MlFuM_D8Xp2KlmRi0J5%2Fimage.png?alt=media\&token=3897feb9-b610-4c5c-9e49-b1d7a80a1ce5)

* 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".

![](https://3331713008-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MlCAurE6RSGoCmtmAET%2F-MlFtr_-3bv9x1wsfsrX%2F-MlFuXQWxJYl8XqrxJX2%2Fimage.png?alt=media\&token=09e2466c-a077-42ab-9d90-58cf91495f7c)

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

![](https://3331713008-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MlCAurE6RSGoCmtmAET%2F-MlFtr_-3bv9x1wsfsrX%2F-MlFudb5DbpLhXEhTIl0%2Fimage.png?alt=media\&token=37c80ed0-06e7-461c-8aae-4021d5cb6f81)

* 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

![](https://3331713008-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MlCAurE6RSGoCmtmAET%2F-MlFtr_-3bv9x1wsfsrX%2F-MlFukW2zfXWW_GTOqvV%2Fimage.png?alt=media\&token=4357afe6-6038-48c3-8de8-a9d9d6d736ea)

## 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: \
&#x20; *@Command(\[FileSave]);*\
&#x20; *@Command(\[FileCloseWindow])*

There is an event trigger defined which executes when the document is being saved ("*WebQuerySave*" event):\
&#x20; *@Command(\[ToolsRunMacro];"FaxWeb")*\
&#x20; 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.&#x20;

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.&#x20;

More on alternate forms:

{% content-ref url="../../getting-started/using-pdf-converter-client-side/how-to-use-alternate-forms" %}
[how-to-use-alternate-forms](https://docs.swingsoftware.com/pdf-converter-for-notes/getting-started/using-pdf-converter-client-side/how-to-use-alternate-forms)
{% endcontent-ref %}

{% content-ref url="../../how-to/how-to-use-alternate-forms" %}
[how-to-use-alternate-forms](https://docs.swingsoftware.com/pdf-converter-for-notes/how-to/how-to-use-alternate-forms)
{% endcontent-ref %}

##
