next newid extended on CreatePicture in Paragraph class SetWidthsPercentage pwidth calculation extended with * (96 / 72) to get pixels from pointsmaster
| string temp = pr.SourceUri.OriginalString; | string temp = pr.SourceUri.OriginalString; | ||||
| string start = temp.Remove(temp.LastIndexOf('/')); | string start = temp.Remove(temp.LastIndexOf('/')); | ||||
| string end = pr.TargetUri.OriginalString; | string end = pr.TargetUri.OriginalString; | ||||
| string full = start + "/" + end; | |||||
| string full = end.Contains(start) ? end : start + "/" + end; | |||||
| return(new PackagePartStream(document.package.GetPart(new Uri(full, UriKind.Relative)).GetStream(mode, access))); | |||||
| return (new PackagePartStream(document.package.GetPart(new Uri(full, UriKind.Relative)).GetStream(mode, access))); | |||||
| } | } | ||||
| /// <summary> | /// <summary> |
| existingIds.Add(idAtt.Value); | existingIds.Add(idAtt.Value); | ||||
| } | } | ||||
| while (existingIds.Contains(newDocPrId.ToString())) | |||||
| newDocPrId++; | |||||
| //also loop thru all docPr ids | |||||
| foreach (var bookmarkId in document.Xml.Descendants(XName.Get("docPr", DocX.wp.NamespaceName))) | |||||
| { | |||||
| var idAtt = bookmarkId.Attributes().FirstOrDefault(x => x.Name.LocalName == "id"); | |||||
| if (idAtt != null) | |||||
| existingIds.Add(idAtt.Value); | |||||
| } | |||||
| while (existingIds.Contains(newDocPrId.ToString())) | while (existingIds.Contains(newDocPrId.ToString())) | ||||
| newDocPrId++; | newDocPrId++; | ||||
| get { return cx / EmusInPixel; } | get { return cx / EmusInPixel; } | ||||
| set | set | ||||
| { | |||||
| cx = value; | |||||
| { | |||||
| cx = value * EmusInPixel; | |||||
| foreach (XAttribute a in Xml.Descendants().Attributes(XName.Get("cx"))) | foreach (XAttribute a in Xml.Descendants().Attributes(XName.Get("cx"))) | ||||
| a.Value = (cx * EmusInPixel).ToString(); | |||||
| a.Value = (cx).ToString(); | |||||
| } | } | ||||
| } | } | ||||
| get { return cy / EmusInPixel; } | get { return cy / EmusInPixel; } | ||||
| set | set | ||||
| { | |||||
| cy = value; | |||||
| { | |||||
| cy = value * EmusInPixel; | |||||
| foreach (XAttribute a in Xml.Descendants().Attributes(XName.Get("cy"))) | foreach (XAttribute a in Xml.Descendants().Attributes(XName.Get("cy"))) | ||||
| a.Value = (cy * EmusInPixel).ToString(); | |||||
| a.Value = (cy).ToString(); | |||||
| } | } | ||||
| } | } | ||||
| { | { | ||||
| if (totalWidth == null) totalWidth = this.Document.PageWidth - this.Document.MarginLeft - this.Document.MarginRight; // calculate total table width | if (totalWidth == null) totalWidth = this.Document.PageWidth - this.Document.MarginLeft - this.Document.MarginRight; // calculate total table width | ||||
| List<float> widths = new List<float>(widthsPercentage.Length); // empty list, will hold actual width | List<float> widths = new List<float>(widthsPercentage.Length); // empty list, will hold actual width | ||||
| widthsPercentage.ToList().ForEach(pWidth => { widths.Add(pWidth * totalWidth.Value / 100); }); // convert percentage to actual width for all values in array | |||||
| widthsPercentage.ToList().ForEach(pWidth => { widths.Add((pWidth * totalWidth.Value / 100) * (96 / 72)); }); // convert percentage to actual width for all values in array | |||||
| SetWidths(widths.ToArray()); // set actual column width | SetWidths(widths.ToArray()); // set actual column width | ||||
| } | } | ||||