public static Layout BuildFromXjf(int papCode, xpresso xjf) { var layout = BuildEmptyLayout(xjf, papCode); layout.Elements.Add(BuildColorStripElement(layout)); layout.Elements.Add(BuildVendorLogoElement(xjf)); return(layout); }
public static void Save(xpresso xjf, int papCode) { var fileName = string.Format(_workXjfFileNameTempate, papCode); using (var writer = new StreamWriter(fileName)) { var serializer = new XmlSerializer(typeof(xpresso)); serializer.Serialize(writer, xjf); } }
public static xpresso AddMeasureColorStrip(xpresso xjf, Layout layoutWithColorStrip) { var colorStripCustomization = BuildColorStripCustomization(layoutWithColorStrip); var currentPictures = xjf.templates.pages.page.picture.ToList(); currentPictures.Add(colorStripCustomization); xjf.templates.pages.page.picture = currentPictures.ToArray(); return(xjf); }
private static Layout BuildEmptyLayout(xpresso xjf, int papCode) { var separator = new[] { ' ' }; // todo: check if we can always assume Points as size units var sheetWidthPoints = float.Parse(xjf.job.layout.size.Split(separator)[0]); var sheetHeightPoints = float.Parse(xjf.job.layout.size.Split(separator)[1]); return(new Layout { PapCode = papCode, SheetHeight = sheetHeightPoints, SheetWidth = sheetWidthPoints, Elements = new List <Element>() }); }
private static Element BuildVendorLogoElement(xpresso xjf) { var pointsInInch = 72.0f; var vendorElement = xjf.templates.pages.page.picture.Single(pic => pic.resource == "{vendorid}.jpg"); var separator = new[] { ' ' }; var locationData = vendorElement.data.Split(separator); var leftPoints = float.Parse(locationData[0]) * pointsInInch; var bottomPoints = float.Parse(locationData[1]) * pointsInInch; var widthPoints = float.Parse(locationData[2]) * pointsInInch; var heightPoints = float.Parse(locationData[3]) * pointsInInch; return(new Element { Type = ElementType.VendorLogo, //Left = leftPoints, //Bottom = bottomPoints, //Height = heightPoints, //Width = widthPoints, Rotate = vendorElement.rotate }); }
// this method uses XJF data directly, use it only for reference public static string GetCustomizations(xpresso xjf) { var page = xjf.templates.pages.page; var xmlBuffer = new StringBuilder(); using (var writer = new StringWriter(xmlBuffer)) { var serializer = new XmlSerializer(typeof(xpressoTemplatesPagesPage)); serializer.Serialize(writer, page); } var customizationsString = xmlBuffer.ToString(); // some cleanup customizationsString = customizationsString.Replace("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"", string.Empty); customizationsString = customizationsString.Replace("<?xml version=\"1.0\" encoding=\"utf-16\"?>", string.Empty); customizationsString = customizationsString.Replace("xpressoTemplatesPagesPage", "page"); return(customizationsString.Trim()); }