public override IList <IElement> Start(IWorkerContext ctx, Tag tag) { float height = 0; //TODO check viewbox float width = 0; //TODO check viewbox Rectangle r = null; String viewbox = ""; IDictionary <String, String> attributes = tag.Attributes; if (attributes != null) { try { if (attributes.ContainsKey("height")) { height = float.Parse(attributes["height"]); } }catch { //TODO } try{ if (attributes.ContainsKey("width")) { width = float.Parse(attributes["width"]); } }catch { //TODO } try{ if (attributes.TryGetValue("viewBox", out viewbox)) { r = new Rectangle(0, 0); StringTokenizer st = new StringTokenizer(viewbox); if (st.HasMoreTokens()) { r.Right = float.Parse(st.NextToken()); } if (st.HasMoreTokens()) { r.Bottom = -float.Parse(st.NextToken()); } if (st.HasMoreTokens()) { r.Left = r.Right + float.Parse(st.NextToken()); } if (st.HasMoreTokens()) { r.Top = r.Bottom + float.Parse(st.NextToken()); } r.Normalize(); } } catch { //TODO } } if (r == null) { r = new Rectangle(width, height); } else if (width == 0 && height == 0) { width = r.Width; height = r.Height; } IList <IElement> elems = new List <IElement>(); elems.Add(new Svg(height, width, r, tag.CSS)); return(elems); }
public override IList<IElement> Start(IWorkerContext ctx, Tag tag) { float height = 0; //TODO check viewbox float width = 0; //TODO check viewbox Rectangle r = null; String viewbox = ""; IDictionary<String, String> attributes = tag.Attributes; if(attributes != null){ try { if (attributes.ContainsKey("height")) { height = float.Parse(attributes["height"]); } }catch { //TODO } try{ if (attributes.ContainsKey("width")) { width = float.Parse(attributes["width"]); } }catch { //TODO } try{ if (attributes.TryGetValue("viewBox", out viewbox)) { r = new Rectangle(0, 0); StringTokenizer st = new StringTokenizer(viewbox); if (st.HasMoreTokens()) r.Right = float.Parse(st.NextToken()); if (st.HasMoreTokens()) r.Bottom = -float.Parse(st.NextToken()); if (st.HasMoreTokens()) r.Left = r.Right + float.Parse(st.NextToken()); if (st.HasMoreTokens()) r.Top = r.Bottom + float.Parse(st.NextToken()); r.Normalize(); } } catch { //TODO } } if (r == null) { r = new Rectangle(width, height); } else if (width == 0 && height == 0) { width = r.Width; height = r.Height; } IList<IElement> elems = new List<IElement>(); elems.Add(new Svg(height, width, r, tag.CSS)); return elems; }
/** * Sets the signature to be visible. An empty signature field with the same name must already exist. * @param fieldName the existing empty signature field name */ public void SetVisibleSignature(String fieldName) { AcroFields af = writer.AcroFields; AcroFields.Item item = af.GetFieldItem(fieldName); if (item == null) throw new ArgumentException(MessageLocalization.GetComposedMessage("the.field.1.does.not.exist", fieldName)); PdfDictionary merged = item.GetMerged(0); if (!PdfName.SIG.Equals(PdfReader.GetPdfObject(merged.Get(PdfName.FT)))) throw new ArgumentException(MessageLocalization.GetComposedMessage("the.field.1.is.not.a.signature.field", fieldName)); this.fieldName = fieldName; PdfArray r = merged.GetAsArray(PdfName.RECT); float llx = r.GetAsNumber(0).FloatValue; float lly = r.GetAsNumber(1).FloatValue; float urx = r.GetAsNumber(2).FloatValue; float ury = r.GetAsNumber(3).FloatValue; pageRect = new Rectangle(llx, lly, urx, ury); pageRect.Normalize(); page = item.GetPage(0); int rotation = writer.reader.GetPageRotation(page); Rectangle pageSize = writer.reader.GetPageSizeWithRotation(page); switch (rotation) { case 90: pageRect = new Rectangle( pageRect.Bottom, pageSize.Top - pageRect.Left, pageRect.Top, pageSize.Top - pageRect.Right); break; case 180: pageRect = new Rectangle( pageSize.Right - pageRect.Left, pageSize.Top - pageRect.Bottom, pageSize.Right - pageRect.Right, pageSize.Top - pageRect.Top); break; case 270: pageRect = new Rectangle( pageSize.Right - pageRect.Bottom, pageRect.Left, pageSize.Right - pageRect.Top, pageRect.Right); break; } if (rotation != 0) pageRect.Normalize(); rect = new Rectangle(this.pageRect.Width, this.pageRect.Height); }
/** * Sets the signature to be visible. An empty signature field with the same name must already exist. * @param fieldName the existing empty signature field name */ public void SetVisibleSignature(String fieldName) { AcroFields af = writer.AcroFields; AcroFields.Item item = af.GetFieldItem(fieldName); if (item == null) throw new ArgumentException("The field " + fieldName + " does not exist."); PdfDictionary merged = (PdfDictionary)item.merged[0]; if (!PdfName.SIG.Equals(PdfReader.GetPdfObject(merged.Get(PdfName.FT)))) throw new ArgumentException("The field " + fieldName + " is not a signature field."); this.fieldName = fieldName; PdfArray r = (PdfArray)PdfReader.GetPdfObject(merged.Get(PdfName.RECT)); ArrayList ar = r.ArrayList; float llx = ((PdfNumber)PdfReader.GetPdfObject((PdfObject)ar[0])).FloatValue; float lly = ((PdfNumber)PdfReader.GetPdfObject((PdfObject)ar[1])).FloatValue; float urx = ((PdfNumber)PdfReader.GetPdfObject((PdfObject)ar[2])).FloatValue; float ury = ((PdfNumber)PdfReader.GetPdfObject((PdfObject)ar[3])).FloatValue; pageRect = new Rectangle(llx, lly, urx, ury); pageRect.Normalize(); page = (int)item.page[0]; int rotation = writer.reader.GetPageRotation(page); Rectangle pageSize = writer.reader.GetPageSizeWithRotation(page); switch (rotation) { case 90: pageRect = new Rectangle( pageRect.Bottom, pageSize.Top - pageRect.Left, pageRect.Top, pageSize.Top - pageRect.Right); break; case 180: pageRect = new Rectangle( pageSize.Right - pageRect.Left, pageSize.Top - pageRect.Bottom, pageSize.Right - pageRect.Right, pageSize.Top - pageRect.Top); break; case 270: pageRect = new Rectangle( pageSize.Right - pageRect.Bottom, pageRect.Left, pageSize.Right - pageRect.Top, pageRect.Right); break; } if (rotation != 0) pageRect.Normalize(); rect = new Rectangle(this.pageRect.Width, this.pageRect.Height); }