PDFmyURL.NET Created by Ta0 Software Developed in Visual C# 2013 ---------------------------------------------------------------- Description: This is a managed .NET wrapper for the PDFmyURL PHP API available at http://pdfmyurl.com. It allows C# and VB.NET developers to easily add HTML to PDF conversion functionality in Windows and web applications. Simply add PDFmyURL.NET.dll to your project and import the PDFmyURLdotNET namespace to start using the API. This assembly is fully object oriented and conforms to the Microsoft standards for .NET framework components. ---------------------------------------------------------------- Basic Usage (C#): PDFmyURL pdf = new PDFmyURL("yourlicensekey"); pdf.ConvertURL("http://www.example.com", Application.StartupPath + @"\example.pdf"); ---------------------------------------------------------------- Basic Usage (VB.NET): Dim pdf As New PDFmyURL("yourlicensekey") pdf.ConvertURL("http://www.example.com", Application.StartupPath & "\example.pdf") ---------------------------------------------------------------- Asynchronous Usage (C#): private PDFmyURL pdf; pdf = new PDFmyURL("yourlicensekey"); pdf.DownloadCompleted += pdf_DownloadCompleted; pdf.WebException += pdf_WebException; pdf.ConvertURL("http://www.example.com", Application.StartupPath + @"\example.pdf", true); private void pdf_DownloadCompleted(object sender, DownloadCompletedEventArgs e) { MessageBox.Show("Download completed successfully - Size: " + e.Data.Length.ToString() + " bytes"); } private void pdf_WebException(object sender, WebExceptionEventArgs e) { MessageBox.Show("Download failed - " + e.StatusCode.ToString() + ": " + PDFmyURL.StatusCodeDescription(e.StatusCode)); } ---------------------------------------------------------------- Asynchronous Usage (VB.NET): Private pdf As PDFmyURL pdf = New PDFmyURL("yourlicensekey") AddHandler pdf.DownloadCompleted, AddressOf pdf_DownloadCompleted AddHandler pdf.WebException, AddressOf pdf_WebException pdf.ConvertURL("http://www.example.com", Application.StartupPath & "\example.pdf", True) Private Sub pdf_DownloadCompleted(sender As Object, e As DownloadCompletedEventArgs) MessageBox.Show("Download completed successfully - Size: " & e.Data.Length.ToString() & " bytes") End Sub Private Sub pdf_WebException(sender As Object, e As WebExceptionEventArgs) MessageBox.Show("Download failed - " & e.StatusCode.ToString() & ": " & PDFmyURL.StatusCodeDescription(e.StatusCode)) End Sub ---------------------------------------------------------------- Functions: ConvertHTML(html, fileName = "", async = false) Converts the specified HTML string into a PDF document and optionally saves it to a file on your computer. html - String value containing valid HTML data to be converted. fileName - Optional string value indicating the local file name where the PDF document will be saved. async - Optional boolean value indicating whether the file will be downloaded asynchronously. ConvertURL(url, fileName = "", async = false) Converts the specified URL into a PDF document and optionally saves it to a file on your computer. url - The URL containing the HTML file to be converted. fileName - Optional string value indicating the local file name where the PDF document will be saved. async - Optional boolean value indicating whether the file will be downloaded asynchronously. ---------------------------------------------------------------- Events: DownloadCompleted(sender, e) Occurs when the download has completed successfully. sender - Contains the object that raised this event. e - DownloadCompletedEventArgs object containing event-specific arguments. The DownloadCompletedEventArgs object contains the downloaded data stored in a byte array. WebException(sender, e) Occurs when the download is interrupted and a web exception is raised. sender - Contains the object that raised this event. e - WebExceptionEventArgs object containing event-specific arguments. The WebExceptionEventArgs object contains the status code returned by the server, and the WebException raised. In addition, all properties listed below also contain their own individual PropertyChanged events. For example when the Margins property changes, the corresponding MarginsChanged event is raised. ---------------------------------------------------------------- Properties: Background - Gets or sets the background options of the resulting PDF document. CookieJar - The contents of a cookie jar file, that we should use to access your URL. Credentials - Gets or sets the network credentials used for basic HTTP authentication. CSSMediaType - Gets or sets the CSS media type of the resulting PDF document. Use the print friendly layout if your web page has one. DimensionUnit - Gets or sets the measurement unit, which is applied to the margins as well as the width and height. EncryptionLevel - Gets or sets the encryption level of the resulting PDF document. EndPoint - Gets or sets the remote end point used to connect to the API server. Footer - Gets or sets the HTML footer of the resulting PDF document. FormFields - Gets the list of form fields that you want us to post to the login page, so we can login to your site. FormURL - Gets or sets the URL of a login page that you want us to use and post the form fields to. Grayscale - Determines if the resulting PDF document will be converted to grayscale. Header - Gets or sets the HTML header of the resulting PDF document. HiddenContent - Gets the list of Element objects that will be hidden during conversion. JavaScriptDelay - Gets or sets the time, in milliseconds, that JavaScript waits to complete. LicenseKey - Gets or sets the license key associated with your developer account. Margins - Gets or sets the page margins of the resulting PDF document. NetscapeCookieJar - The contents of a cookie jar file in the old Netscape format (still used by cURL and wget), that we should use to access your URL. NoBackground - Determines if the background image will be disabled in the resulting PDF document. NoExternalLinks - Determines if links to external sites will be disabled in the resulting PDF document. NoImages - Determines if images will be disabled in the resulting PDF document. NoInternalLinks - Determines if links within the domain will be disabled in the resulting PDF document. NoJavaScript - Determines if JavaScript will be disabled in the resulting PDF document. OwnerPassword - Gets or sets the password required to adjust the rights management settings of the PDF document. PageDimensions - Gets or sets the page dimensions of the resulting PDF document. PageOffset - Number that will be added to the page number, by default this is 0 so page numbers will start at 1. PageOrientation - Gets or sets the page orientation of the resulting PDF document. PageSize - Gets or sets the page size, such as A4, Letter etc. See http://pdfmyurl.com/page-sizes-and-page-breaking for details. Permissions - Gets or sets the permissions of the resulting PDF document. SessionID - Gets or sets the contents of a JSESSIONID cookie, that we should use to access your URL. Title - Gets or sets the title of the PDF, instead of the value of the title tag from the web page. UserPassword - Gets or sets the password required to open the PDF document. VisibleContent - Gets the list of Element objects that will be visible during conversion. Watermark - Gets or sets the watermark options of the resulting PDF document. ZoomFactor - Use this zoom factor during conversion, this may alter/improve font kerning e.g. 1.03 for a 3% zoom. ---------------------------------------------------------------- Exceptions: In some cases, such as invalid HTML or URL input, an exception error will be raised. The developer can handle these errors by wrapping functions inside a try/catch statement to check the details of the error. try { pdf.ConvertURL("http://www.example.com", string.Empty); } catch (Exception ex) { MessageBox.Show("Error: Unable to convert URL - " + ex.Message); }