Thanks for your patience.
We have further investigated the issue reported earlier and it does not seem to be a bug in our API. Even the issue appears to be out of the scope of Aspose.Pdf and relates more to web-technologies(AJAX) itself, but we have deeply analyzed the problem. Using of HttpResponse appeared in API before AJAX , without AJAX in mind and writes to response some headers and content itself.
The idea of AJAX is in essence exchange with server without the reload of whole page. In such case request/response go throw additional layers on server and client (JS) and often are wrapped into some additional HTML/XML code. Direct usage of Response object in such cases can easily violate that wrapping, because inside Save(…) method some additional content/headers are written into Response object. That’s why usage of saving to Response in that context(AJAX) leads to problems.
We are not entirely certain if its a desirable behavior of the handler of button, but for illustrative purposes and to ensure that there is no problems in Aspose.Pdf itself, we have made little bit changes to code against Button1_click handler in order to avoid saving into Response inside Aspose.Pdf:
protected void Button1_Click(object sender, EventArgs e)<o:p></o:p>
string html = "Hello
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
pdf.IsTruetypeFontMapCached = false;
Aspose.Pdf.Generator.Section section =
Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(section, html);
text2.IsHtmlTagSupported = true;
simplistic way to ensure that file created and closed -
used in illustrative purposes and
production it should be replaced with more robust code
Fixed sample just saves created PDF-document on server in application's folder and redirects browser to that file to show it in same browser window (according to your requirements as per our understanding). We can see that it works fine : after click on button [Button], created PDF file is shown in same browser window.
Exact implementation of AJAX approach in such case is out of scope of Aspose.Pdf - and requires understanding and experience of working with AJAX itself.
You may take content from that result file, add some headers to it(If some additional things needed) and send to browser (to implement AJAX-packing of content).
To review issue :
- Please find attached corrected project,unzip it, put Aspose.Pdf dll of checked version into Bin folder, open project in VS2010 and run debugging. You'll see browser window with something shown on start screenshot (Screen_start.png).
- Then click on Button1. After 3-4 seconds you'll see PDF document with text "Hello World" in same browser's window (please see screen_pdf_after+click.png).
Please try using the latest release of Aspose.Pdf for .NET 9.8.0 and in case of any further query, please feel free to contact.