Satish Gautam

Satish Gautam

  • 1.9k
  • 33
  • 941

PDF allignmnents

Jul 31 2018 2:33 AM
I have this code
 
protected void btnprev_Click(object sender, EventArgs e)
{
StringReader sr = new StringReader(edheader.Content + eddetails.Content + edfooter.Content);
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
using (MemoryStream memoryStream = new MemoryStream())
{
PdfWriter writer = PdfWriter.GetInstance(pdfDoc, memoryStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
byte[] bytes = memoryStream.ToArray();
memoryStream.Close();
// Clears all content output from the buffer stream
Response.Clear();
// Gets or sets the HTTP MIME type of the output stream.
Response.ContentType = "application/pdf";
// Adds an HTTP header to the output stream
Response.AddHeader("Content-Disposition", "attachment; filename=Data.pdf");

//Gets or sets a value indicating whether to buffer output and send it after
// the complete response is finished processing.
Response.Buffer = true;
// Sets the Cache-Control header to one of the values of System.Web.HttpCacheability.
Response.Cache.SetCacheability(HttpCacheability.NoCache);
// Writes a string of binary characters to the HTTP output stream. it write the generated bytes .
Response.BinaryWrite(bytes);

// Sends all currently buffered output to the client, stops execution of the
// page, and raises the System.Web.HttpApplication.EndRequest event.
Response.End();
// Closes the socket connection to a client. it is a necessary step as you must close the response after doing work.its best approach.
Response.Close();
}
 
I want the pdf page to have 3 sections where i have 3 editors name header , footer , details.
 
like this
 
and the pdf data is the text of the editor see below
 
So to make it more sense of the data in pdf i want section indicating header footer and details like this
 
 Like This Please help ..Thanks
 

Brought to you by:

Answers (2)