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
|