IHtmlTrLauncher.CHICreateHtml, méthode (Microsoft.HtmlTrans)

Windows SharePoint Services 3
Starts the process of converting a document to HTML format for viewing in the browser by a user who does not have the appropriate client application or viewer installed.

Espace de noms : Microsoft.HtmlTrans
Assembly : Microsoft.HtmlTrans.Interface (dans microsoft.htmltrans.interface.dll)

CreateHtmlInfo CHICreateHtml (
	string strLauncherUri,
	byte[] rgbFile,
	BrowserType bt,
	string strReqFile,
	string strTaskName,
	int timeout,
	bool fReturnFileBits
)

Paramètres

strLauncherUri

Specifies the server hosting the launcher application by using the value returned by the StrGetLauncher method of the IHtmlTrLoadBalancer interface.

rgbFile

The binary contents of the source file.

bt

Specifies the target browser type by using a constant from the BrowserType enumeration.

strReqFile

The URL of the document to convert.

strTaskName

The document conversion task name, which the load balancer uses to keep track of the request.

timeout

The time in seconds before the document conversion times out.

fReturnFileBits

Specifies whether to return the binary contents of the converted file (that is, the HTML output) in the rgbMainFile and rgrgbThicketFiles properties of the instance of the CreateHtmlInfo class returned by the CHICreateHtml method.

Valeur retournée

Microsoft.HtmlTrans.CreateHtmlInfo The HTML output of the conversion process is returned in an instance of the CreateHtmlInfo class, which also contains information about any conversion error that occurred and about additional supporting files that may be part of the output.

The CHICreateHtml method starts the process of converting a document to HTML format and returns the HTML output to Microsoft Windows SharePoint Services to forward to the user.

The following code example shows a simple version of handler page code that calls implementations of the IHtmlTrLoadBalancer and IHtmlTrLauncher interfaces, converts a document by using the CHICreateHtml method, and writes the output of the conversion process to a file.

using Microsoft.HtmlTrans;
 
void DisplayHtml(System.Web.HttpResponse response, string strLoadBalancerUri,
  string strDocument, byte[] rgbData)
{
  //generate a task name based off of the document name
  string strTask = strDocument;
 
  //create the load balancer object
  IHtmlTrLoadBalancer htmlTrLoadBalancer = (IHtmlTrLoadBalancer) 
     System.Activator.GetObject( typeof(IHtmlTrLoadBalancer), 
     strLoadBalancerUri);
 
  //get the uri for the launcher object
  string strLauncherUri = htmlTrLoadBalancer.StrGetLauncher(strTask);
 
  //create the launcher object at the uri specified by the load balancer
  IHtmlTrLauncher htmlTrLauncher = (IHtmlTrLauncher)
     System.Activator.GetObject(typeof(IHtmlTrLauncher), 
     strLauncherUri);
 
  //call the launcher to create the html
  CreateHtmlInfo chi = htmlTrLauncher.CHICreateHtml(strLauncherUri, 
    rgbData, BrowserType.BT_IE4, strDocument, strTask, 90 /*timeout*/, true);
 
  //ensure that the load balancer knows that the task has completed
  htmlTrLoadBalancer.LauncherTaskCompleted(strLauncherUri, strTask);
  
  //check for errors and output the results
  if(chi.ce == CreationErrorType.CE_NONE && chi.fHasMainFile)
     response.BinaryWrite(chi.rgbMainFile);
}


Afficher: