-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcpdflibwrapper.h
1844 lines (1488 loc) · 61.3 KB
/
cpdflibwrapper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* A C wrapper to cpdf PDF tools library. Free for non-commercial use. See
* LICENSE for details. To purchase a license, please visit
* http://www.coherentpdf.com/
*
* Text arguments and results are in UTF8.
*/
/* CHAPTER 0. Preliminaries */
/* The function cpdf_startup(argv) must be called before using the library. */
void cpdf_startup(char **);
/* Return the version of the cpdflib library as a string */
char *cpdf_version();
/*
* Some operations have a fast mode. The default is 'slow' mode, which works
* even on old-fashioned files. For more details, see section 1.13 of the
* CPDF manual. These functions set the mode globally.
*/
void cpdf_setFast();
void cpdf_setSlow();
/* Calling this function with a true argument sets embedding for the Standard
* 14 fonts. You must also set the directory to load them from with the
* cpdf_embedStd14Dir function. Default value: false. */
void cpdf_embedStd14(int);
/* Set the directory to load Standard 14 fonts for embedding. */
void cpdf_embedStd14Dir(char *);
/*
* Errors. cpdf_lastError and cpdf_lastErrorString hold information about the
* last error to have occurred. They should be consulted after each call. If
* cpdf_lastError is non-zero, there was an error, and cpdf_lastErrorString
* gives details. If cpdf_lastError is zero, there was no error on the most
* recent cpdf call.
*/
extern int cpdf_lastError;
extern char *cpdf_lastErrorString;
/* In some contexts, for example, .NET or JNI, constants in DLLs can be
* difficult or impossible to access. We provide functions in addition. */
int cpdf_fLastError(void);
char *cpdf_fLastErrorString(void);
/* cpdf_clearError clears the current error state. */
void cpdf_clearError(void);
/*
* cpdf_onExit is a debug function which prints some information about
* resource usage. This can be used to detect if PDFs or ranges are being
* deallocated properly. Contrary to its name, it may be run at any time.
*/
void cpdf_onExit(void);
/* CHAPTER 1. Basics */
/*
* cpdf_fromFile(filename, userpw) loads a PDF file from a given file. Supply
* a user password (possibly blank) in case the file is encrypted. It won't be
* decrypted, but sometimes the password is needed just to load the file.
*/
int cpdf_fromFile(const char[], const char[]);
/*
* cpdf_fromFileLazy(pdf, userpw) loads a PDF from a file, doing only minimal
* parsing. The objects will be read and parsed when they are actually
* needed. Use this when the whole file won't be required. Also supply a user
* password (possibly blank) in case the file is encrypted. It won't be
* decrypted, but sometimes the password is needed just to load the file.
*/
int cpdf_fromFileLazy(const char[], const char[]);
/*
* cpdf_fromMemory(data, length, userpw) loads a file from memory, given a
* pointer and a length, and the user password.
*/
int cpdf_fromMemory(void *, int, const char[]);
/*
* cpdf_fromMemory(data, length, userpw) loads a file from memory, given a
* pointer and a length, and the user password, but lazily like
* cpdf_fromFileLazy.
*/
int cpdf_fromMemoryLazy(void *, int, const char[]);
/* Remove a PDF from memory, given its number. */
void cpdf_deletePdf(int);
/*
* Calling cpdf_replacePdf(a, b) places PDF b under number a. Number b is no
* longer available.
*/
void cpdf_replacePdf(int, int);
/*
* To enumerate the list of currently allocated PDFs, call
* cpdf_startEnumeratePDFs which gives the number, n, of PDFs allocated, then
* cpdf_enumeratePDFsInfo and cpdf_enumeratePDFsKey with index numbers from
* 0...(n - 1). Call cpdf_endEnumeratePDFs to clean up.
*/
int cpdf_startEnumeratePDFs(void);
int cpdf_enumeratePDFsKey(int);
char *cpdf_enumeratePDFsInfo(int);
void cpdf_endEnumeratePDFs(void);
/* Convert a figure in centimetres to points (72 points to 1 inch) */
double cpdf_ptOfCm(double);
/* Convert a figure in millimetres to points (72 points to 1 inch) */
double cpdf_ptOfMm(double);
/* Convert a figure in inches to points (72 points to 1 inch) */
double cpdf_ptOfIn(double);
/* Convert a figure in points to centimetres (72 points to 1 inch) */
double cpdf_cmOfPt(double);
/* Convert a figure in points to millimetres (72 points to 1 inch) */
double cpdf_mmOfPt(double);
/* Convert a figure in points to inches (72 points to 1 inch) */
double cpdf_inOfPt(double);
/*
* A page range is a list of page numbers used to restrict operations to
* certain pages. A page specification is a textual description of a page
* range, such as "1-12,18-end". Here is the syntax:
*
* o A range must contain no spaces.
*
* o A dash (-) defines ranges, e.g. 1-5 or 6-3.
*
* o A comma (,) allows one to specify several ranges, e.g. 1-2,4-5.
*
* o The word end represents the last page number.
*
* o The words odd and even can be used in place of or at the end of a page
* range to restrict to just the odd or even pages.
*
* o The words portrait and landscape can be used in place of or at the end of
* a page range to restrict to just those pages which are portrait or
* landscape. Note that the meaning of "portrait" and "landscape" does not
* take account of any viewing rotation in place (use cpdf_upright first, if
* required). A page with equal width and height is considered neither
* portrait nor landscape.
*
* o The word reverse is the same as end-1.
*
* o The word all is the same as 1-end.
*
* o A tilde (~) defines a page number counting from the end of the document
* rather than the beginning. Page ~1 is the last page, ~2 the penultimate
* page etc.
*/
/*
* cpdf_parsePagespec(pdf, range) parses a page specification with reference
* to a given PDF (the PDF is supplied so that page ranges which reference
* pages which do not exist are rejected).
*/
int cpdf_parsePagespec(int, const char[]);
/*
* cpdf_validatePagespec(range) validates a page specification so far as is
* possible in the absence of the actual document. Result is true if valid.
*/
int cpdf_validatePagespec(const char[]);
/*
* cpdf_stringOfPagespec(pdf, range) builds a page specification from a page
* range. For example, the range containing 1,2,3,6,7,8 in a document of 8
* pages might yield "1-3,6-end"
*/
char *cpdf_stringOfPagespec(int, int);
/* cpdf_blankRange() creates a range with no pages in. */
int cpdf_blankRange(void);
/* cpdf_deleteRange(range) deletes a range. */
void cpdf_deleteRange(int);
/*
* cpdf_range(from, to) builds a range from one page to another inclusive. For
* example, cpdf_range(3,7) gives the range 3,4,5,6,7
*/
int cpdf_range(int, int);
/* cpdf_all(pdf) is the range containing all the pages in a given document. */
int cpdf_all(int);
/*
* cpdf_even(range) makes a range which contains just the even pages of
* another range.
*/
int cpdf_even(int);
/*
* cpdf_odd(range) makes a range which contains just the odd pages of another
* range.
*/
int cpdf_odd(int);
/*
* cpdf_rangeUnion(a, b) makes the union of two ranges giving a range
* containing the pages in range a and range b.
*/
int cpdf_rangeUnion(int, int);
/*
* cpdf_difference(a, b) makes the difference of two ranges, giving a range
* containing all the pages in a except for those which are also in b.
*/
int cpdf_difference(int, int);
/* cpdf_removeDuplicates(range) deduplicates a range, making a new one. */
int cpdf_removeDuplicates(int);
/* cpdf_rangeLength gives the number of pages in a range. */
int cpdf_rangeLength(int);
/*
* cpdf_rangeGet(range, n) gets the page number at position n in a range,
* where n runs from 0 to rangeLength - 1.
*/
int cpdf_rangeGet(int, int);
/*
* cpdf_rangeAdd(range, page) adds the page to a range, if it is not already
* there.
*/
int cpdf_rangeAdd(int, int);
/*
* cpdf_isInRange(range, page) returns true if the page is in the range,
* false otherwise.
*/
int cpdf_isInRange(int, int);
/* cpdf_pages(pdf) returns the number of pages in a PDF. */
int cpdf_pages(int);
/*
* cpdf_pagesFast(password, filename) returns the number of pages in a given
* PDF, with given user encryption password. It tries to do this as fast as
* possible, without loading the whole file.
*/
int cpdf_pagesFast(const char[], const char[]);
/*
* cpdf_toFile (pdf, filename, linearize, make_id) writes the file to a given
* filename. If linearize is true, it will be linearized if a linearizer is
* available. If make_id is true, it will be given a new ID.
*
* NB: Unlike with the command line tool, cpdf, streams decompressed during
* processing will not automatically be compressed when writing. Call
* cpdf_compress() first.
*/
void cpdf_toFile(int, const char[], int, int);
/*
* cpdf_toFileExt (pdf, filename, linearize, make_id, preserve_objstm,
* generate_objstm, compress_objstm) writes the file to a given filename. If
* make_id is true, it will be given a new ID. If preserve_objstm is true,
* existing object streams will be preserved. If generate_objstm is true,
* object streams will be generated even if not originally present. If
* compress_objstm is true, object streams will be compressed (what we
* usually want). WARNING: the pdf argument will be invalid after this call,
* and should be discarded.
*/
void cpdf_toFileExt(int, const char[], int, int, int, int, int);
/*
* cpdf_toFileMemory (pdf, linearize, make_id, sizse) writes a PDF file it
* and returns the buffer. The buffer length is filled in.
*
* NB: Unlike with the command line tool, cpdf, streams decompressed during
* processing will not automatically be compressed when writing. Call
* cpdf_compress() first.
*/
void *cpdf_toMemory(int, int, int, int *);
/*
* cpdf_isEncrypted(pdf) returns true if a documented is encrypted, false
* otherwise.
*/
int cpdf_isEncrypted(int);
/*
* cpdf_decryptPdf(pdf, userpw) attempts to decrypt a PDF using the given
* user password. The error code is non-zero if the decryption fails.
*/
void cpdf_decryptPdf(int, const char[]);
/*
* cpdf_decryptPdfOwner(pdf, ownerpw) attempts to decrypt a PDF using the
* given owner password. The error code is non-zero if the decryption fails.
*/
void cpdf_decryptPdfOwner(int, const char[]);
/*
* File permissions. These are inverted, in the sense that the presence of
* one of them indicates a restriction.
*/
enum cpdf_permission {
cpdf_noEdit, /* Cannot edit the document */
cpdf_noPrint, /* Cannot print the document */
cpdf_noCopy, /* Cannot copy the document */
cpdf_noAnnot, /* Cannot annotate the document */
cpdf_noForms, /* Cannot edit forms in the document */
cpdf_noExtract, /* Cannot extract information */
cpdf_noAssemble, /* Cannot assemble into a bigger document */
cpdf_noHqPrint /* Cannot print high quality */
};
/*
* Encryption methods. Suffixes 'false' and 'true' indicates lack of or
* presence of encryption for XMP metadata streams.
*/
enum cpdf_encryptionMethod {
cpdf_pdf40bit, /* 40 bit RC4 encryption */
cpdf_pdf128bit, /* 128 bit RC4 encryption */
cpdf_aes128bitfalse, /* 128 bit AES encryption, do not encrypt
* metadata. */
cpdf_aes128bittrue, /* 128 bit AES encryption, encrypt metadata */
cpdf_aes256bitfalse, /* Deprecated. Do not use for new files */
cpdf_aes256bittrue, /* Deprecated. Do not use for new files */
cpdf_aes256bitisofalse, /* 256 bit AES encryption, do not encrypt
* metadata. */
cpdf_aes256bitisotrue /* 256 bit AES encryption, encrypt metadata */
};
/*
* cpdf_toFileEncrypted(pdf, encryption_method, permissions,
* permission_length, owner_password, user password, linearize, makeid,
* filename) writes a file as encrypted.
*/
void cpdf_toFileEncrypted(int, int, int *, int, const char[], const char[], int,
int, const char[]);
/*
* cpdf_toFileEncryptedExt(pdf, encryption_method, permissions,
* permission_length, owner_password, user_password, linearize, makeid,
* preserve_objstm, generate_objstm, compress_objstm, filename) WARNING: the
* pdf argument will be invalid after this call, and should be discarded.
*/
void cpdf_toFileEncryptedExt(int, int, int *, int, const char[], const char[],
int, int, int, int, int, const char[]);
/*
* cpdf_hasPermission(pdf, permission) returns true if the given permission
* (restriction) is present.
*/
int cpdf_hasPermission(int, enum cpdf_permission);
/*
* cpdf_encryptionKind(pdf) return the encryption method currently in use on
* a document.
*/
enum cpdf_encryptionMethod cpdf_encryptionKind(int);
/* cpdf_loadFont(name, filename) loads a TrueType font from the given file
* name, and names it. It may then be used when adding text or drawing, using
* the name in place of a standard font name. */
void cpdf_loadFont(char *, char *);
/* CHAPTER 2. Merging and Splitting */
/*
* cpdf_mergeSimple(pdfs, length) given an array of PDFs, and its length,
* merges the files into a new one, which is returned.
*/
int cpdf_mergeSimple(int *, int);
/*
* cpdf_merge(pdfs, len, retain_numbering, remove_duplicate_fonts) merges the
* PDFs. If retain_numbering is true page labels are not rewritten. If
* remove_duplicate_fonts is true, duplicate fonts are merged. This is useful
* when the source documents for merging originate from the same source.
*/
int cpdf_merge(int *, int, int, int);
/*
* cpdf_mergeSame(pdfs, len, retain_numbering, remove_duplicate_fonts,
* ranges) is the same as cpdf_merge, except that it has an additional
* argument - an array of page ranges. This is used to select the pages to
* pick from each PDF. This avoids duplication of information when multiple
* discrete parts of a source PDF are included.
*/
int cpdf_mergeSame(int *, int, int, int, int *);
/*
* cpdf_selectPages(pdf, range) returns a new document which just those pages
* in the page range.
*/
int cpdf_selectPages(int, int);
/* CHAPTER 3. Pages */
/*
* cpdf_scalePages(pdf, range, x scale, y scale) scales the page dimensions
* and content by the given scale, about (0, 0). Other boxes (crop etc. are
* altered as appropriate)
*/
void cpdf_scalePages(int, int, double, double);
/*
* cpdf_scaleToFit(pdf, range, width, height, scale) scales the content to fit
* new page dimensions (width x height) multiplied by scale (typically 1.0).
* Other boxes (crop etc. are altered as appropriate)
*/
void cpdf_scaleToFit(int, int, double, double, double);
/* Standard page sizes. */
enum cpdf_papersize {
cpdf_a0portrait, /* A0 portrait */
cpdf_a1portrait, /* A1 portrait */
cpdf_a2portrait, /* A2 portrait */
cpdf_a3portrait, /* A3 portrait */
cpdf_a4portrait, /* A4 portrait */
cpdf_a5portrait, /* A5 portrait */
cpdf_a0landscape, /* A0 landscape */
cpdf_a1landscape, /* A1 landscape */
cpdf_a2landscape, /* A2 landscape */
cpdf_a3landscape, /* A3 landscape */
cpdf_a4landscape, /* A4 landscape */
cpdf_a5landscape, /* A5 landscape */
cpdf_usletterportrait, /* US Letter portrait */
cpdf_usletterlandscape, /* US Letter landscape */
cpdf_uslegalportrait, /* US Legal portrait */
cpdf_uslegallandscape /* US Legal landscape */
};
/*
* cpdf_scaleToFitPaper(pdf, range, papersize, scale) scales the page content
* to fit the given page size, possibly multiplied by scale (typically 1.0)
*/
void cpdf_scaleToFitPaper(int, int, enum cpdf_papersize, double);
/* Positions on the page. Used for scaling about a point, and adding text. */
enum cpdf_anchor {
cpdf_posCentre, /* Absolute centre */
cpdf_posLeft, /* Absolute left */
cpdf_posRight, /* Absolute right */
cpdf_top, /* Top top centre of the page */
cpdf_topLeft, /* The top left of the page */
cpdf_topRight, /* The top right of the page */
cpdf_left, /* The left hand side of the page, halfway
* down */
cpdf_bottomLeft, /* The bottom left of the page */
cpdf_bottom, /* The bottom middle of the page */
cpdf_bottomRight, /* The bottom right of the page */
cpdf_right, /* The right hand side of the page, halfway
* down */
cpdf_diagonal, /* Diagonal, bottom left to top right */
cpdf_reverseDiagonal /* Diagonal, top left to bottom right */
};
/*
* A cpdf_position is an anchor (above) and zero or one or two parameters
* (cpdf_coord1, cpdf_coord2).
*
* cpdf_posCentre: Two parameters, x and y
*
* cpdf_posLeft: Two parameters, x and y
*
* cpdf_posRight: Two parameters, x and y
*
* cpdf_top: One parameter -- distance from top
*
* cpdf_topLeft: One parameter -- distance from top left
*
* cpdf_topRight: One parameter -- distance from top right
*
* cpdf_left: One parameter -- distance from left middle
*
* cpdf_bottomLeft: One parameter -- distance from bottom left
*
* cpdf_bottom: One parameter -- distance from bottom
*
* cpdf_bottomRight: One parameter -- distance from bottom right
*
* cpdf_right: One parameter -- distance from right
*
* cpdf_diagonal: Zero parameters
*
* cpdf_reverseDiagonal: Zero parameters
*/
struct cpdf_position {
int cpdf_anchor; /* Position anchor */
double cpdf_coord1; /* Parameter one */
double cpdf_coord2; /* Parameter two */
};
/*
* cpdf_scaleContents(pdf, range, position, scale) scales the contents of the
* pages in the range about the point given by the cpdf_position, by the
* scale given.
*/
void cpdf_scaleContents(int, int, struct cpdf_position, double);
/*
* cpdf_shiftContents(pdf, range, dx, dy) shifts the content of the pages in
* the range.
*/
void cpdf_shiftContents(int, int, double, double);
/*
* cpdf_shiftContents(pdf, range, dx, dy) shifts the boxes of the pages in
* the range.
*/
void cpdf_shiftBoxes(int, int, double, double);
/*
* cpdf_rotate(pdf, range, rotation) changes the viewing rotation to an
* absolute value. Appropriate rotations are 0, 90, 180, 270.
*/
void cpdf_rotate(int, int, int);
/*
* cpdf_rotateBy(pdf, range, rotation) changes the viewing rotation by a
* given number of degrees. Appropriate values are 90, 180, 270.
*/
void cpdf_rotateBy(int, int, int);
/*
* cpdf_rotateContents(pdf, range, angle) rotates the content about the
* centre of the page by the given number of degrees, in a clockwise
* direction.
*/
void cpdf_rotateContents(int, int, double);
/*
* cpdf_upright(pdf, range) changes the viewing rotation of the pages in the
* range, counter-rotating the dimensions and content such that there is no
* visual change.
*/
void cpdf_upright(int, int);
/* cpdf_hFlip(pdf, range) flips horizontally the pages in the range. */
void cpdf_hFlip(int, int);
/* cpdf_vFlip(pdf, range) flips vertically the pages in the range. */
void cpdf_vFlip(int, int);
/*
* cpdf_crop(pdf, range, x, y, w, h) crops a page, replacing any existing
* crop box. The dimensions are in points.
*/
void cpdf_crop(int, int, double, double, double, double);
/* cpdf_removeCrop(pdf, range) removes any crop box from pages in the range. */
void cpdf_removeCrop(int, int);
/* cpdf_removeTrim(pdf, range) removes any trim box from pages in the range. */
void cpdf_removeTrim(int, int);
/* cpdf_removeArt(pdf, range) removes any art box from pages in the range. */
void cpdf_removeArt(int, int);
/* cpdf_removeBleed(pdf, range) removes any bleed box from pages in the range.
*/
void cpdf_removeBleed(int, int);
/*
* cpdf_trimMarks(pdf, range) adds trim marks to the given pages, if the
* trimbox exists.
*/
void cpdf_trimMarks(int, int);
/* cpdf_showBoxes(pdf, range) shows the boxes on the given pages, for debug. */
void cpdf_showBoxes(int, int);
/* cpdf_hardBox makes a given box a 'hard box' i.e clips it explicitly. */
void cpdf_hardBox(int, int, const char[]);
/* CHAPTER 4. Encryption */
/* Encryption covered under Chapter 1 in cpdflib. */
/* CHAPTER 5. Compression */
/*
* cpdf_compress(pdf) compresses any uncompressed streams in the given PDF
* using the Flate algorithm.
*/
void cpdf_compress(int);
/*
* cpdf_decompress(pdf) decompresses any streams in the given PDF, so long as
* the compression method is supported.
*/
void cpdf_decompress(int);
/* cpdf_squeezeToMemory(pdf) squeezes a pdf in memory. */
void cpdf_squeezeInMemory(int);
/* CHAPTER 6. Bookmarks */
/*
* cpdf_startGetBookmarkInfo(pdf) starts the bookmark retrieval process for a
* given PDF.
*/
void cpdf_startGetBookmarkInfo(int);
/*
* cpdf_numberBookmarks gets the number of bookmarks for the PDF given to
* cpdf_startGetBookmarkInfo.
*/
int cpdf_numberBookmarks(void);
/*
* cpdf_getBookmarkLevel(serial) get bookmark level for the given bookmark
* (0...(n - 1)).
*/
int cpdf_getBookmarkLevel(int);
/*
* cpdf_getBookmarkPage gets the bookmark target page for the given PDF
* (which must be the same as the PDF passed to cpdf_startSetBookmarkInfo)
* and bookmark (0...(n - 1)).
*/
int cpdf_getBookmarkPage(int, int);
/* cpdf_getBookmarkText returns the text of bookmark (0...(n - 1)). */
char *cpdf_getBookmarkText(int);
/* cpdf_getBookmarkOpenStatus(pdf) is true if the bookmark is open. */
int cpdf_getBookmarkOpenStatus(int);
/* cpdf_endGetBookmarkInfo ends the bookmark retrieval process, cleaning up. */
void cpdf_endGetBookmarkInfo(void);
/*
* cpdf_startGetBookmarkInfo(n) start the bookmark setting process for n
* bookmarks.
*/
void cpdf_startSetBookmarkInfo(int);
/*
* cpdf_setBookmarkLevel(n, level) set bookmark level for the given bookmark
* (0...(n - 1)).
*/
void cpdf_setBookmarkLevel(int, int);
/*
* cpdf_setBookmarkPage(pdf, bookmark, targetpage) sets the bookmark target
* page for the given PDF (which must be the same as the PDF to be passed to
* cpdf_endSetBookmarkInfo) and bookmark (0...(n - 1)).
*/
void cpdf_setBookmarkPage(int, int, int);
/*
* cpdf_setBookmarkOpenStatus(n, status) set the open status of a bookmark,
* true or false.
*/
void cpdf_setBookmarkOpenStatus(int, int);
/* cpdf_setBookmarkText(n, text) sets the text of bookmark (0...(n - 1)). */
void cpdf_setBookmarkText(int, const char[]);
/*
* cpdf_endSetBookmarkInfo(pdf) end the bookmark setting process, writing the
* bookmarks to the given PDF.
*/
void cpdf_endSetBookmarkInfo(int);
/* cpdf_getBookmarksJSON(pdf, length) returns the bookmark data and sets the
* length. */
void *cpdf_getBookmarksJSON(int, int *);
/* cpdf_setBookmarksJSON(pdf, data, datalength) sets the bookmarks from JSON
* bookmark data. */
void cpdf_setBookmarksJSON(int, void *, int);
/* cpdf_tableOfContents(pdf, font, fontsize, title, bookmark) typesets a table
* of contents from existing bookmarks and prepends it to the document. If
* bookmark is set, the table of contents gets its own bookmark. */
void cpdf_tableOfContents(int, const char[], double, const char[], int);
/* CHAPTER 7. Presentations */
/* Not included in the library version. */
/* CHAPTER 8. Logos, Watermarks and Stamps */
/*
* cpdf_stampOn(stamp_pdf, pdf, range) stamps stamp_pdf on top of all the
* pages in the document which are in the range. The stamp is placed with its
* origin at the origin of the target document.
*/
void cpdf_stampOn(int, int, int);
/*
* cpdf_stampUnder(stamp_pdf, pdf, range) stamps stamp_pdf under all the
* pages in the document which are in the range. The stamp is placed with its
* origin at the origin of the target document.
*/
void cpdf_stampUnder(int, int, int);
/*
* cpdf_stampExtended(pdf, pdf2, range, isover, scale_stamp_to_fit, pos,
* relative_to_cropbox) is a stamping function with extra features. - isover
* true, pdf goes over pdf2, isover false, pdf goes under pdf2 -
* scale_stamp_to_fit scales the stamp to fit the page - pos gives the
* position to put the stamp - relative_to_cropbox: if true, pos is relative
* to cropbox not mediabox.
*/
void cpdf_stampExtended(int, int, int, int, int, struct cpdf_position, int);
/*
* cpdf_combinePages(under, over) combines the PDFs page-by-page, putting
* each page of 'over' over each page of 'under'.
*/
int cpdf_combinePages(int, int);
/* Adding text. */
/*
* Special codes
*
* %Page Page number in arabic notation (1, 2, 3...)
*
* %roman Page number in lower-case roman notation (i, ii, iii...)
*
* %Roman Page number in upper-case roman notation (I, II, III...)
*
* %EndPage Last page of document in arabic notation
*
* %Label The page label of the page
*
* %EndLabel The page label of the last page
*
* %Filename The file name
*
* %a Abbreviated weekday name (Sun, Mon etc.)
*
* %A Full weekday name (Sunday, Monday etc.)
*
* %b Abbreviated month name (Jan, Feb etc.)
*
* %B Full month name (January, February etc.)
*
* %d Day of the month (01-31)
*
* %e Day of the month (1-31)
*
* %H Hour in 24-hour clock (00-23)
*
* %I Hour in 12-hour clock (01-12)
*
* %j Day of the year (001-366)
*
* %m Month of the year (01-12)
*
* %M Minute of the hour (00-59)
*
* %p "a.m" or "p.m"
*
* %S Second of the minute (00-61)
*
* %T Same as %H:%M:%S
*
* %u Weekday (1-7, 1 = Monday)
*
* %w Weekday (0-6, 0 = Monday)
*
* %Y Year (0000-9999)
*
* %% The % character
*/
/* The standard fonts */
char *cpdf_timesRoman = "Times-Roman";
char *cpdf_timesBold = "Times-Bold";
char *cpdf_timesItalic = "Times-Italic";
char *cpdf_timesBoldItalic = "Times-BoldItalic";
char *cpdf_helvetica = "Helvetica";
char *cpdf_helveticaBold = "Helvetica-Bold";
char *cpdf_helveticaOblique = "Helvetica-Oblique";
char *cpdf_helveticaBoldOblique = "Helvetica-BoldOblique";
char *cpdf_courier = "Courier";
char *cpdf_courierBold = "Courier-Bold";
char *cpdf_courierOblique = "Courier-Oblique";
char *cpdf_courierBoldOblique = "Courier-BoldOblique";
/* Justifications for multi line text */
enum cpdf_justification {
cpdf_leftJustify, /* Left justify */
cpdf_CentreJustify, /* Centre justify */
cpdf_RightJustify /* Right justify */
};
/* Add text */
void cpdf_addText(int, /* If true, don't actually add text but
* collect metrics. */
int, /* Document */
int, /* Page Range */
const char[], /* The text to add */
struct cpdf_position, /* Position to add text at */
double, /* Linespacing, 1.0 = normal */
int, /* Starting Bates number */
const char[], /* Font */
double, /* Font size in points */
double, /* Red component of colour, 0.0 - 1.0 */
double, /* Green component of colour, 0.0 - 1.0 */
double, /* Blue component of colour, 0.0 - 1.0 */
int, /* If true, text is added underneath rather
* than on top */
int, /* If true, position is relative to crop box
* not media box */
int, /* If true, text is outline rather than
* filled */
double, /* Opacity, 1.0 = opaque, 0.0 = wholly
* transparent */
enum cpdf_justification, /* Justification */
int, /* If true, position is relative to midline
* of text, not baseline */
int, /* If true, position is relative to topline
* of text, not baseline */
const char[], /* filename that this document was read from
* (optional) */
double, /* line width */
int /* embed fonts */
);
/* Add text, with most parameters default. NB %filename cannot be used here. */
void cpdf_addTextSimple(int, /* Document */
int, /* Page range */
const char[], /* The text to add */
struct cpdf_position, /* Position to add text
* at */
const char[], /* font */
double); /* font size */
/*
* cpdf_removeText(pdf, range) will remove any text added by libcpdf from the
* given pages.
*/
void cpdf_removeText(int, int);
/*
* Return the width of a given string in the given standard font in thousandths
* of a point.
*/
int cpdf_textWidth(const char[], const char[]);
/* cpdf_addContent(content, before, pdf, range) adds page content before (if
* true) or after (if false) the existing content to pages in the given range
* in the given PDF. */
void cpdf_addContent(const char[], int, int, int);
/* cpdf_stampAsXObject(pdf, range, stamp_pdf) stamps stamp_pdf onto the pages
* in the given range in pdf as a shared Form XObject. The name of the
* newly-created XObject is returned. */
char *cpdf_stampAsXObject(int, int, int);
/* CHAPTER 9. Multipage facilities */
/*
* cpdf_padBefore(pdf, range) adds a blank page before each page in the given
* range.
*/
void cpdf_padBefore(int, int);
/*
* cpdf_padAfter(pdf, range) adds a blank page after each page in the given
* range.
*/
void cpdf_padAfter(int, int);
/* cpdf_pageEvery(pdf, n) adds a blank page after every n pages. */
void cpdf_padEvery(int, int);
/*
* cpdf_padMultiple(pdf, n) adds pages at the end to pad the file to a
* multiple of n pages in length.
*/
void cpdf_padMultiple(int, int);
/*
* cpdf_padMultiple(pdf, n) adds pages at the beginning to pad the file to a
* multiple of n pages in length.
*/
void cpdf_padMultipleBefore(int, int);
/* cpdf_impose(pdf, x, y, fit, columns, rtl, btt, center, margin, spacing,
* linewidth) imposes a PDF. There are two modes: imposing x * y, or imposing
* to fit a page of size x * y. This is controlled by fit. Columns imposes by
* columns rather than rows. rtl is right-to-left, btt bottom-to-top. Center is
* unused for now. Margin is the margin around the output, spacing the spacing
* between imposed inputs. */
void cpdf_impose(int, double, double, int, int, int, int, int, double, double,
double);
/* cpdf_chop(pdf, range, x, y, columns, rtl, btt) chops each page in the range
* into x * y pieces. If columns is set, the pieces go by columns instead of
* rows. If rtl is set, the pieces are taken right-to-left. If btt is set, the
* pieces are taken from bottom to top. */
void cpdf_chop(int, int, int, int, int, int, int);
/* cpdf_chopH(pdf, range, columns, y) chops each page in the range horizontally
* at position y. If columns is set, the pieces are arranged in reverse order.
* */
void cpdf_chopH(int, int, int, double);
/* cpdf_chopV(pdf, range, columns, x) chops each page in the range vertically
* at position x. If columns is set, the pieces are arranged in reverse order.
* */
void cpdf_chopV(int, int, int, double);
/*
* Impose a document two up. cpdf_twoUp does so by retaining the existing
* page size, scaling pages down. cpdf_twoUpStack does so by doubling the
* page size, to fit two pages on one.
*/
void cpdf_twoUp(int);
void cpdf_twoUpStack(int);
/* CHAPTER 10. Annotations */
/* Return the annotations from a PDF in JSON format, returning also its length.
*/
void *cpdf_annotationsJSON(int, int *);
/* cpdf_removeAnnotations(pdf, range) removes all annotations from pages in the
* given range. */
void cpdf_removeAnnotations(int, int);
/* cpdf_setAnnotationsJSON(pdf, data, length) adds the annotations given in
* JSON format to the PDF, on top of any existing annotations. */
void cpdf_setAnnotationsJSON(int, void *, int);
/* CHAPTER 11. Document Information and Metadata */
/*
* cpdf_isLinearized(filename) finds out if a document is linearized as
* quickly as possible without loading it.
*/
int cpdf_isLinearized(const char[]);
/* cpdf_hasObjectStreams(pdf) finds out if a document was written using object
* streams. */
int cpdf_hasObjectStreams(int);
/* cpdf_id1(pdfs) returns the first ID string of the PDF, if any, in
* hexadecimal string format. */
char *cpdf_id1(int);
/* cpdf_id2(pdfs) returns the second ID string of the PDF, if any, in
* hexadecimal string format. */
char *cpdf_id2(int);
/* cpdf_hasAcroForm returns true if the document has an AcroForm */
int cpdf_hasAcroForm(int);
/* To return the subformats of a PDF (if any), call
* cpdf_startGetSubformats(pdf) to return their number. Then pass the numbers
* 0..n - 1 to cpdf_getSubformat to return the strings. Call
* cpdf_endGetSubformats() to clean up. */
int cpdf_startGetSubformats(int);
char *cpdf_getSubformat(int);
void cpdf_endGetSubformats(void);
/* cpdf_getVersion(pdf) returns the minor version number of a document. */
int cpdf_getVersion(int);
/* cpdf_getMajorVersion(pdf) returns the minor version number of a document. */
int cpdf_getMajorVersion(int);
/* cpdf_getTitle(pdf) returns the title of a document. */
char *cpdf_getTitle(int);
/* cpdf_getAuthor(pdf) returns the author of a document. */
char *cpdf_getAuthor(int);
/* cpdf_getSubject(pdf) returns the subject of a document. */
char *cpdf_getSubject(int);
/* cpdf_getKeywords(pdf) returns the keywords of a document. */
char *cpdf_getKeywords(int);
/* cpdf_getCreator(pdf) returns the creator of a document. */
char *cpdf_getCreator(int);
/* cpdf_getProducer(pdf) returns the producer of a document. */
char *cpdf_getProducer(int);
/* cpdf_getCreationDate(pdf) returns the creation date of a document. */
char *cpdf_getCreationDate(int);
/* cpdf_getModificationDate(pdf) returns the modification date of a document. */
char *cpdf_getModificationDate(int);
/* cpdf_getTitleXMP(pdf) returns the XMP title of a document. */
char *cpdf_getTitleXMP(int);
/* cpdf_getAuthorXMP(pdf) returns the XMP author of a document. */