0

I have a pdf which produced by SSRS. I need to get this pdf as a byte array then save whole pdf as a A4.Landscape.

I try ;

string say ="hello world";
byte [] pdfArr=Encoding.UTF8.GetBytes(say) 
var doc = new Document(iTextSharp.text.PageSize.A4_Landscape.Rotate());
string path = Environment.CurrentDirectory;
PdfWriter.GetInstance(doc, new FileStream(path,"/pdfdoc.pdf",FileMode.Create));
doc.Open();
doc.Add(new Paragraph(Encoding.UTF8.GetString(pdfArr)));
doc.Close();
Process.Start(path+"/pdfdoc.pdf");

When I create new pdf by iTextsharp the above code works fine but when I try for the SSRS pdf, the pdf's inside fills with meaningless characters.

Also I know that, I can read and rotate page by page via PDFReader but I don't want to read the pages. Because, the reports table is too long so it divides into pages, I don't know how many pages should involved for one table, so my main aim is showing them in horizantal (landscape) as one table.

Any suggestions or code pieces are welcomed. Thanks anyway..

Edit : As I explained in above paragraph, I can't take pages with pdfReader or something else because I don't want to change every page as landscape and I can't. It doesn't serve my aim. I just wat to create pdf as a landscape so all the loıng tables anda datas can seen in one page.

  • If it's full of meaningless characters I'd guess you've got your encoding wrong somewhere. – Equalsk Apr 03 '17 at 13:24
  • 1
    It's full of meaningless characters because PDF is a binary format. You cannot just take the bytes and recreate the text. – stuartd Apr 03 '17 at 13:25
  • Possible duplicate of [iTextSharp how to rotate/switch page from landscape to portrait](http://stackoverflow.com/questions/5345067/itextsharp-how-to-rotate-switch-page-from-landscape-to-portrait) – Amedee Van Gasse Apr 03 '17 at 14:40
  • @AmedeeVanGasse, thanks for your help but its not provide my requirement. The question you marked is about pages taken single by single. My question is not about taking them single and rotating, creating new pdf as landscape.. thanks anyway –  Apr 04 '17 at 07:26
  • I hate to disappoint you, but the linked question still has a valid answer. You change the rotation of a page by changing the `/Rotate` key in the page dictionary. See line 28 of the code example in that question. – Amedee Van Gasse Apr 04 '17 at 08:00

0 Answers0