1jaws
asked on
landscape
Using iTextSharp...I am trying do like this to make it landscape oriteantion it is not working..
Document doc = new Document(iTextSharp.text.P ageSize.LE TTER.Rotat e);
Document doc = new Document(iTextSharp.text.P
Document doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35);
doc.Open();
iTextSharp.text.Rectangle page = doc.PageSize;
ASKER
Error 1 Cannot implicitly convert type 'iTextSharp.text.pdf.PdfNu mber' to 'iTextSharp.text.pdf.PdfPa ge'
also I am setting to height and weight... it is complain that too when I take out that line..
Error 2 'iTextSharp.text.pdf.PdfPa ge' does not contain a definition for 'Width' and no extension method 'Width' accepting a first argument of type 'iTextSharp.text.pdf.PdfPa ge' could be found (are you missing a using directive or an assembly reference?)
also I am setting to height and weight... it is complain that too when I take out that line..
Error 2 'iTextSharp.text.pdf.PdfPa
ASKER
didnt help me no. :((
What did you get from the link??
ASKER
didnt make the landscape oritentaion.. no error though..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
you did it!! it worked..!! thank you so much!!. I am going to ask more question about this shortly.. if you want to take a look?
ASKER
You know what I just discovered that because it is Document.NewPage();
my title is not showing..!!
my title is not showing..!!
If you will visit the link you will see the use of:
Document.SetPageSize(PageS ize.A4.Rot ate());
before:
Document.NewPage();
We need to rotate the page first and then declare that page. So,Once page is created rotation won't work as described in the link that will giv error.
I was thinking from your title's point of view so the referenec i posted you didn't work. then I work on general page rotation and I found the helpful article.
Document.SetPageSize(PageS
before:
Document.NewPage();
We need to rotate the page first and then declare that page. So,Once page is created rotation won't work as described in the link that will giv error.
I was thinking from your title's point of view so the referenec i posted you didn't work. then I work on general page rotation and I found the helpful article.
ASKER
depending on where I put that code it changes... the way I am sending you now will put it first page empty only shows date displays..than second page it shows my title and the table fine...
but I want to see those on the first page not second...
but I want to see those on the first page not second...
Document doc = new Document();
PdfWriter writer = PdfWriter.GetInstance(doc, Response.OutputStream);
Phrase phrase = new iTextSharp.text.Phrase(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") + " GMT", new iTextSharp.text.Font(iTextSharp.text.Font.COURIER, 5));
doc.Open();
iTextSharp.text.Rectangle page = doc.PageSize;
PdfPTable head = new PdfPTable(1);
head.TotalWidth = page.Width;
PdfPCell c = new PdfPCell(phrase);
c.Border = iTextSharp.text.Rectangle.NO_BORDER;
c.VerticalAlignment = Element.ALIGN_TOP;
c.HorizontalAlignment = Element.ALIGN_CENTER;
head.AddCell(c);
head.WriteSelectedRows(
// first/last row; -1 writes all rows
0, -1,
// left offset
0,
// ** bottom** yPos of the table
page.Height - doc.TopMargin + head.TotalHeight + 20,
writer.DirectContent);
doc.SetPageSize(PageSize.A4.Rotate());
doc.NewPage();
// add image to document
iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance(Request.MapPath("~/GF2images/ogoPDF.jpg"));
logo.Alignment = iTextSharp.text.Image.ALIGN_LEFT;
logo.ScalePercent(60f);
doc.Add(logo);
// report "title"
Paragraph p = new Paragraph("Test Title", new iTextSharp.text.Font(iTextSharp.text.Font.HELVETICA, 10f, iTextSharp.text.Font.BOLD));
p.Alignment = 1;
doc.Add(p);
// add tabular data
doc.Add(my_table());
doc.Close();
ASKER
I got it worked!!!
Okay what did you do ??
ASKER
go ahead and paste that answer you provided this one. to here if youlike I will give you points because you have it got it worked for me...
https://www.experts-exchange.com/questions/26322308/header-text-not-showing.html
https://www.experts-exchange.com/questions/26322308/header-text-not-showing.html
ASKER
and do you have slight idea about this question
https://www.experts-exchange.com/questions/26322278/add-textbox-to-pdf.html
if you like to look at it??
https://www.experts-exchange.com/questions/26322278/add-textbox-to-pdf.html
if you like to look at it??
ASKER
I kept putting the code you gave me anywehere I can and test it accordingly...
iTextSharp.text.pdf.PdfPag
instead of:
iTextSharp.text.Rectangle page = doc.PageSize;