Rank: Member Groups: Member
Joined: 8/4/2014 Posts: 11
|
how to rotate the pdf document (or a page, because my document contains only one page) 180 degrees?
Code: C#
PdfDocument doc = new PdfDocument();
HtmlToPdfResult result = HtmlToPdf.ConvertHtml(sCoursePlan, doc);
EO.Pdf.Drawing.PdfMatrix matrix = new EO.Pdf.Drawing.PdfMatrix();
//matrix.FlipY(); // doesn't work
matrix.Rotate(180); // doesn't work
doc.Pages[0].Transform(matrix);
MemoryStream memory;
using (memory = new MemoryStream())
{
doc.Save(memory);
}
after rotation the page is empty. No idea why...
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
You need to do a rotate and a translate for this case. When you rotate, you are rotating the page around the bottom left corner. So once you rotate the page 180 degrees, you actually have rotated the whole page out of view because your original page rectangle of (0, 0, width, height) now becomes (-width, -height, 0, 0). In order to move that rectangle into visible area (both x and y must be positive in visible area). You must do a translate (width, height) so that the visible rectangle becomes (0, 0, width, height) again.
Thanks!
|