TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Chevy Mark Sunderland
NA
188
167.3k
Add logo image for each page on pdf file by iTextSharp
Aug 11 2016 8:10 AM
Hi there, hope in your help.
I have been trying to add an image to all pages using iTextSharp.
The below code correctly it inserted all information from asp Panel "on Print" but only inserts an image in the first page.
Is there any way to insert the image in the same way in all pages?
Can you help me ?
Thank you in advance.
private
void
CreatePdf()
{
Response.ContentType =
"application/pdf"
;
Response.AddHeader(
"content-disposition"
,
"attachment;filename="
test.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw =
new
StringWriter();
HtmlTextWriter hw =
new
HtmlTextWriter(sw);
pnPrint.RenderControl(hw);
StringReader sr =
new
StringReader(sw.ToString());
string
imagepath = Server.MapPath(
"."
) +
"\\Img\\logo.jpg"
;
Document pdfDoc =
new
Document(PageSize.A4, 20f, 20f, 10f, 20f);
try
{
HTMLWorker htmlparser =
new
HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
for
(
int
i = 0; i < 5; i++)
{
Image image = Image.GetInstance(imagepath);
image.Alignment = Image.ALIGN_LEFT;
pdfDoc.Add(image);
htmlparser.Parse(sr);
}
}
catch
(Exception ex)
{
throw
ex;
}
finally
{
pdfDoc.Close();
Response.End();
}
}
Reply
Answers (
4
)
Issue with Posted JSON data to Web API
How to merge the datatable in dataset? Asp.net C#