Skip navigation
Currently Being Moderated

Bleed from the inserted pdf

Mar 22, 2012 12:36 PM

Rectangle. It inserted into PDF. How do you know the size of the bleed from the inserted pdf?

  • Currently Being Moderated
    Mar 22, 2012 2:48 PM   in reply to AlexeyNik

    It seems you cannot know. The only property that sounds like it's useful is pdfAttributes, but that (a) is readonly, and (b) only tells you if Crop to Bleed was used when placing the file.


    You can't even be sure if you place the same PDF page twice, once with and once without bleed, because the bleed for left, right, top and bottom can have any value -- they don't have to be the same.

    Mark as:
  • Currently Being Moderated
    Mar 24, 2012 5:01 AM   in reply to [Jongware]

    Jong, here is a function I get some mileage from… Its not pretty… Im convinced the regex stuff could be better but while it work for me I ain't looked at it too much… Values are in points so you need other functions to do UnitValue or plain Math conversion… If the PDF is Illustrator then the boxes are NOT what you would expect… ( inside out back to front the usual AI hash ) So in some cases a creator check is needed… Getting the TBLR bleeds is simple enough…



    function getPDFboxes( f ) { // Feed it the PDF file…
              var pdfBoxes = Object();
              try {
               'r' );
                        var str =;
                        var b = str.match( /BleedBox\[(\d+\.\d+\s){3}\d+\.\d+\]/g ); // All matches
                        if ( b != null ) pdfBoxes.BleedBox = b[0].match( /\d+\.\d+/g ); // Array from just the first match
                        var a = str.match( /ArtBox\[(\d+\.\d+\s){3}\d+\.\d+\]/g ); // Ditto the others
                        if ( a != null ) pdfBoxes.ArtBox = a[0].match( /\d+\.\d+/g );
                        var m = str.match( /MediaBox\[(\d+\.\d+\s){3}\d+\.\d+\]/g );
                        if ( m != null ) pdfBoxes.MediaBox = m[0].match( /\d+\.\d+/g );
                        var t = str.match( /TrimBox\[(\d+\.\d+\s){3}\d+\.\d+\]/g );
                        if ( t != null ) pdfBoxes.TrimBox = t[0].match( /\d+\.\d+/g );
                        var c = str.match( /CropBox\[(\d+\.\d+\s){3}\d+\.\d+\]/g );
                        if ( c != null ) pdfBoxes.CropBox = c[0].match( /\d+\.\d+/g );
              } catch( err ) {
              return pdfBoxes;


    Oh I forgot but should add that I generally split PDF pages it makes them easier to work with… Multi-pages and multi-sized pages has just not been worth me trying to work out…

    Mark as:
  • Currently Being Moderated
    Mar 24, 2012 12:18 PM   in reply to Muppet Mark

    I opened a PDF with TextWrangler and did a hopeful/naive search for text strings such as 'bleed', 'crop', etc. -- but you are right, every single page can have different settings! So to get the actual bleed/crop for *any* page, you have to parse the entire Pages array, which is a wonderful construction, as any set of "Pages" may include yet another complete set of "Pages", which in turn ... (etc.).


    Writing a PDF parsing library has been on my "might be worth trying" list for a while -- I can think of all sorts of interesting things one could do with it.

    Mark as:
  • Currently Being Moderated
    Mar 25, 2012 9:55 AM   in reply to [Jongware]

    @Jongware – A PDF could be "optimized". In Acrobat 9 Pro(?) and above the task to decifer the code will be near to impossible…


    You will not see any information in an "optimized" PDF like:

    /CropBox[0.0 0.0 595.0 842.0]

    /MediaBox[0.0 0.0 595.0 842.0]
    /Rotate 0

    Just tested with Acrobat 9 Pro. Created a new PDF from scratch (in Acrobat), choose "Save As / Adobe PDF files, optimized" as saving option.



    Mark as:
  • Currently Being Moderated
    Mar 26, 2012 7:37 AM   in reply to Laubender

    If you can use an external tool, I think rather than writing my own pdf parsing library I would use one of the ones already out there and freely available. See for instance pdfinfo -box in the xpdf suite. (You can tell it which page to look at or run it once per page if you need to know the sizes for every page; it looks like it reports the page box dimensions of the first page by default.)



    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points