Problem with .pdf generator in .NET - Dynamically generate .pdf in ASP.NET

Posted by Bhanubysani under ASP.NET on 11/29/2012 | Points: 10 | Views : 2469 | Status : [Member] | Replies : 2
Hi Sheo,

I followed one of your article

I am exporting a grid view to PDF using above code in web part,in web part or user control i am not able to write
public override void VerifyRenderingInServerForm(Control control)



so i used htmlform like this

using (StringWriter sWriter = new StringWriter(strB))
using (HtmlTextWriter htWriter = new HtmlTextWriter(sWriter))
using (HtmlForm frm = new HtmlForm())
frm.Attributes["runat"] = "server";
// GridView1.RenderControl(htWriter);

After exporting to PDF some unwanted headers are adding which are not required above and below of the content.I followed different URLs.some of the codes are working good in webpages.
Because in that pages i am able to write the below method which i can't write in webpart or usercontrol.

Please find this attachment,please help me.This type of headers are adding above and below the code. I think this is top and bottom of the page.i am not sure about that.

//var theForm = document.forms['aspnetForm']; if (!theForm) { theForm = document.aspnetForm; } function
__doPostBack(eventTarget, eventArgument) { if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget; theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit(); } } ////var MSOWebPartPageFormName = 'aspnetForm'; var g_presenceEnabled = true;
var g_wsaEnabled = false; var g_wsaLCID = 1033; var g_wsaSiteTemplateId = 'STS#0'; var
g_wsaListTemplateId = 850; var _fV4UI=true;var _spPageContextInfo = {webServerRelativeUrl: "\u002f",
webLanguage: 1033, currentLanguage: 1033, webUIVersion:4,pageListId:"{12e3d35a-1bde-402c-910af18ab0398d16}",
pageItemId:1,userId:2, alertsEnabled:true, siteServerRelativeUrl: "\u002f",
allowSilverlightPrompt:'True'};////var dlc_fvsi = {"DefaultViews":[],"ViewUrls":[],"WebUrl":"\/"};////function
_spNavigateHierarchy(nodeDiv, dataSourceId, dataPath, url, listInContext, type) {
CoreInvoke('ProcessDefaultNavigateHierarchy', nodeDiv, dataSourceId, dataPath, url, listInContext, type,
document.forms.aspnetForm, "", "\u002fPages\u002fReportTool.aspx"); } ////function WebForm_OnSubmit()
{ UpdateFormDigest('\u002f', 1440000); return true; } //

Please help me getting this.

Thanks in advance.


Bhanu Prakash Bysani


Posted by: Eva2012 on: 11/30/2012 [Member] Starter | Points: 25

See this article may help you:

Bhanubysani, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Arronlee on: 6/23/2013 [Member] Starter | Points: 25

I do think that it is a little complicated to generate .pdf in ASP.NET dynamically using CODE.
Besides, the mistakes of the CODE is very hard to check.
So I suggest you refer to some professional PDF Generator SDKs in .NET.
( )
After all, they are more skilful, don't you think so?
I hope it helps.

Best regards,

Bhanubysani, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response