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;
		}
Ejemplo n.º 2
0
        public void Teardown()
        {
            if (_tempFilePath != null && File.Exists(_tempFilePath))
            {
                try
                {
                    File.Delete(_tempFilePath);
                }
                catch { }
            }

            _kind         = PdfContentKind.Html;
            _html         = _originalHtml;
            _tempFilePath = null;
            _processed    = false;
        }
Ejemplo n.º 3
0
        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;
		}