public void ScalePercent(float percentX, float percentY) { plainWidth = (this.Width * percentX) / 100f; plainHeight = (this.Height * percentY) / 100f; float[] matrix = Matrix; scaledWidth = matrix[DX] - matrix[CX]; scaledHeight = matrix[DY] - matrix[CY]; WidthPercentage = 0; }
private void AddCover() { try { byte[] cover = WebCrawler.DownloadCover(lnParameters.urlCover); PdfImage pic = PdfImage.GetInstance(cover); if (pic.Height > pic.Width) { //Maximum height is 800 pixels. float percentage = 0.0f; percentage = 700 / pic.Height; pic.ScalePercent(percentage * 100); } else { //Maximum width is 600 pixels. float percentage = 0.0f; percentage = 540 / pic.Width; pic.ScalePercent(percentage * 100); } pic.Border = Rectangle.BOX; pic.BorderColor = BaseColor.BLACK; pic.BorderWidth = 3f; pdf.NewPage(); pdf.Add(pic); } catch (CoverException) {} }