PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Oct 31, 2024 11:49 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: export gridview to pdf
PostPosted: Fri Jun 06, 2014 9:43 pm 
Offline

Joined: Fri Jun 06, 2014 9:36 pm
Posts: 1
I'm trying to create and ADA compliant pdf
by exporting a gridvew to pdf. See code below.
Response.ClearContent();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", string.Format("attachment;filename={0}", "AdminExpenditures.pdf"));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
// setting some response headers
Response.Headers.Set("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
Response.Headers.Set("Expires", "0");
Response.Headers.Set("Pragma", "public");

StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
gvGridView.DataBind();
gvGridView.AllowPaging = false;
gvGridView.RenderControl(hw);
gvGridView.UseAccessibleHeader = true;
StringReader sr = new StringReader(sw.ToString());
iTextSharp.text.Document pdfDoc = new iTextSharp.text.Document(PageSize.A2, 10f, 10f, 10f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
iTextSharp.text.pdf.PdfWriter pw = iTextSharp.text.pdf.PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pw.PdfVersion = iTextSharp.text.pdf.PdfWriter.VERSION_1_7;
pw.SetTagged();
pw.UserProperties = true;
pdfDoc.Open();

//PdfDictionary dict = new PdfDictionary();
//dict.Put(PdfName.LANG, new PdfString("en-us"));
//pw.DirectContent.BeginMarkedContentSequence(PdfName.FIGURE, dict, true);

pdfDoc.AddTitle("SUMMARY OF EXPENDITURES");
pdfDoc.AddAuthor("OPEN BOE");
pdfDoc.AddCreator("Board of Equalization");
pdfDoc.AddKeywords("Open Data Portal");
pdfDoc.AddSubject("SUMMARY OF EXPENDITURES");
pdfDoc.AddLanguage("English");
pdfDoc.AddHeader("Header", "SUMMARY OF EXPENDITURES");
htmlparser.Parse(sr);
//pw.DirectContent.EndMarkedContentSequence();
pw.Flush();
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();

This fails both Title and Headers when I check Accessability with Adobe Acrobat Pro


Top
 Profile  
 
PostPosted: Tue Jun 10, 2014 8:18 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3111
Location: Cologne, Germany
This is the PDFsharp forum, not the iTextSharp forum.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 40 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group