CGPDFContext.pas 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. { CoreGraphics - CGPDFContext.h
  2. * Copyright (c) 2000-2004 Apple Computer, Inc.
  3. * All rights reserved.
  4. }
  5. { Pascal Translation: Peter N Lewis, <[email protected]>, August 2005 }
  6. {
  7. Modified for use with Free Pascal
  8. Version 200
  9. Please report any bugs to <[email protected]>
  10. }
  11. {$mode macpas}
  12. {$packenum 1}
  13. {$macro on}
  14. {$inline on}
  15. {$CALLING MWPASCAL}
  16. unit CGPDFContext;
  17. interface
  18. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  19. {$setc GAP_INTERFACES_VERSION := $0200}
  20. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  21. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  22. {$endc}
  23. {$ifc defined CPUPOWERPC and defined CPUI386}
  24. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  25. {$endc}
  26. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  27. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  28. {$endc}
  29. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  30. {$setc __ppc__ := 1}
  31. {$elsec}
  32. {$setc __ppc__ := 0}
  33. {$endc}
  34. {$ifc not defined __i386__ and defined CPUI386}
  35. {$setc __i386__ := 1}
  36. {$elsec}
  37. {$setc __i386__ := 0}
  38. {$endc}
  39. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  40. {$error Conflicting definitions for __ppc__ and __i386__}
  41. {$endc}
  42. {$ifc defined __ppc__ and __ppc__}
  43. {$setc TARGET_CPU_PPC := TRUE}
  44. {$setc TARGET_CPU_X86 := FALSE}
  45. {$elifc defined __i386__ and __i386__}
  46. {$setc TARGET_CPU_PPC := FALSE}
  47. {$setc TARGET_CPU_X86 := TRUE}
  48. {$elsec}
  49. {$error Neither __ppc__ nor __i386__ is defined.}
  50. {$endc}
  51. {$setc TARGET_CPU_PPC_64 := FALSE}
  52. {$ifc defined FPC_BIG_ENDIAN}
  53. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  54. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  55. {$elifc defined FPC_LITTLE_ENDIAN}
  56. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  57. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  58. {$elsec}
  59. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  60. {$endc}
  61. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  62. {$setc CALL_NOT_IN_CARBON := FALSE}
  63. {$setc OLDROUTINENAMES := FALSE}
  64. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  65. {$setc OPAQUE_UPP_TYPES := TRUE}
  66. {$setc OTCARBONAPPLICATION := TRUE}
  67. {$setc OTKERNEL := FALSE}
  68. {$setc PM_USE_SESSION_APIS := TRUE}
  69. {$setc TARGET_API_MAC_CARBON := TRUE}
  70. {$setc TARGET_API_MAC_OS8 := FALSE}
  71. {$setc TARGET_API_MAC_OSX := TRUE}
  72. {$setc TARGET_CARBON := TRUE}
  73. {$setc TARGET_CPU_68K := FALSE}
  74. {$setc TARGET_CPU_MIPS := FALSE}
  75. {$setc TARGET_CPU_SPARC := FALSE}
  76. {$setc TARGET_OS_MAC := TRUE}
  77. {$setc TARGET_OS_UNIX := FALSE}
  78. {$setc TARGET_OS_WIN32 := FALSE}
  79. {$setc TARGET_RT_MAC_68881 := FALSE}
  80. {$setc TARGET_RT_MAC_CFM := FALSE}
  81. {$setc TARGET_RT_MAC_MACHO := TRUE}
  82. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  83. {$setc TYPE_BOOL := FALSE}
  84. {$setc TYPE_EXTENDED := FALSE}
  85. {$setc TYPE_LONGLONG := TRUE}
  86. uses MacTypes,CGGeometry,CFBase,CFDictionary,CFURL,CGBase,CGContext,CGDataConsumer;
  87. {$ALIGN POWER}
  88. { Create a PDF context, using `consumer' for output. `mediaBox' is the
  89. * default page media bounding box; if NULL, then a default page size is
  90. * used. `auxiliaryInfo' specifies additional information used by the PDF
  91. * context when generating the PDF file. The keys and values in
  92. * `auxiliaryInfo' are described below. If `mediaBox' is non-NULL, then its
  93. * value overrides the value of `kCGPDFContextMediaBox' if specified in the
  94. * `auxiliaryInfo' dictionary. }
  95. function CGPDFContextCreate( consumer: CGDataConsumerRef; const (*var*) mediaBox: CGRect; auxiliaryInfo: CFDictionaryRef ): CGContextRef; external name '_CGPDFContextCreate';
  96. { Create a PDF context for writing to `url'. This function behaves in the
  97. * same manner as the above function, except that the output data will be
  98. * written to `url'. }
  99. function CGPDFContextCreateWithURL( url: CFURLRef; const (*var*) mediaBox: CGRect; auxiliaryInfo: CFDictionaryRef ): CGContextRef; external name '_CGPDFContextCreateWithURL';
  100. { Begin a new page in the PDF context `context'. }
  101. procedure CGPDFContextBeginPage( context: CGContextRef; pageInfo: CFDictionaryRef ); external name '_CGPDFContextBeginPage'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  102. { End the current page in the PDF context `context'. }
  103. procedure CGPDFContextEndPage( context: CGContextRef ); external name '_CGPDFContextEndPage'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  104. { Set the URL associated with `rect' to `url' in the PDF context
  105. * `context'. }
  106. procedure CGPDFContextSetURLForRect( context: CGContextRef; url: CFURLRef; rect: CGRect ); external name '_CGPDFContextSetURLForRect'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  107. { Create a PDF destination named `name' at `point' in the current page of
  108. * the PDF context `context'. }
  109. procedure CGPDFContextAddDestinationAtPoint( context: CGContextRef; name: CFStringRef; point: CGPoint ); external name '_CGPDFContextAddDestinationAtPoint'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  110. { Specify a destination named `name' to jump to when clicking in `rect' of
  111. * the current page of the PDF context `context'. }
  112. procedure CGPDFContextSetDestinationForRect( context: CGContextRef; name: CFStringRef; rect: CGRect ); external name '_CGPDFContextSetDestinationForRect'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  113. {** Keys for the auxiliary info dictionary or the page info dictionary. **}
  114. { The media box for the document or for a given page. Optional; if
  115. * present, the value of this key must be a CFData containing a CGRect
  116. * (stored by value, not by reference). }
  117. var kCGPDFContextMediaBox: CFStringRef; external name '_kCGPDFContextMediaBox'; (* attribute const *) (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  118. { The crop box for the document or for a given page. Optional; if present,
  119. * the value of this key must be a CFData containing a CGRect (stored by
  120. * value, not by reference). }
  121. var kCGPDFContextCropBox: CFStringRef; external name '_kCGPDFContextCropBox'; (* attribute const *) (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  122. { The bleed box for the document or for a given page. Optional; if
  123. * present, the value of this key must be a CFData containing a CGRect
  124. * (stored by value, not by reference). }
  125. var kCGPDFContextBleedBox: CFStringRef; external name '_kCGPDFContextBleedBox'; (* attribute const *) (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  126. { The trim box for the document or for a given page. Optional; if present,
  127. * the value of this key must be a CFData containing a CGRect (stored by
  128. * value, not by reference). }
  129. var kCGPDFContextTrimBox: CFStringRef; external name '_kCGPDFContextTrimBox'; (* attribute const *) (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  130. { The art box for the document or for a given page. Optional; if present,
  131. * the value of this key must be a CFData containing a CGRect (stored by
  132. * value, not by reference). }
  133. var kCGPDFContextArtBox: CFStringRef; external name '_kCGPDFContextArtBox'; (* attribute const *) (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  134. {** Keys for auxiliary info dictionary. **}
  135. { The document's title. Optional; if present, the value of this key must
  136. * be a CFString. }
  137. // const kCGPDFContextTitle: CFStringRef; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  138. { The name of the person who created this document. Optional; if present,
  139. * the value of this key must be a CFString. }
  140. // const kCGPDFContextAuthor: CFStringRef; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  141. { The name of the application that created the original data used to
  142. * create this document. Optional; if present, the value of this key must
  143. * be a CFString. }
  144. // const kCGPDFContextCreator: CFStringRef; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  145. { The "owner password" of the PDF document. If this key is specified, the
  146. * document will be encrypted using the value as the owner password;
  147. * otherwise, the document will not be encrypted. The value of this key
  148. * must be a CFStringRef which can be represented in ASCII encoding; only
  149. * the first 32 bytes will be used for the password. There is no default
  150. * value for this key.
  151. *
  152. * If the value of this key cannot be represented in ASCII, the document
  153. * will not be created and the creation function will return NULL. }
  154. var kCGPDFContextOwnerPassword: CFStringRef; external name '_kCGPDFContextOwnerPassword'; (* attribute const *) (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  155. { The "user password" of the PDF document. If the document is encrypted,
  156. * then the value of this key will be the user password for the document;
  157. * if unspecified, the user password will be the empty string. The value of
  158. * this key must be a CFStringRef which can be represented in ASCII
  159. * encoding; only the first 32 bytes will be used for the password.
  160. *
  161. * If the value of this key cannot be represented in ASCII, the document
  162. * will not be created and the creation function will return NULL. }
  163. var kCGPDFContextUserPassword: CFStringRef; external name '_kCGPDFContextUserPassword'; (* attribute const *) (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  164. { Used to specify whether the document allows printing when unlocked with
  165. * the user password. The value of this key must be a CFBooleanRef. The
  166. * default value of this key is "kCFBooleanTrue". }
  167. var kCGPDFContextAllowsPrinting: CFStringRef; external name '_kCGPDFContextAllowsPrinting'; (* attribute const *) (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  168. { Used to specify whether the document allows copying when unlocked with
  169. * the user password. The value of this key must be a CFBooleanRef. The
  170. * default value of this key is "kCFBooleanTrue". }
  171. var kCGPDFContextAllowsCopying: CFStringRef; external name '_kCGPDFContextAllowsCopying'; (* attribute const *) (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  172. { The document's PDF/X output intent. Optional; if present, the value of
  173. * this key must be a CFDictionaryRef. The dictionary is added to the
  174. * /OutputIntents entry in the PDF file's document catalog. The keys and
  175. * values contained in the dictionary must match those specified in section
  176. * 9.10.4 of the PDF 1.4 specification, ISO/DIS 15930-3 document published
  177. * by ISO/TC 130, and Adobe Technical Note #5413. }
  178. // const kCGPDFContextOutputIntent: CFStringRef; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  179. { The following keys are supported in the output intent dictionary:
  180. *
  181. * kCGPDFXOutputIntentSubtype ("S") - The output intent subtype. This key
  182. * is required; the value of this key must be a CFString equal to
  183. * "GTS_PDFX"; otherwise, the dictionary is ignored. }
  184. var kCGPDFXOutputIntentSubtype: CFStringRef; external name '_kCGPDFXOutputIntentSubtype'; (* attribute const *) (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  185. { kCGPDFXOutputConditionIdentifier ("OutputConditionIdentifier") - A
  186. * string identifying the intended output device or production condition
  187. * in a human- or machine-readable form. This key is required; the
  188. * value of this key must be a CFString. For best results, the string
  189. * should be representable losslessly in ASCII encoding. }
  190. var kCGPDFXOutputConditionIdentifier: CFStringRef; external name '_kCGPDFXOutputConditionIdentifier'; (* attribute const *) (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  191. { kCGPDFXOutputCondition ("OutputCondition") - A text string identifying
  192. * the intended output device or production condition in a human-
  193. * readable form. This key is optional; if present, the value of this
  194. * key must be a CFString. }
  195. var kCGPDFXOutputCondition: CFStringRef; external name '_kCGPDFXOutputCondition'; (* attribute const *) (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  196. { kCGPDFXRegistryName ("RegistryName") - A string identifying the registry
  197. * in which the condition designated by kCGPDFXOutputConditionIdentifier
  198. * is defined. This key is optional; if present, the value of this key
  199. * must be a CFString. For best results, the string should be
  200. * representable losslessly in ASCII encoding. }
  201. var kCGPDFXRegistryName: CFStringRef; external name '_kCGPDFXRegistryName'; (* attribute const *) (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  202. { kCGPDFXInfo ("Info") - A human-readable text string containing
  203. * additional information or comments about the intended target device
  204. * or production condition. This key is required if the value of
  205. * kCGPDFXOutputConditionIdentifier does not specify a standard
  206. * production condition; it is optional otherwise. If present, the
  207. * value of this key must be a CFString. }
  208. var kCGPDFXInfo: CFStringRef; external name '_kCGPDFXInfo'; (* attribute const *) (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  209. { kCGPDFXDestinationOutputProfile ("DestOutputProfile") - An ICC profile
  210. * stream defining the transformation from the PDF document's source
  211. * colors to output device colorants. This key is required if the value
  212. * of kCGPDFXOutputConditionIdentifier does not specify a standard
  213. * production condition; it is optional otherwise. If present, the
  214. * value of this key must be a ICC-based CGColorSpaceRef. }
  215. var kCGPDFXDestinationOutputProfile: CFStringRef; external name '_kCGPDFXDestinationOutputProfile'; (* attribute const *) (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  216. { The document's output intents. Optional; if present, the value must be a
  217. * CFArrayRef containing one or more CFDictionaryRefs. The array is added
  218. * to the PDF document in the /OutputIntents entry in the PDF file's
  219. * document catalog. Each dictionary in the array must be of form
  220. * specified above for the "kCGPDFContextOutputIntent" key, except that
  221. * only the first dictionary in the array may contain the
  222. * kCGPDFXOutputIntentSubtype ("S") key with a value of "GTS_PDFX". If both
  223. * the "kCGPDFContextOutputIntent" and "kCGPDFContextOutputIntents" keys
  224. * are specified, the former is ignored. }
  225. // const kCGPDFContextOutputIntents: CFStringRef; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  226. { Compatibility with earlier versions of Mac OS X. }
  227. // #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4
  228. {
  229. PNL comments:
  230. There is an issue here that these types below are macro defines, and they
  231. conflict with the definitions above unless only one or the other is defined.
  232. This only applies to GPC where GPCMacros.inc contains the macros and
  233. is typically read before this Pascal source file.
  234. }
  235. {$ifc USE_CFSTR_CONSTANT_MACROS}
  236. {$definec kCGPDFContextTitle CFSTRP('kCGPDFContextTitle')}
  237. {$endc}
  238. {$ifc USE_CFSTR_CONSTANT_MACROS}
  239. {$definec kCGPDFContextAuthor CFSTRP('kCGPDFContextAuthor')}
  240. {$endc}
  241. {$ifc USE_CFSTR_CONSTANT_MACROS}
  242. {$definec kCGPDFContextCreator CFSTRP('kCGPDFContextCreator')}
  243. {$endc}
  244. {$ifc USE_CFSTR_CONSTANT_MACROS}
  245. {$definec kCGPDFContextOutputIntent CFSTRP('kCGPDFContextOutputIntent')}
  246. {$endc}
  247. {$ifc USE_CFSTR_CONSTANT_MACROS}
  248. {$definec kCGPDFContextOutputIntents CFSTRP('kCGPDFContextOutputIntents')}
  249. {$endc}
  250. // #endif { MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4 }
  251. end.