Converter.ConvertHTML
Contents
[
Hide
]Converter.ConvertHTML method
ConvertHTML(HtmlSource, SaveOptions, ICreateStreamProvider)
Converts source to the streams output creates, one per part.
public static ConversionResult ConvertHTML(HtmlSource source, SaveOptions options, ICreateStreamProvider output)
| Parameter | Type | Description |
|---|---|---|
| source | HtmlSource | The HTML source. |
| options | SaveOptions | PDF or image options. |
| output | ICreateStreamProvider | The stream provider. |
Return Value
ConversionResult: The conversion result.
See Also
- class Converter
- namespace Aspose.Css
- assembly Aspose.CSS
ConvertHTML(HtmlSource, SaveOptions, Stream)
Converts source to output, left open.
public static ConversionResult ConvertHTML(HtmlSource source, SaveOptions options, Stream output)
| Parameter | Type | Description |
|---|---|---|
| source | HtmlSource | The HTML source. |
| options | SaveOptions | PDF or image options. |
| output | Stream | A writable stream. |
Return Value
ConversionResult: The conversion result.
See Also
- class Converter
- namespace Aspose.Css
- assembly Aspose.CSS
ConvertHTML(HtmlSource, SaveOptions, string)
Converts source to the file outputPath.
public static ConversionResult ConvertHTML(HtmlSource source, SaveOptions options, string outputPath)
| Parameter | Type | Description |
|---|---|---|
| source | HtmlSource | The HTML source. |
| options | SaveOptions | PDF or image options. |
| outputPath | string | The output file; replaced only when the conversion succeeds. |
Return Value
ConversionResult: The conversion result.
See Also
- class Converter
- namespace Aspose.Css
- assembly Aspose.CSS
ConvertHTML(string, SaveOptions, string)
Converts the HTML file inputPath to the file outputPath.
public static ConversionResult ConvertHTML(string inputPath, SaveOptions options, string outputPath)
| Parameter | Type | Description |
|---|---|---|
| inputPath | string | The input file; its directory is an allowed file root. |
| options | SaveOptions | PDF or image options. |
| outputPath | string | The output file. |
Return Value
ConversionResult: The conversion result.
See Also
- class Converter
- namespace Aspose.Css
- assembly Aspose.CSS
ConvertHTML(Stream, string, SaveOptions, Stream)
Converts the HTML bytes of input to output; both stay open.
public static ConversionResult ConvertHTML(Stream input, string baseUri, SaveOptions options, Stream output)
| Parameter | Type | Description |
|---|---|---|
| input | Stream | The input, read from its current position. |
| baseUri | string | An absolute http(s) or file URI, or about:blank. |
| options | SaveOptions | PDF or image options. |
| output | Stream | A writable stream. |
Return Value
ConversionResult: The conversion result.
See Also
- class Converter
- namespace Aspose.Css
- assembly Aspose.CSS
ConvertHTML(Stream, string, SaveOptions, string)
Converts the HTML bytes of input to the file outputPath.
public static ConversionResult ConvertHTML(Stream input, string baseUri, SaveOptions options, string outputPath)
| Parameter | Type | Description |
|---|---|---|
| input | Stream | The input, read from its current position and left open. |
| baseUri | string | An absolute http(s) or file URI, or about:blank. |
| options | SaveOptions | PDF or image options. |
| outputPath | string | The output file. |
Return Value
ConversionResult: The conversion result.
See Also
- class Converter
- namespace Aspose.Css
- assembly Aspose.CSS
ConvertHTML(string, string, SaveOptions, Stream)
Converts the markup html to output, left open.
public static ConversionResult ConvertHTML(string html, string baseUri, SaveOptions options, Stream output)
| Parameter | Type | Description |
|---|---|---|
| html | string | The markup. |
| baseUri | string | An absolute http(s) or file URI, or about:blank. |
| options | SaveOptions | PDF or image options. |
| output | Stream | A writable stream. |
Return Value
ConversionResult: The conversion result.
See Also
- class Converter
- namespace Aspose.Css
- assembly Aspose.CSS
ConvertHTML(string, string, SaveOptions, string)
Converts the markup html to the file outputPath.
public static ConversionResult ConvertHTML(string html, string baseUri, SaveOptions options, string outputPath)
| Parameter | Type | Description |
|---|---|---|
| html | string | The markup. |
| baseUri | string | An absolute http(s) or file URI, or about:blank. |
| options | SaveOptions | PDF or image options. |
| outputPath | string | The output file. |
Return Value
ConversionResult: The conversion result.
See Also
- class Converter
- namespace Aspose.Css
- assembly Aspose.CSS
Examples
Convert a local invoice with the familiar Aspose call.
var result = Converter.ConvertHTML("invoice.html", new PdfSaveOptions(), "invoice.pdf");
Console.WriteLine(result.PageCount);
Convert stream-to-stream without accidental ownership transfer.
using var input = File.OpenRead("report.html");
using var output = File.Create("report.pdf");
Converter.ConvertHTML(input, "https://assets.example/", new PdfSaveOptions(), output);
Produce one print-resolution PNG per page with explicit stream completion.
var images = new ImageSaveOptions {
Mode = ImageMode.PrintPages, HorizontalResolution = 300, VerticalResolution = 300,
};
images.Css.MediaType = MediaType.Print;
Converter.ConvertHTML(HtmlSource.FromFile("report.html"), images, new PageFiles());
private sealed class PageFiles : ICreateStreamProvider
{
public Stream GetStream(OutputPart part) => File.Create($"page-{part.Index + 1}.png");
public void Complete(OutputPart part, Stream stream, OutputOutcome outcome)
{
stream.Dispose();
if (outcome != OutputOutcome.Completed) File.Delete($"page-{part.Index + 1}.png");
}
}