Skip to content

Instantly share code, notes, and snippets.

@silicontrip
Created April 1, 2021 12:50
Show Gist options
  • Save silicontrip/e7a0d96093811952767dd76b17523dc8 to your computer and use it in GitHub Desktop.
Save silicontrip/e7a0d96093811952767dd76b17523dc8 to your computer and use it in GitHub Desktop.
PDF commands and arguments
# ZERO Arguments
B
b
B*
b*
BI
BT
BX
EI
EMC
ET
EX
F
f
f*
h
ID
n
Q
q
S
s
T*
W
W*
# ONE ARGUMENT
(string) ' (yes a single f..ing ' is a keyword)
/name BMC
/name CS
/name cs
/name Do
1.0 G
1.0 g
/name gs
1.0 i
1.0 J
1.0 j
1.0 M
/name MP
/name ri
/name sh
1.0 Tc
(string) Tj
[array] TJ
1.0 TL
1.0 Tr
1.0 Ts
1.0 Tw
1.0 Tz
1.0 w
# TWO
/name <<dictionary>> BDC
1.0 1.0 d
1.0 1.0 d0
/name <<dictionary>> DP
1.0 1.0 l
1.0 1.0 m
1.0 1.0 TD
1.0 1.0 Td
/name 1.0 Tf
# THREE
1.0 1.0 (string) " yes another horrible character for a keyword
1.0 1.0 1.0 RG
1.0 1.0 1.0 rg
# FOUR
1.0 1.0 1.0 1.0 K
1.0 1.0 1.0 1.0 k
1.0 1.0 1.0 1.0 re
1.0 1.0 1.0 1.0 v
1.0 1.0 1.0 1.0 y
# SIX
1.0 1.0 1.0 1.0 1.0 1.0 c
1.0 1.0 1.0 1.0 1.0 1.0 cm
1.0 1.0 1.0 1.0 1.0 1.0 d1
1.0 1.0 1.0 1.0 1.0 1.0 Tm
# VARIABLE
SC \d (1,3,4)
sc \d (1,3,4)
SCN \d (1,3,4) | /name
scn \d (1,3,4) | /name
@silicontrip
Copy link
Author

silicontrip commented Apr 1, 2021

  • Name types begin with a / eg /falcon all characters are allowed except null.
  • Dictionaries are enclosed in << and >> and are of the form << /Key value >> value can be any valid type, including names.
  • Arrays are enclosed in [ and ] and contain a list of values, each can be any type.
  • Strings are enclosed in ( and ) and use the regular escape character \ so a ( and ) can appear in a string as long as it's prefixed with \

All other types are represented as strings, eg Boolean uses true and false Integers 4096 Reals (floats) 1.234

There is also an indirect type, however these will never appear in a command stream.

@silicontrip
Copy link
Author

silicontrip commented Apr 1, 2021

I tried to find an example that had many different types. However this one uses hex strings rather than character strings This example was too large, so I deleted it.

@silicontrip
Copy link
Author

Documentation for the Foundation framework Regular Expression class: https://developer.apple.com/documentation/foundation/nsregularexpression?language=objc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment