public GuidePage( Guide g, Page p, int ind) { this.guide = g; this.page = p; this.idx = ind; pageBounds = new Bounds( page.Bounds); contentBounds = Bounds.GetContentBounds(g.document, page); //currentY = contentBounds.top; }
/*private static void SetPDFCrop(object tempimg) { if (tempimg is PDF) { idPDFCrop crop = ((PDF)tempimg).PDFAttributes.PDFCrop; ((PDF)tempimg).PDFAttributes.PDFCrop = idPDFCrop.idCropTrim; } }*/ private Rectangle PlaceImageInRect(string filename, Bounds tempBounds, bool resize, idPDFCrop crop) { Rectangle temprect = currentPage.page.Rectangles.Add(miss, idLocationOptions.idAtEnd, miss); temprect.GeometricBounds = tempBounds.raw; temprect.StrokeWeight = 0; temprect.FillColor = document.Swatches["None"]; PlaceImage(filename, temprect, resize, crop, false); return temprect; }
private double DoHeaderIcon(double iconTop, string icon, string text) { if (text.Length > 0) { string iconPath = GetIconPath(icon); Bounds iconBounds = new Bounds(); iconBounds.top = iconTop; iconBounds.left = currentPage.contentBounds.left + GRAPHSIZE + 2; double iconSize = ICONSIZE; iconBounds.width = iconSize; iconBounds.height = iconSize; //PlaceImageInRect(iconPath, iconBounds, true, idPDFCrop.idCropContent); PlaceImageInRect(iconPath, iconBounds, true, idPDFCrop.idCropContentAllLayers); GuideFrame right = GetTextFrame(Mode.SingleColumn, FrameType.Text, true); Bounds rightBounds = right.bounds; rightBounds.top = iconTop + 1; rightBounds.left = iconBounds.left + iconSize + 2; right.ApplyBounds(); right.AddPara(text, "text", true); right.ResizeToFit(); iconTop += Math.Max(iconSize, right.bounds.height) + 1; } return iconTop; }
void SetupSidebar() { if (sideBarMax > 0) { double maxWidth = 40; double height = GetPage(0).contentBounds.height; double topMargin = GetPage(0).contentBounds.top; double top; if (sideBarCount > sideBarMax) Log("!! sideBarCount is bigger than sideBarMax"); double spacing = (height-maxWidth) / (sideBarMax-1); if (spacing > maxWidth) spacing = maxWidth; top = topMargin + spacing * (sideBarCount-1); MasterSpread master = GetMaster("A-Master"); TextFrames tfs = master.TextFrames; foreach (TextFrame tf in tfs) { Bounds b = new Bounds(tf.GeometricBounds); if (tf.Paragraphs.Count > 0) { Paragraph p = (Paragraph) tf.Paragraphs[1]; if ( ((ParagraphStyle) p.AppliedParagraphStyle).Name=="SideBar" ) { //double h = b.height; b.top = top; b.height = maxWidth; tf.GeometricBounds = b.raw; } } } } }
void ProcessImage(XmlElement node) { string src = GetAttr(node, "src"); string width = GetAttr(node, "width"); string noPrint = GetAttr(node, "noPrint"); if (noPrint=="true") return; bool forceTwoColums = GetConfigBool(src, "TwoColumns"); bool fitToPage = GetConfigBool(src, "FitToPage"); bool rotate = GetConfigBool(src, "Rotate"); bool border = GetConfigBool(src, "Border"); string overrideWidth = GetConfig(src, "Width"); if (overrideWidth != null && overrideWidth.Length > 0) width = overrideWidth; //int topOffset = 0; if ( src.Trim().Length > 0 ) { if (src=="starwars.jpg") { int x=0; } string filename = GetAttachmentPath(src); string filenameRepl = filename.Replace(".png",".pdf").Replace(".jpg",".pdf").Replace(".gif",".pdf"); bool pdf = false; if (filenameRepl != filename && System.IO.File.Exists(filenameRepl)) { filename = filenameRepl; pdf = true; } else { string srcpdf = src.Replace(".png", ".pdf").Replace(".jpg", ".pdf").Replace(".gif", ".pdf"); string filecache = Layout.GetFileCache(srcpdf); if (filecache != null) { filename = filecache; pdf = true; } } idPDFCrop crop = idPDFCrop.idCropArt; Bounds tempBounds = new Bounds( new double[] {0.0, 0.0, 10.0, 10.0} ); Rectangle temprect = PlaceImageInRect(filename, tempBounds, false, crop); object tempimg = temprect.AllGraphics.FirstItem(); Bounds tempbounds = Util.GetImageBounds(tempimg); double sizeY = tempbounds.height; double dpi = 72; if (!pdf) { object[] dpis = ((Image)tempimg).ActualPpi; dpi = (double)dpis[0]; } double sizeX = tempbounds.width; temprect.Delete(); if (rotate) { double temp = sizeY; sizeY = sizeX; sizeX = temp; } Mode type = Mode.SingleColumn; double colsize = 120; bool forceNew = true; sizeX = (dpi/72) * sizeX ; sizeY = (dpi/72) * sizeY; double newSX = sizeX; double newSY = sizeY; double w = 0; if (width.Length > 0) w = Double.Parse(width); if (forceTwoColums || (!pdf && ( sizeX < 180 || (width.Length > 0 && w<=500) ) )) { // can fit in column - this needs more logic though type = Mode.TwoColumns; if (currentPage.currentFrame != null && currentPage.currentFrame.mode == Mode.TwoColumns) currentPage.currentFrame.bottomOffset += 2; //forceNew = false; colsize = 58; //if (currentPage.currentFrame != null) // currentPage.currentFrame.bottomOffset = 2; if (width.Length > 0 && !forceTwoColums) { colsize = (w/500) * colsize; } } else { if (width.Length > 0) { colsize = (w/800) * colsize; } } GuideFrame frame = GetTextFrame(type, FrameType.Image, forceNew); frame.AddPara("", "text", false); if (fitToPage) { newSY = frame.page.contentBounds.bottom - frame.bounds.top; newSY = newSY - 3; newSX = (newSY / sizeY) * sizeX; } // wider than column/page if (newSX > colsize) { newSX = colsize; newSY = (newSX/sizeX)*sizeY; } else if (width.Length > 0 && !fitToPage) { if (type == Mode.SingleColumn) newSX = colsize * (w / 800); else newSX = colsize * (w / 500); newSY = (newSX / sizeX) * sizeY; } // higher than page if (newSY > frame.page.contentBounds.height) { newSY = frame.page.contentBounds.height - 2; newSX = (newSY / sizeY) * sizeX; } Rectangle rect = frame.GetRect(); //Bounds newBounds = new Bounds(frame.GeometricBounds); frame.bounds.height = 300; frame.ApplyBounds(); Bounds newBounds = new Bounds(); newBounds.width = 10; newBounds.height = 10; rect.GeometricBounds = newBounds.raw; rect.FillColor = document.Swatches["None"]; if (src.ToLower().IndexOf(".jpg") > 0 || border) rect.StrokeWeight = 0.25; else rect.StrokeWeight = 0; Bounds rectBounds = newBounds.Clone(); if (type == Mode.SingleColumn) { //rectBounds.left = (currentPage.contentBounds.width - newSX) / 2; Paragraph p = (Paragraph)frame.textFrame.Paragraphs.FirstItem(); p.Justification = idJustification.idCenterAlign; } rectBounds.width = newSX; rectBounds.height = newSY; rect.GeometricBounds = rectBounds.raw; PlaceImage(filename, rect, true, crop, rotate); object img = rect.AllGraphics.FirstItem(); frame.bounds.height = newSY + 1; frame.ApplyBounds(); frame.ResizeAndPaginate(); } classes.Add("img"); }
void ProcessHeader(XmlElement node) { string intro = GetAttr(node, "intro"); string name = GetAttr(node, "name"); string sun = GetAttr(node, "sun"); string rock = GetAttr(node, "rock"); string walk = GetAttr(node, "walk"); string history = GetAttr(node, "history"); string access = GetAttr(node, "access"); string acknowledgement = GetAttr(node, "acknowledgement"); GuideFrame frame = GetTextFrame(Mode.SingleColumn, FrameType.Multi, true); frame.AddPara( name, "heading1", true); frame.bounds.top -= 4; frame.ApplyBounds(); frame.ResizeAndPaginate(); frame.bottomOffset += 2; double bottomExtra = 0; double iconTop = currentPage.GetNextTop(); bool done = false; string graphPath = GetAttachmentPath("graph.pdf"); if (File.Exists(graphPath) && this.xml.SelectNodes("//climb").Count > 0) { Bounds graphBounds = new Bounds(); graphBounds.top = iconTop; graphBounds.height = GRAPHSIZE; graphBounds.left = currentPage.contentBounds.left; graphBounds.width = GRAPHSIZE; //PlaceImageInRect( graphPath, graphBounds, true, idPDFCrop.idCropContent); PlaceImageInRect(graphPath, graphBounds, true, idPDFCrop.idCropContentAllLayers); bottomExtra = graphBounds.bottom + 3; done = true; } if (walk.Length > 0 || sun.Length > 0 || rock.Length > 0) { done = true; iconTop = DoHeaderIcon(iconTop, "walk2.pdf", walk); iconTop = DoHeaderIcon(iconTop, "sun2.pdf", sun); iconTop = DoHeaderIcon(iconTop, "rock2.pdf", rock); iconTop += 4; } if (done) { bottomExtra = Math.Max(iconTop, bottomExtra); currentPage.nextTopMin = bottomExtra; MasterSpread master = GetMaster("FP-Master"); // assume every rect needs moving Rectangles rects = master.Rectangles; foreach (Rectangle rect in rects) { Bounds b = new Bounds(rect.GeometricBounds); b.bottom = bottomExtra - 2; rect.GeometricBounds = b.raw; } } else frame.bottomOffset += 2; //DoIndentedText(walk, "Walk"); //DoIndentedText(sun, "Sun"); //DoIndentedText(rock, "Rock"); DoIndentedText(acknowledgement, "Author"); DoIndentedText(intro, "Intro"); DoIndentedText(history, "History"); DoIndentedText(access, "Access"); currentPage.frames[currentPage.frames.Count - 1].bottomOffset += 1; //currentPage.currentY += 3; }
/*private static void SetPDFCrop(object tempimg) { if (tempimg is PDF) { idPDFCrop crop = ((PDF)tempimg).PDFAttributes.PDFCrop; ((PDF)tempimg).PDFAttributes.PDFCrop = idPDFCrop.idCropTrim; } }*/ private Rectangle PlaceImageInRect(string filename, Bounds tempBounds, bool resize, idPDFCrop crop) { if (!File.Exists(filename)) { Console.WriteLine("Image " + filename + " does not exist!"); return null; } Rectangle temprect = currentPage.page.Rectangles.Add(miss, idLocationOptions.idAtEnd, miss); temprect.GeometricBounds = tempBounds.raw; temprect.StrokeWeight = 0; temprect.FillColor = document.Swatches["None"]; PlaceImage(filename, temprect, resize, crop, false); return temprect; }