Guest User

Untitled

a guest
Jul 16th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. # based on:
  4. # /System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py
  5.  
  6. from CoreFoundation import *
  7. from Quartz.CoreGraphics import *
  8.  
  9. SRC = 'Unified_Storage_Systems_Architecture.pdf'
  10. DST = '7310_architecture.pdf'
  11. PAGES = (26, 27, 28)
  12.  
  13. srcURL = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, SRC, len(SRC), False)
  14. srcDoc = CGPDFDocumentCreateWithURL(srcURL)
  15.  
  16. dstURL = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, DST, len(DST), False)
  17. dstCtx = CGPDFContextCreateWithURL(dstURL, None, None)
  18.  
  19. try:
  20. for i in PAGES:
  21. page = CGPDFDocumentGetPage(srcDoc, i)
  22. mediaBox = CGPDFPageGetBoxRect(page, kCGPDFMediaBox)
  23. CGContextBeginPage(dstCtx, mediaBox)
  24. CGContextDrawPDFPage(dstCtx, page)
  25. CGContextEndPage(dstCtx)
  26. finally:
  27. CGPDFContextClose(dstCtx)
Add Comment
Please, Sign In to add comment