private void CreateTempFile() { // TODO: (mc) This is a very weak mechanism to determine if html is partial. Find a better way! bool isPartial = !_html.Trim().StartsWith("<!DOCTYPE", StringComparison.OrdinalIgnoreCase); if (isPartial) { _html = WrapPartialHtml(_html); } string tempPath = Path.GetTempPath(); _tempFilePath = Path.Combine(tempPath, "pdfgen-" + Path.GetRandomFileName() + ".html"); File.WriteAllBytes(_tempFilePath, Encoding.UTF8.GetBytes(_html)); _kind = PdfContentKind.Url; }
public void Teardown() { if (_tempFilePath != null && File.Exists(_tempFilePath)) { try { File.Delete(_tempFilePath); } catch { } } _kind = PdfContentKind.Html; _html = _originalHtml; _tempFilePath = null; _processed = false; }