|
Don't know if it's still interesting for you, but I had the same problem in here - adding a trimbox and cropmarks after the content has been drawn before. My solution (C#): Let' suppose, the variable trimBoxInches holds the width of the trim box iterate through the pages, add a new page for every page and capture the (first) page (which removes it, so the next page is always the first): IDictionary<int, int> pageIds = new Dictionary<int, int>(); int nrOfPages = this.Library.PageCount(); for (int page = 1; page <= nrOfPages; page++) { this.Library.NewPage(); this.Library.SelectPage(1); int pageId = this.Library.CapturePage(1); pageIds.Add(page, pageId); }
Afterwards you can calculate the new dimensions of your pages and resize them: double pageWidth = this.Library.PageWidth(); double pageHeight = this.Library.PageHeight(); double newPageWidth = pageWidth + 2 * trimBoxInches; double newPageHeight = pageHeight + 2 * trimBoxInches; this.Library.SetPageDimensions(newPageWidth, newPageHeight); After this the captured pages can be redrawn again: foreach (KeyValuePair<int, int> entry in pageIds) { int pageNr = entry.Key; int pageId = entry.Value; this.Library.SelectPage(pageNr); this.Library.DrawCapturedPage(pageId, trimBoxInches, trimBoxInches + pageHeight, pageWidth, pageHeight);
double trimBoxLength = trimBoxInches; // eventually you want to make the lines a little bit shorter here // prepare drawing this.Library.SetLineColorCMYK(0, 0, 0, 1); this.Library.SetLineWidth(...); // set the width of your cropmarks here // bottom left corner this.Library.DrawLine(0, trimBoxInches, trimBoxLength, trimBoxInches); this.Library.DrawLine(trimBoxInches, 0, trimBoxInches, trimBoxLength); // bottom right corner this.Library.DrawLine(newPageWidth, trimBoxInches, newPageWidth - trimBoxLength, trimBoxInches); this.Library.DrawLine(newPageWidth - trimBoxInches, 0, newPageWidth - trimBoxInches, trimBoxLength); // top right corner this.Library.DrawLine(newPageWidth, newPageHeight - trimBoxInches, newPageWidth - trimBoxLength, newPageHeight - trimBoxInches); this.Library.DrawLine(newPageWidth - trimBoxInches, newPageHeight, newPageWidth - trimBoxInches, newPageHeight - trimBoxLength); // top left corner this.Library.DrawLine(0, newPageHeight - trimBoxInches, trimBoxLength, newPageHeight - trimBoxInches); this.Library.DrawLine(trimBoxInches, newPageHeight, trimBoxInches, newPageHeight - trimBoxLength); } And, of course, you want to add a trimbox for the print office: this.Library.SetPageBox(4, trimBoxInches, trimBoxInches, pageWidth, pageHeight); Hth, Martin
|