Export Page Content To PDF Using A ITextSharp (include Buttons And Grids)

Feb 21, 2011

how to export my aspx page (include buttons and Grids) to PDF? Searching the web I found this component, but it works only with normal html If my page has Grids or Buttons, these do not appear in PDF. My current code for export to PDF; This code exports only basic html (no buttons or grids)

string attachment = "attachment; filename=AllPage.pdf";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/pdf";
StringWriter stw = new StringWriter();
HtmlTextWriter htextw = new HtmlTextWriter(stw);
GridView1.AllowPaging = false;
GridView1.DataBind();
GridView1.RenderControl(htextw);
Document document = new Document();
PdfWriter.GetInstance(document, Response.OutputStream);
document.Open();
StringReader str = new StringReader(stw.ToString());
HTMLWorker htmlworker = new HTMLWorker(document);
htmlworker.Parse(str);
document.Close();
Response.Write(document);
Response.End();

View 2 Replies


Similar Messages:

Controls :: Export Repeater Item (Row) On Separate Page In PDF Using ITextSharp

May 7, 2015

I want to convert a repated contents of a repeater (binded from databse )to pdf using iTextSharp so that every repeated contents comes in new pdf page.. two or multiple unique records should come individually in new pdf page.

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Registrations.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();

[Code] .....

View 1 Replies

Controls :: Add New Page With Content To Existing PDF Using ITextSharp And C#

Nov 22, 2015

I have a PDF template(abc.pdf) that defined 1 page with  fields to be annotated.  And I need to create a PDF using the template which will insert additional identical pages with the exact same as template if my input data requires more pages.  When I use the following code (partially) to insert new page the text fields to be annotated are not write on the new page

Rectangle rectangle = reader.GetPageSize(1);
for (int i = 1; i <= Convert.ToInt16(HfPgNumber); i++)
stamper.InsertPage(Convert.ToInt16(HfPgNumber), rectangle);
stamper.Close();
reader.Close();

View 1 Replies

MVC :: Include View Content Page In My Master Page

Feb 21, 2010

I want to include view content page in my master page: My MVC application Left Menu MainPage. The Left Menu and Main page are two contentHolders in the master page. How can I add the Left Menu (View content page) to my Master page?. The Left Menu page is going to be a permanent page. The Content in the main Page is going to change. Left Menu content needs to be the permanent content for all other pages.

I searched in the internet, but I didn't find any solution that solves my problem. Basically I need some permanent menu items in the left page. But, I should not write the code in my master page. I need to add that Menucontent as my contentPage to the master. I have tried that by adding a New content page called "LeftPage.aspx" in View/Home folder.I have referred this page to the master "Left content holder". As the ASP.Net MVC talk to the controller, the left menu is not getting displayed while page loading.If i specify the ControlAction for this left page and specify the URL as //Home/Left ;then the page is getting displayed with only the left page content.

View 4 Replies

Forms Data Controls :: Export Multiple Grids And Dataset To Excel Sheet

Feb 9, 2010

In a page im having multiple data grids with some data tables.How can i export all these to excel sheet without any change in the alignment.

View 6 Replies

How To Include Repeating Content On Every Page Of A Website Such As A Navigation Menu

Aug 10, 2010

What is the best way to include repeating content on every page of a website such as a navigation menu?

View 2 Replies

AJAX :: How To Go About Making A Bigger Piece Of Content Change (without Page Refresh) Using The Same Buttons?

May 12, 2010

I created some buttons and a label inside UpdatePanel. Upon clicking the buttons Label's text changes as configured. Lovely. Now how do I go about making a bigger piece of content change (without page refresh) using the same buttons? (Basically I'm trying to build Ajax tabs)I tried making the button click event change ContentPlaceHolderID value on some Content controls but that doesn't seem to work.

View 3 Replies

Web Forms :: How To Export Displayed Content Of Page To Pdf

Apr 14, 2010

is it possible to export displayed content of asp.net page to pdf.if yes how

View 5 Replies

Export Gridview To Xlsx In Content Page .net 4.0 C#?

Nov 22, 2010

I am using content page, Data is huge so the xls opens very very slow, so I want the gridview to be exported to xlsx.

I have already tried to use content type: application/vnd.openxmlformats- fficedocument.spreadsheetml.sheet

I am using .Net 4.0, C#

The code I am using the following code to export to excel:

Response.Clear();
Response.Buffer = true;
string attachment = null;
attachment = "attachment; filename=ABC.xls";
Response.ClearContent();

[Code].....

View 1 Replies

C# - Get The Export Value Of A Checkbox Using ITextSharp?

Dec 20, 2010

I'm working on dynamically filling in the fields on a pdf document using ITextSharp. I'd like to be able to determine the "export value" of the checkbox is from the codebehind in order to determine what value to send to this checkbox if it should be checked. Most of the documents I've worked with in the past had the same export value for every check box but the one I'm currently working with varies from checkbox to checkbox. I could go through all of the text boxes and make them consistent but it would save a lot of time in the future if I could just determine what the export value of these checkboxes are at runtime and set them accordingly.I tried to implement the solution below in C# and ended up with the following code:

public string GetCheckBoxExportValue(AcroFields pdfDocument, string checkBoxFieldName)
{
AcroFields.Item item = pdfDocument.GetFieldItem(checkBoxFieldName);

[code]...

View 1 Replies

VS 2008 How To Export Gridview To Pdf Using ITextSharp

Jan 26, 2011

I'm trying to export my gridview to pdf but the html parsing of the iTextSharp control seems to be failing. I have to create an HtmlForm like below and add the gridview to it because the code is in a custom control, so I cant pass the gridview directly. I get an error saying "gridview must be in a form tag with runat=server"

If I don't insert the test header like i do below, I get an error saying "document has no pages"

At the moment the pdf is generated but it only has the text "testing".

The htmlform html doesn't get parsed i think. Here is a small portion of what the newHtml variable below contains when I create it.

Code:

[code]....

View 3 Replies

Export Gridview To PDF Document Using ItextSharp DLL

Jan 28, 2013

I'm using ItextSharp dll to export my gridview to a pdf document. When it executes htmlworker.Parse(streamreader) I get an error:

Could not find file 'C:Program FilesCommon FilesMicrosoft SharedDevServer10.0 '. I never specified this path. How I can resolve this error?

View 2 Replies

Controls :: Export PDF - Use External CSS With ITextSharp

Jan 16, 2013

When converting an aspx page to pdf using itextsharp external css is not working.I dont want to create  tables for exporting to PDf as its a complex design .I am able to generate the pdf but css is not getting applied. I am  using the latest relese of itextsharp.dll.

Protected Sub btnExport_Click(ByVal sender As Object, ByVal e As EventArgs)Response.ContentType = "application/pdf"Response.AddHeader("content-disposition", "attachment;filename=TestPage.pdf")Response.Cache.SetCacheability(HttpCacheability.NoCache)Dim sw As New StringWriter()Dim hw As New HtmlTextWriter(sw)Me.Page.RenderControl(hw)Dim sr As New StringReader(sw.ToString())Dim pdfDoc As New Document(PageSize.A4, 10.0F, 10.0F, 100.0F, 0.0F)Dim htmlparser As New HTMLWorker(pdfDoc)PdfWriter.GetInstance(pdfDoc, Response.OutputStream)pdfDoc.Open()htmlparser.Parse(sr)pdfDoc.Close()Response.Write(pdfDoc)Response.[End]()End Sub

I am using above code but getting error:

  htmlparser.Parse(sr)    

is not defining  proper path for the images:

Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:ImagesLayoutan-Logo.png'.

View 1 Replies

Controls :: Export Crystal Report To PDF And Show It In Content Page

Jan 27, 2014

I have an asp.net ERP website with Master - Child (Content) Page architecture, where I have two buttons to view a report. One is to view report in crsyral report viewer and second is to view report as pdf.

I am exporting the report to pdf via report.ExportToHttpResponse(...). I am able to export it and it opens in a new tab of browser, thats fine! But opening report in some new tab looks like this tab is not a part of my website, you know it just show pdf, no header, no footer, no menus.

I want that when I click on View as PDF, it should export report to pdf and instead of opening into a new tab, it should open the pdf into same content page. I don't want to use report.ExportToDisk(....) because there are numerous reports in my application and user will view them many times a day. So exportToDisk will not be suitable as it will always export as a file to server and there will be a huge collection.

View 1 Replies

Controls :: Export GridView With Images To PDF Using ITextSharp

Mar 4, 2013

Before converting a gridview to PDF I can modify the font size and color using:

gridview.HeaderRow.Style.Add("font-family","Arial, Helvetica, sans-serif;"); gridview.HeaderRow.Style.Add("font-size","7.20px"); gridview.HeaderRow.Style.Add("color","#284775"); 

gridview.Style.Add("font-family","Arial, Helvetica, sans-serif;");
gridview.Style.Add("font-size","6px");

The gridview has different column widths because of the information that is being displayed, those sizes are set .aspx file. But, the generated pdf file auto adjusts the width of each column to be the same size, therefore the information is shrinked and doesnt look good..

I tried the following:

gridview.Width =100;
or
gridview.Style.Add("width","100"); 
or
gridview.Columns[3].ItemStyle.Width =Unit.Pixel(10);

And many more but haven't been able to adjust the gridview to it's original columns width. How can I do that?

This is the code I use to generate the PDF file:

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=UserDetails.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);

[Code] .....

View 1 Replies

Web Forms :: ITextsharp - Export Gridview To PDF Without Header Row

Apr 15, 2012

I am using textsharp dll to export to pdf.Its exporting the gridview without the header row.

View 1 Replies

Controls :: Export Chemical Formula To PDF Using ITextSharp

Oct 21, 2015

I am having a label on web form which contains chemical formula, when I am exporting web form in pdf using iTextSharp it displaying like this :

<p>C<sub>32</sub>H<sub>16</sub>CuN<sub>8</sub></p>

I want to display like this in pdf C32H16CuN8

StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
lblChemicalFormula.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
HTMLWorker htmlparser = new HTMLWorker(document);

[Code] ....

View 1 Replies

Using ITextSharp Library To Export GridView With Images To PDF - URL?

Feb 4, 2013

I am using the iTextSharp library to export a gridview with images to pdf. Some of the image urls are not directly to an image, but rather direct you to a .aspx page which displays the image. (includes a parameter with the id, and when you view the url in a browser you can see the image.) When I run the below code, I get an error that the image url in not a recognized image format.

Code:
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition",
"attachment;filename=GridViewExport.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);

[Code] ........

View 4 Replies

Databases :: How To Export Gridview Data To An Excel File From A Content Page

Mar 29, 2010

I am trying to export a grdview to an Excel file but I am getting this error and i suspect

the error has something to do with the fact that the code is on a CONTENT page and not web page:

[Code]....

Here is my export code:

[Code]....

So I trying adding this code to avoid the error but this has a problem with a content page:

[Code]....

[Code]....

View 1 Replies

Can ITextSharp Rasterize/export To JPEG Or Other Image Format

Apr 26, 2010

I need to be able to export PDF's that I am creating to JPEG, so that users can have a screenshot/thumbnail of the end product, which is faster than opening the whole PDF.

I am running this on an ASP.NET website running in Medium Trust in the Rackspace Mosso Cloud.

I have yet to find a library that will either work in Medium trust, or in the case of ABC PDF, which works great locally, wont load in Mosso. Maybe Mosso has a custom trust level?

I know that iTextSharp works on Mosso, but I haven't been able to figure how to "screenshot" a single page of a PDF, or export a page to JPEG.

View 1 Replies

Controls :: Export Multiple Charts To PDF Using ITextSharp Library?

Jan 30, 2013

How do i export multiple charts to pdf using iText library?

View 1 Replies

Controls :: Print (Export) TextBox Contents As PDF Using ITextSharp

Apr 2, 2013

I want to print  one TexBox (TextMode = "MultiLine") to  pdf with ITEXTSHARP !!

My problem is that when I print the textbox contained ,he displays contained in html forma

Here is my code printing

PdfPTable TblB = new PdfPTable(1);
float[] Awidthss = new float[] { 4f};
TblB.SetWidths(Awidthss);

PdfPCell B1 = new PdfPCell(new Phrase(10, " ", f3));
B1.BackgroundColor = new BaseColor(ColorTranslator.FromHtml("#e9e9e9"));

[Code]..

View 1 Replies

Controls :: Export Search Results In GridView To PDF Using ITextSharp

Sep 24, 2013

In my gridview I am selecting data using search textbox....

I want to make pdf file of the searched data....

but when I clicked on my pdfbutton after searching data it make the pdf file of all data present in my table....

View 1 Replies

Controls :: Export To PDF Using ITextSharp HTML Parser Error

Feb 20, 2013

How to save webpage as pdf...    Am using asp.net 4.0 and oracle 10g. and code behind language as vb.net.I have one button. that converts the web page to pdf.It shows Could not find file 'C:....' in  htmlparser.Parse(sr) error... 

Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment;filename=psno.pdf")
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Dim sw As New StringWriter()

[code].....

View 1 Replies

Controls :: ITextSharp - Export HTML To Multiple PDF Pages Using C#

May 7, 2015

I am creating a pdf document with fields from sql database using iTextsharp,after a client inputs information, the next button is pressed each page is saved  in new row with page01,page02 etc as a column within that database. I would like iTextsharp to loop and create a new page based on this page number and have one pdf doc. my code is as below.

protected void GenerateReport(object sender, EventArgs e)
{
DataRow dr = GetData("SELECT * FROM OnSiteWorkTx where DocID = " + DropDownListPdf.SelectedItem.Value).Rows[0]; ;

[Code].....

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved