|
Yea. U can add the page number in your PDF Report.
see the code :
int pgNo = 1;
while (!myPdfTable.AllTablePagesCreated)
{
PdfPage newPdfPage = myPdfDocument.NewPage();
PdfTablePage newPdfTablePage =
myPdfTable.CreateTablePage(new PdfArea(myPdfDocument,48, 130, 500, 670));
PdfTextArea pageNumber = new PdfTextArea(new Font("Verdana", 8, FontStyle.Regular), Color.Black
, new PdfArea(myPdfDocument, 50, 0, 450, 1600), ContentAlignment.MiddleRight, "Page Number : " + pgNo++.ToString());
newPdfPage.Add(newPdfTablePage);
newPdfPage.Add(pta);
newPdfPage.Add(ToDate);
newPdfPage.Add(pageNumber);
newPdfPage.SaveToDocument();
}
|
|
|
|
|
Hi,
this library is very useful. I want to can I use this library in asp.net 2005 and if Yes then how.
Actually I have a web page that generate reports. I want to save that report in a pdf on the users computer.
Please help me.
thanks
|
|
|
|
|
Hi
I also want to use in web application. I tried to use in web apps, but getting some error. Please help me. This is my code i write to save the generated PDF.
newPdfPage.SaveToDocument();
myPdfDocument.SaveToFile(HttpContext.Current.Server.MapPath(@"~/PdfFiles/" ));
Please help me.
|
|
|
|
|
Yes, we can use in web application. I used in web application. But when i use in web application, i got some error. The error is "error generating the document". So to resolve the error i add one more dll. The name of dll is ICSharpCode.SharpZipLib.dll. So when i add the dll the error removed.
Note: If you want to use the dll in your Application please add the two important dll.
1)Gios Pdf.NET.dll
2)ICSharpCode.SharpZipLib.dll
so see the sample code. how to use in web application
public void ShowTable()
{
IList<alert> data = GetAlertDetails();
if (data != null)
{
lvAlert.DataSource = null;
lvAlert.DataSource = data;
lvAlert.DataBind();
}
else
{
lvAlert.DataSource = null;
dataPager2.Visible = false;
lblmsg.Text = "No Record Found";
isNoRecord = true;
}
var countData = data.Count();
if (countData <= 0)
{
lblmsg.Visible = true;
lblmsg.Text = "No Records";
return;
}
DataTable d1t = new DataTable();
d1t.Columns.Add("No.");
d1t.Columns.Add("Type");
d1t.Columns.Add("Severity");
d1t.Columns.Add("Description");
d1t.Columns.Add("Job Name");
d1t.Columns.Add("Create Date");
int i = 1;
foreach (Alert rp in data)
{
DataRow dr = d1t.NewRow();
dr["No."] = i.ToString();
dr["Type"] = rp.Type;
dr["Severity"] = rp.Severity;
dr["Description"] = rp.Description;
dr["Job Name"] = rp.JobName;
dr["Create Date"] = rp.CreateDate;
i++;
d1t.Rows.Add(dr);
}
PdfDocument myPdfDocument = new PdfDocument(PdfDocumentFormat.InCentimeters(21, 29.7));
var count = data.Count();
PdfTable myPdfTable = myPdfDocument.NewTable(new Font("Verdana", 7), count, 6, 4);
myPdfTable.ImportDataTable(d1t);
myPdfTable.HeadersRow.SetColors(Color.White, Color.Gray);
myPdfTable.SetBorders(Color.Gray, 0.5, BorderType.ColumnsAndBounds);
myPdfTable.SetColors(Color.Black, Color.White, Color.Gainsboro);
myPdfTable.SetColumnsWidth(new int[] { 4, 12, 9, 30, 13, 15 });
myPdfTable.SetContentAlignment(ContentAlignment.MiddleCenter);
myPdfTable.Columns[3].SetContentAlignment(ContentAlignment.TopLeft);
PdfImage LogoImage = myPdfDocument.NewImage(HttpContext.Current.Server.MapPath(@"~/images/perpetuiti_logo.jpg"));
PdfTextArea pta = new PdfTextArea(new Font("Verdana", 15, FontStyle.Bold), Color.DodgerBlue
, new PdfArea(myPdfDocument, 0, 20, 595, 80), ContentAlignment.MiddleCenter, "Alerts Log");
PdfTextArea ptaGroup = new PdfTextArea(new Font("Verdana", 9, FontStyle.Bold), Color.Black
, new PdfArea(myPdfDocument, 50, 0, 220, 160), ContentAlignment.MiddleRight, "Group Name : ");
PdfTextArea ptaGroupName = new PdfTextArea(new Font("Verdana", 9, FontStyle.Bold), Color.Black
, new PdfArea(myPdfDocument, 70, 0, 280, 160), ContentAlignment.MiddleRight, ddlGroup.SelectedItem.Text.ToString());
PdfTextArea From = new PdfTextArea(new Font("Verdana", 8, FontStyle.Bold), Color.Black
, new PdfArea(myPdfDocument, 50, 0, 100, 190), ContentAlignment.MiddleRight, "From: ");
PdfTextArea FromDate = new PdfTextArea(new Font("Verdana", 8, FontStyle.Underline), Color.Black
, new PdfArea(myPdfDocument, 50, 0, 140, 190), ContentAlignment.MiddleRight, txtFromDate.Text);
PdfTextArea To = new PdfTextArea(new Font("Verdana", 8, FontStyle.Bold), Color.Black
, new PdfArea(myPdfDocument, 50, 0, 360, 190), ContentAlignment.MiddleRight, "To: ");
PdfTextArea ToDate = new PdfTextArea(new Font("Verdana", 8, FontStyle.Regular), Color.Black
, new PdfArea(myPdfDocument, 50, 0, 400, 190), ContentAlignment.MiddleRight, txtToDate.Text);
int pgNo = 1;
while (!myPdfTable.AllTablePagesCreated)
{
PdfPage newPdfPage = myPdfDocument.NewPage();
PdfTablePage newPdfTablePage =
myPdfTable.CreateTablePage(new PdfArea(myPdfDocument, 48, 100, 500, 670));
PdfTextArea pageNumber = new PdfTextArea(new Font("Verdana", 8, FontStyle.Regular), Color.Black
, new PdfArea(myPdfDocument, 50, 0, 450, 1600), ContentAlignment.MiddleRight, "Page Number : " + pgNo++.ToString());
newPdfPage.Add(LogoImage, 440, 15, 120);
//newPdfPage.Add(LogoImage, 440, 80, 82);
newPdfPage.Add(newPdfTablePage);
newPdfPage.Add(pta);
newPdfPage.Add(ptaGroup);
newPdfPage.Add(ptaGroupName);
newPdfPage.Add(From);
newPdfPage.Add(FromDate);
newPdfPage.Add(To);
newPdfPage.Add(ToDate);
newPdfPage.Add(pageNumber);
newPdfPage.SaveToDocument();
}
str = DateTime.Now.ToString().Replace("/", "");
str = str.Replace(":", "");
str = str.Substring(0, str.Length - 5);
str = System.Text.RegularExpressions.Regex.Replace(str, @"\s", "");
str = ddlGroup.SelectedItem.Text.ToString() + "Alert" + str + ".pdf";
myPdfDocument.SaveToFile(HttpContext.Current.Server.MapPath(@"~/PdfFiles/" + str));
string myUrl = "/PdfFiles/" + str;
string fullURL = "window.open('" + myUrl + "', '_blank', 'height=500,width=800,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,titlebar=DataLog Report' );";
ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true);
lblmsg.Text = "";
}
knowledgetoyou
|
|
|
|
|
I get an excpetion about the height! Then I cant use the library
|
|
|
|
|
Can you show the code causing the problem?
|
|
|
|
|
See the reason is like that :
PdfTable myPdfTable = myPdfDocument.NewTable(new Font("Verdana", 7), countData, 6, 4);
myPdfTable.SetColumnsWidth(new int[] { 4,8,13,15,10,5 });
Note: Here countData is total number of records we are getting from the object and 6 is the total number of column, we are going to populate in the PDF report. So total number of column must be equal to setcolumnwidth.
I hope it is helpful for u.
|
|
|
|
|
1.I want to display arabic text in the pdf document and change the text direction from right to left
2.add the images in the header and the footer of the pdfdocument and then save it as pdf template so that can be used for all the documents
how can i achieve in this library
regards
kabilan shanmugavel
|
|
|
|
|
Hi,
Have you found solution for this?
Thanks.
|
|
|
|
|
This is just what I needed to get a pdf start ! There are a few bugs here and there, but
nice work ! I did change adding an image to the page from file to Bitmap for flexiblity.
|
|
|
|
|
- the length of the xref table is not correct (1 longer than indicated)
- the values of the xref table are not correct (first value can not start at 0, but after the pdf header)
- the length for streams must be /Length and not /Lenght
- the file is stored in text mode, which does a convertion from lf to crlf, this gives problems in the calculation of the xref table and gives problems in compressed parts
|
|
|
|
|
Very nice document. Thank you for the library source code and detail.
|
|
|
|
|
Please I want to add this word in the pdf: "TEST".
How can I do?
modified on Friday, November 27, 2009 3:47 AM
|
|
|
|
|
|
Please write your exact requirement. Then i will reply to u.
|
|
|
|
|
First of all thank you for this great tool.
html code we use <sup>text</sup> but I can't find how to supper with this tool.
It'll be useless without it. help me to solve it.
|
|
|
|
|
hi,
I want to add text containing URL link inside the PDF
For example I have www.google.com as the URL
I want to set this url to a text "go to google"
modified on Friday, October 30, 2009 8:04 AM
|
|
|
|
|
Is this problem solved..? i am also waiting for answer
|
|
|
|
|
how to convert image file like jpg, BMP to PDF file using C# 2008.
Plz give the code.
|
|
|
|
|
you can try ITextSharp check on net , if you need details reply back
|
|
|
|
|
Hello All,
I have problem that when I export long text in table, some correct text are missing in table and strange text are overflow out the table and displayed unexpected characters such as (Tj1001223401, Tj1000223521....) I don't understand why.... Please help me. Thanks in advanced.
modified on Tuesday, September 15, 2009 4:02 AM
|
|
|
|
|
Hi,
I was just wondering if you've ever got this figured out (i.e how to wrap a long text around in a cell). If you have, could you share some insights on what you had to to?
Thanks,
Qazn123
|
|
|
|
|
Hi,
I like the library you have provided. I have a problem related to SetContentFormat(). I have supplied {0 }, {0:dd/MM/yyyy} for date type, {0:C} for amount (currency) etc. But no formatting is applied to the PDF output. Could you please explain me, what is exact reason or how should I use formatting.
Thanks and regards
Mohammad Irfan
|
|
|
|
|
The "Download complete project with source - 157 Kb" link is broken. Can you help me?
|
|
|
|
|
I am getting Error Generating document exception on using pdftextarea,pdfarea and adding to pdfpage, running application from online server. In offline its working fine.
If I am using only pdfpage and pdfimage not getting any exception in online and also in offline.
Kindly provide the solution.
|
|
|
|
|