Read Crop,Art,Trim,Bleed Box Dimensions

Read Crop,Art,Trim,Bleed Box Dimensions

Forum member · Oct 8, 2010
Currently using v6.0.2 I have the requirement to open an already existing PDF document and determine the sizes of each of the unique CropBox, ArtBox, TrimBox, and Bleedboxes. Ive been going through the documentation and using the ExtendedPageDimensions, it seems you can SET all the individual box sizes when creating a new document. However, I have been unsuccessful in figuring out how to get those dimensions for a document which already exists. The best I've been able to do is get the Page size (Height/Width), Margins, Body, Edges... That all was pretty straight forward and simple :-). Any help would be greatly appreciated. Thanks in advance.

Re: Read Crop,Art,Trim,Bleed Box Dimensions

Support · Oct 8, 2010
Hello, You can read the existing document using the MergeDocument class and read the extended dimensions of the page by casting it to ExtendedPageDimensions.This will work if you already know that the page has the extended dimensions set, otherwise the casting will fail. There is no property as such in the Page.Dimensions that will tell you if the extended page dimensions are set or not. A work around for this would be to put the casting statement in a try..catch block. MergeDocument document = new MergeDocument(@"c:\documentA.pdf"); ExtendedPageDimensions exp = (ExtendedPageDimensions)document.Pages[0].Dimensions; Dimensions art = exp.ArtBox; Please be aware that the MergeDocument class is available in the DynamicPDF Merger not in the Generator. Thanks, ceTe Software Support Team

Re: Read Crop,Art,Trim,Bleed Box Dimensions

Forum member · Oct 11, 2010
Thank you very much for the quick reply. I was able to get the required dimensions by casting the Page.Dimensions to the ExtendedPageDimensions class. I never thought of trying to do that and it works perfectly! However, I am encountering an issue with regards to the actual positioning of the said boxes. As a test I drew a Rectangle on the page over the ArtBox, BleedBox, CropBox, MediaBox, and TrimBox. My problem is that when I draw these Rectangles they all show up down and to the right of where the artwork really is on the page. The size of the rectangles seems correct however, which means the bottom-right corner is down and to the right of where I would expect it to be. Hopefully this makes sense, I can e-mail an example attachment if needed to explain more clearly. This is the code I have for actually drawing the Rectangles on the page. page4.Elements.Add(new Rectangle(ArtBox.Left, ArtBox.Top, ArtBox.Width, ArtBox.Height, RgbColor.Yellow)); page4.Elements.Add(new Rectangle(BleedBox.Left, BleedBox.Top, BleedBox.Width, BleedBox.Height, RgbColor.Red)); page4.Elements.Add(new Rectangle(CropBox.Left, CropBox.Top, CropBox.Width, CropBox.Height, RgbColor.Black)); page4.Elements.Add(new Rectangle(MediaBox.Left, MediaBox.Top, MediaBox.Width, MediaBox.Height, RgbColor.Fuchsia)); page4.Elements.Add(new Rectangle(TrimBox.Left, TrimBox.Top, TrimBox.Width, TrimBox.Height, RgbColor.HotPink)); I suspected that the Rectangles may not be 100% perfect because I could not tell if the border size is drawn inside or outside of the extents of the Rectangle. So they may be 2pix larger. But in my test they are showing up about .25in low and .125in right of the top-left corner. Below were the Dimension sizes for each of the Boxes: ArtBox Height: 648 ArtBox Width: 288 ArtBox Top: 39 ArtBox Bottom: 687 ArtBox Left: 21 ArtBox Right: 309 BleedBox Height: 666 BleedBox Width: 306 BleedBox Top: 30 BleedBox Bottom: 696 BleedBox Left: 12 BleedBox Right: 318 CropBox Height: 708 CropBox Width: 330 CropBox Top: 0 CropBox Bottom: 708 CropBox Left: 0 CropBox Right: 330 MediaBox Height: 708 MediaBox Width: 330 MediaBox Top: 0 MediaBox Bottom: 708 MediaBox Left: 0 MediaBox Right: 330 TrimBox Height: 648 TrimBox Width: 288 TrimBox Top: 39 TrimBox Bottom: 687 TrimBox Left: 21 TrimBox Right: 309 Page Height: 708 Page Width: 330 Page Top Margin: 39 Page Bottom Margin: 21 Page Left Margin: 21 Page Right Margin: 21 Page Edge - Top: 0 Page Edge - Bottom: 708 Page Edge - Left: 0 Page Edge - Right: 330 Page Edge Height: 708 Page Edge Width: 330 Page Body - Top: 39 Page Body - Bottom: 687 Page Body - Left: 21 Page Body - Right: 309 Page Body Height: 648 Page Body Width: 288

Re: Read Crop,Art,Trim,Bleed Box Dimensions

Forum member · Oct 11, 2010
Oh, and I apologize for placing this in the wrong forum. If possible, could an admin place this in the DynamicPDF Merger for .NET (v5.x) forum where it belongs. Thanks, -Jeremy

Re: Read Crop,Art,Trim,Bleed Box Dimensions

Support · Oct 11, 2010
Hello, Please email the example document and sample code to [^a|mailto:support@cete.com|opennewiwndow|Support Team^] so we can get a better idea. Thanks, ceTe Software Support Team.

Re: Read Crop,Art,Trim,Bleed Box Dimensions

Forum member · Oct 11, 2010
E-mail message sent. Thanks, -Jeremy

Re: Read Crop,Art,Trim,Bleed Box Dimensions

Support · Oct 13, 2010
Hello, When considering the Crop, Art, Trim & Bleed boxes, they are considered with respect to the top and left edges of the document. Where as when you add the page elements they are added with respect to the top and left margin of the document. Thanks, ceTe Software Support Team