Example #1
0
	protected void Page_Load(object sender, EventArgs e)
	{
		WikiReader reader = PXGraph.CreateInstance<WikiReader>();
		PXWikiSettings settings = new PXWikiSettings(this, reader);
		reader.Filter.Current.PageID = PX.Common.GUID.CreateGuid(this.Request["PageID"]);
		WikiPage article = reader.Pages.SelectWindowed(0, 1);
		reader.Pages.Current = article;
		if (article != null && !string.IsNullOrEmpty(article.Content))
		{
			MemoryStream stream = new MemoryStream();
			PXPdfRenderer renderer = new PXPdfRenderer(stream, settings.Relative);
			settings.Relative.Renderer = renderer;
			PXWikiParser.Parse(article.Content, settings.Relative);
			string mime = MimeTypes.GetMimeType(".pdf");
			byte[] bytes = new byte[renderer.ResultPDFStream.Length];

			renderer.ResultPDFStream.Position = 0;
			renderer.ResultPDFStream.Read(bytes, 0, bytes.Length);
			Response.AddHeader("cache-control", "no-store, private");
			Response.Clear();
			Response.Cache.SetCacheability(HttpCacheability.Private);
			Response.Cache.SetExpires(DateTime.Now.AddSeconds(2));
			Response.Cache.SetValidUntilExpires(true);
			Response.AddHeader("Content-Type", mime);
			Response.AddHeader("Content-Length", renderer.ResultPDFStream.Length.ToString());
			Response.BinaryWrite(bytes);
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		string exportType = Request["type"];
		WikiReader reader = PXGraph.CreateInstance<WikiReader>();
		PXWikiSettings settings = new PXWikiSettings(this, reader);
		this.SetReaderFilter(reader);
		WikiPage article = reader.Pages.SelectWindowed(0, 1);
		reader.Pages.Current = article;
		PXRenderer renderer = this.CreateRenderer(exportType, settings.Absolute);
		if (article != null && !string.IsNullOrEmpty(article.Content) && renderer != null)
		{
			var ctx = new PXDBContext(settings.Absolute);

			ctx.Renderer = renderer;
			ctx.WikiID = article.WikiID;
			string result = PXWikiParser.Parse(article.Content, ctx);
			string mime = MimeTypes.GetMimeType("." + exportType);
			Response.AddHeader("cache-control", "no-store, private");
			Response.Clear();
			Response.Cache.SetCacheability(HttpCacheability.Private);
			Response.Cache.SetExpires(DateTime.Now.AddSeconds(2));
			Response.Cache.SetValidUntilExpires(true);
			Response.AddHeader("Content-Type", mime);
			Response.AddHeader("Content-Encoding", "ansi");
			this.AdditionalResponseParams(renderer, article);
			Response.Write(result);
		}
	}