Call us on
+44 (0) 2077 545 948
Quickly and easily convert Notes to PDF. With only 2 lines of code any Notes / Domino content can be saved as PDF.
Download Now| Loading HTML from a Notes URL with LotusScript and Java |
|
Sometimes it's needed to connect to a Notes URL and download the HTML to disk so DominoPDF can process it locally, manipulate the code, etc. LotusScript has the web retriever method but it doesn't provide all the necessary support for connectivity, authentication, etc. The following code shows a method of calling a Java class from LotusScript to open a URL and retrieve the HTML. 1. Open the script library section in the Notes designer and create a new Java library named GetHTML. 2. Paste the following code into the library and save accordingly. import java.io.*; import java.net.*; import sun.misc.BASE64Encoder; public class GetHTML { public String getHTML(String urlToRead, String username, String password) { URL url; // The URL to read HttpURLConnection conn; // The actual connection to the web page BufferedReader rd; // Used to read results from the web page String line; // An individual line of the web page HTML String result = ""; // A long string containing all the HTML try { url = new URL(urlToRead); conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); String userpass = username + ":" + password; BASE64Encoder encoder = new BASE64Encoder(); String encodedStr = encoder.encode(userpass.getBytes()); String basicAuth = "Basic " + encodedStr; conn.setRequestProperty ("Authorization", basicAuth); rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); while ((line = rd.readLine()) != null) { result += line; } rd.close(); } catch (Exception e) { e.printStackTrace(); } return result; } } 3. Create your LotusScript agent which will handle the URL loading and paste the following code.
4. On execution the variable html will contain the HTML output of the URL 5. If you wish to save the HTML to a local file for processing with DominoPDF, the following code can be used.
6. DominoPDF can be used to convert the local file to PDF as follows.
Comments
(0)
|
| Home |
| Download |
| Case Studies |
| Testimonials |
| Contact Us |