wok-current annotate gambas2/stuff/CPdfDocument.cpp @ rev 23730

updated wavemon (0.9.0 -> 0.9.1)
author Hans-G?nter Theisgen
date Fri May 01 07:20:00 2020 +0100 (2020-05-01)
parents
children
rev   line source
pascal@18440 1 /***************************************************************************
pascal@18440 2
pascal@18440 3 CPdfDocument.cpp
pascal@18440 4
pascal@18440 5 gb.pdf Component
pascal@18440 6
pascal@18440 7 (C) 2005-2007 Daniel Campos Fernández <dcamposf@gmail.com>
pascal@18440 8
pascal@18440 9
pascal@18440 10 This program is free software; you can redistribute it and/or modify
pascal@18440 11 it under the terms of the GNU General Public License as published by
pascal@18440 12 the Free Software Foundation; either version 1, or (at your option)
pascal@18440 13 any later version.
pascal@18440 14
pascal@18440 15 This program is free software; you can redistribute it and/or modify
pascal@18440 16 it under the terms of the GNU General Public License as published by
pascal@18440 17 the Free Software Foundation; either version 1, or (at your option)
pascal@18440 18 any later version.
pascal@18440 19
pascal@18440 20 This program is distributed in the hope that it will be useful,
pascal@18440 21 but WITHOUT ANY WARRANTY; without even the implied warranty of
pascal@18440 22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
pascal@18440 23 GNU General Public License for more details.
pascal@18440 24
pascal@18440 25 You should have received a copy of the GNU General Public License
pascal@18440 26 along with this program; if not, write to the Free Software
pascal@18440 27 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
pascal@18440 28
pascal@18440 29 ***************************************************************************/
pascal@18440 30
pascal@18440 31 #define __CPDFDOCUMENT_C
pascal@18440 32
pascal@18440 33 #include "CPdfDocument.h"
pascal@18440 34
pascal@18440 35 #include "gambas.h"
pascal@18440 36 #include "main.h"
pascal@18440 37
pascal@18440 38 #include <stdio.h>
pascal@18440 39 #include <stdint.h>
pascal@18440 40 #include <math.h>
pascal@18440 41
pascal@18440 42 #include <PDFDoc.h>
pascal@18440 43 #include <Stream.h>
pascal@18440 44 #include <ErrorCodes.h>
pascal@18440 45 #include <Page.h>
pascal@18440 46 #include <Catalog.h>
pascal@18440 47 #include <TextOutputDev.h>
pascal@18440 48 #include <SplashOutputDev.h>
pascal@18440 49 #include <splash/SplashBitmap.h>
pascal@18440 50 #include <goo/GooList.h>
pascal@18440 51 #include <Outline.h>
pascal@18440 52 #include <Link.h>
pascal@18440 53 #include <Gfx.h>
pascal@18440 54
pascal@18440 55 /*****************************************************************************
pascal@18440 56
pascal@18440 57 Translations from Poppler universe to Gambas universe
pascal@18440 58
pascal@18440 59 ******************************************************************************/
pascal@18440 60 typedef struct
pascal@18440 61 {
pascal@18440 62 int32_t x0;
pascal@18440 63 int32_t y0;
pascal@18440 64 int32_t x1;
pascal@18440 65 int32_t y1;
pascal@18440 66 } FoundRect;
pascal@18440 67
pascal@18440 68 static void aux_return_string_info(void *_object, const char *key)
pascal@18440 69 {
pascal@18440 70 Object obj;
pascal@18440 71 Object dst;
pascal@18440 72 GooString *goo_value;
pascal@18440 73 Dict *info_dict;
pascal@18440 74 char *tmpstr;
pascal@18440 75
pascal@18440 76 THIS->doc->getDocInfo (&obj);
pascal@18440 77 if (!obj.isDict()) { GB.ReturnNewZeroString(""); return; }
pascal@18440 78
pascal@18440 79 info_dict=obj.getDict();
pascal@18440 80 info_dict->lookup ((char *)key, &dst);
pascal@18440 81 if (!dst.isString ()) { GB.ReturnNewZeroString(""); }
pascal@18440 82 else {
pascal@18440 83 goo_value = dst.getString();
pascal@18440 84
pascal@18440 85 if (goo_value->hasUnicodeMarker())
pascal@18440 86 {
pascal@18440 87 GB.ConvString (&tmpstr,goo_value->getCString()+2,goo_value->getLength()-2,"UTF-16BE","UTF-8");
pascal@18440 88 GB.ReturnNewZeroString(tmpstr);
pascal@18440 89 }
pascal@18440 90 else
pascal@18440 91 GB.ReturnNewString(goo_value->getCString(),goo_value->getLength());
pascal@18440 92 }
pascal@18440 93 dst.free();
pascal@18440 94 obj.free();
pascal@18440 95 }
pascal@18440 96
pascal@18440 97 static void aux_return_date_info(void *_object, const char *key)
pascal@18440 98 {
pascal@18440 99 // TODO: Y2K effect
pascal@18440 100 GB_DATE_SERIAL ds;
pascal@18440 101 GB_DATE ret;
pascal@18440 102 Object obj;
pascal@18440 103 Object dst;
pascal@18440 104 GooString *goo;
pascal@18440 105 Dict *info_dict;
pascal@18440 106 char *datestr=NULL,*tofree=NULL;
pascal@18440 107 int nnum;
pascal@18440 108
pascal@18440 109 THIS->doc->getDocInfo (&obj);
pascal@18440 110 if (!obj.isDict()) { GB.ReturnNull(); return; }
pascal@18440 111
pascal@18440 112 info_dict=obj.getDict();
pascal@18440 113 info_dict->lookup ((char *)key, &dst);
pascal@18440 114 if (!dst.isString ()) { GB.ReturnNull(); }
pascal@18440 115 else {
pascal@18440 116 goo = dst.getString();
pascal@18440 117 if (goo->hasUnicodeMarker())
pascal@18440 118 GB.ConvString (&datestr,goo->getCString()+2,goo->getLength()-2,"UTF-16BE","UTF-8");
pascal@18440 119 else
pascal@18440 120 {
pascal@18440 121 GB.NewString(&datestr,goo->getCString(),goo->getLength());
pascal@18440 122 tofree=datestr;
pascal@18440 123 }
pascal@18440 124
pascal@18440 125 if (!datestr) { GB.ReturnNull(); }
pascal@18440 126 else
pascal@18440 127 {
pascal@18440 128 if (datestr[0] == 'D' && datestr[1] == ':') datestr += 2;
pascal@18440 129 nnum=sscanf(datestr, "%4hd%2hd%2hd%2hd%2hd%2hd",&ds.year, &ds.month, \
pascal@18440 130 &ds.day, &ds.hour, &ds.min, &ds.sec);
pascal@18440 131 if (nnum != 6) { GB.ReturnNull(); }
pascal@18440 132 else
pascal@18440 133 {
pascal@18440 134 if (GB.MakeDate(&ds,&ret))
pascal@18440 135 GB.ReturnNull();
pascal@18440 136 else
pascal@18440 137 GB.ReturnDate(&ret);
pascal@18440 138 }
pascal@18440 139 }
pascal@18440 140
pascal@18440 141 }
pascal@18440 142
pascal@18440 143 if (tofree) GB.FreeString(&tofree);
pascal@18440 144 dst.free();
pascal@18440 145 obj.free();
pascal@18440 146 }
pascal@18440 147
pascal@18440 148 static void aux_return_unicode_string(Unicode *uni, int32_t len)
pascal@18440 149 {
pascal@18440 150 int32_t bc;
pascal@18440 151 char *ret=NULL;
pascal@18440 152
pascal@18440 153 for (bc=0; bc<len; bc++)
pascal@18440 154 GB.AddString(&ret,(const char*)&uni[bc],0);
pascal@18440 155
pascal@18440 156 GB.ReturnNewString(ret,0);
pascal@18440 157 GB.FreeString(&ret);
pascal@18440 158 }
pascal@18440 159
pascal@18440 160 static LinkDest *get_dest(LinkAction *act)
pascal@18440 161 {
pascal@18440 162 switch (act->getKind())
pascal@18440 163 {
pascal@18440 164 case actionGoTo: return ((LinkGoTo*)act)->getDest();
pascal@18440 165 case actionGoToR: return ((LinkGoToR*)act)->getDest();
pascal@18440 166 default: return 0;
pascal@18440 167 }
pascal@18440 168 }
pascal@18440 169
pascal@18440 170 static uint32_t aux_get_page_from_action(void *_object, LinkAction *act)
pascal@18440 171 {
pascal@18440 172 Ref pref;
pascal@18440 173 LinkDest *dest = get_dest(act);
pascal@18440 174 #if POPPLER_VERSION_0_6
pascal@18440 175 GooString *name;
pascal@18440 176 #else
pascal@18440 177 UGooString *name;
pascal@18440 178 #endif
pascal@18440 179
pascal@18440 180 if (!dest)
pascal@18440 181 {
pascal@18440 182 // try to use NamedDest to get dest
pascal@18440 183 if (!act)
pascal@18440 184 return 0;
pascal@18440 185 if (act->getKind () == actionGoTo)
pascal@18440 186 {
pascal@18440 187 name = ((LinkGoTo*)act)->getNamedDest();
pascal@18440 188 if (name)
pascal@18440 189 dest = THIS->doc->findDest(name);
pascal@18440 190 }
pascal@18440 191 }
pascal@18440 192
pascal@18440 193 if (!dest)
pascal@18440 194 return 0;
pascal@18440 195
pascal@18440 196 if (dest->isPageRef() )
pascal@18440 197 {
pascal@18440 198 pref= dest->getPageRef();
pascal@18440 199 return THIS->doc->findPage(pref.num, pref.gen);
pascal@18440 200 }
pascal@18440 201 else
pascal@18440 202 return dest->getPageNum();
pascal@18440 203 }
pascal@18440 204
pascal@18440 205 static void aux_get_dimensions_from_action(LinkAction *act,int *left, int32_t *right, int32_t *top, int32_t *bottom)
pascal@18440 206 {
pascal@18440 207 LinkDest *dest = get_dest(act);
pascal@18440 208 if (!dest)
pascal@18440 209 {
pascal@18440 210 if (left) *left=0;
pascal@18440 211 if (right) *right=0;
pascal@18440 212 if (top) *top=0;
pascal@18440 213 if (bottom) *bottom=0;
pascal@18440 214 return;
pascal@18440 215 }
pascal@18440 216
pascal@18440 217 if (left) *left=(int32_t)dest->getLeft();
pascal@18440 218 if (right) *right=(int32_t)dest->getRight();
pascal@18440 219 if (top) *top=(int32_t)dest->getTop();
pascal@18440 220 if (bottom) *bottom=(int32_t)dest->getBottom();
pascal@18440 221 }
pascal@18440 222
pascal@18440 223 static double aux_get_zoom_from_action(LinkAction *act)
pascal@18440 224 {
pascal@18440 225 LinkDest *dest = get_dest(act);
pascal@18440 226 if (dest)
pascal@18440 227 return dest->getZoom();
pascal@18440 228 else
pascal@18440 229 return 1;
pascal@18440 230 }
pascal@18440 231
pascal@18440 232 static char* aux_get_target_from_action(LinkAction *act)
pascal@18440 233 {
pascal@18440 234 char *vl=NULL;
pascal@18440 235 char *uni=NULL;
pascal@18440 236 GooString *tmp=NULL;
pascal@18440 237
pascal@18440 238 switch (act->getKind())
pascal@18440 239 {
pascal@18440 240 case actionGoToR:
pascal@18440 241 tmp=((LinkGoToR*)act)->getFileName(); break;
pascal@18440 242
pascal@18440 243 case actionLaunch:
pascal@18440 244 tmp=((LinkLaunch*)act)->getFileName(); break;
pascal@18440 245
pascal@18440 246 case actionURI:
pascal@18440 247 tmp=((LinkURI*)act)->getURI(); break;
pascal@18440 248
pascal@18440 249 case actionNamed:
pascal@18440 250 tmp=((LinkNamed*)act)->getName(); break;
pascal@18440 251
pascal@18440 252 case actionMovie:
pascal@18440 253 #if POPPLER_VERSION_0_8
pascal@18440 254 tmp=((LinkMovie*)act)->getAnnotTitle(); break;
pascal@18440 255 #else
pascal@18440 256 tmp=((LinkMovie*)act)->getTitle(); break;
pascal@18440 257 #endif
pascal@18440 258
pascal@18440 259 default:
pascal@18440 260 break;
pascal@18440 261 }
pascal@18440 262
pascal@18440 263 if (!tmp) return NULL;
pascal@18440 264
pascal@18440 265 if (tmp->hasUnicodeMarker())
pascal@18440 266 {
pascal@18440 267 GB.ConvString (&uni,tmp->getCString()+2,tmp->getLength()-2,"UTF-16BE","UTF-8");
pascal@18440 268 GB.AddString (&vl,uni,0);
pascal@18440 269 }
pascal@18440 270 else
pascal@18440 271 GB.AddString(&vl,tmp->getCString(),tmp->getLength());
pascal@18440 272
pascal@18440 273
pascal@18440 274 return vl;
pascal@18440 275
pascal@18440 276 }
pascal@18440 277
pascal@18440 278 /*****************************************************************************
pascal@18440 279
pascal@18440 280 PDF document
pascal@18440 281
pascal@18440 282 ******************************************************************************/
pascal@18440 283
pascal@18440 284
pascal@18440 285 static void free_all(void *_object)
pascal@18440 286 {
pascal@18440 287 if (THIS->doc)
pascal@18440 288 {
pascal@18440 289 delete THIS->doc;
pascal@18440 290 THIS->doc=NULL;
pascal@18440 291 }
pascal@18440 292
pascal@18440 293 if (THIS->dev)
pascal@18440 294 {
pascal@18440 295 delete THIS->dev;
pascal@18440 296 THIS->dev=NULL;
pascal@18440 297 }
pascal@18440 298
pascal@18440 299 if (THIS->buf)
pascal@18440 300 {
pascal@18440 301 GB.ReleaseFile(&THIS->buf,THIS->len);
pascal@18440 302 THIS->buf=NULL;
pascal@18440 303 }
pascal@18440 304
pascal@18440 305 if (THIS->Found)
pascal@18440 306 {
pascal@18440 307 GB.FreeArray(POINTER(&THIS->Found));
pascal@18440 308 THIS->Found=NULL;
pascal@18440 309 }
pascal@18440 310
pascal@18440 311 if (THIS->links)
pascal@18440 312 {
pascal@18440 313 delete THIS->links;
pascal@18440 314 THIS->links=NULL;
pascal@18440 315 }
pascal@18440 316
pascal@18440 317 if (THIS->pindex)
pascal@18440 318 {
pascal@18440 319 GB.FreeArray(POINTER(&THIS->pindex));
pascal@18440 320 GB.FreeArray(POINTER(&THIS->oldindex));
pascal@18440 321 THIS->pindex=NULL;
pascal@18440 322 THIS->oldindex=NULL;
pascal@18440 323 }
pascal@18440 324
pascal@18440 325 THIS->index=NULL;
pascal@18440 326 THIS->currpage=-1;
pascal@18440 327 }
pascal@18440 328
pascal@18440 329 BEGIN_METHOD_VOID (PDFDOCUMENT_free)
pascal@18440 330
pascal@18440 331 free_all(_object);
pascal@18440 332
pascal@18440 333 END_METHOD
pascal@18440 334
pascal@18440 335 BEGIN_PROPERTY(PDFDOCUMENT_scale)
pascal@18440 336
pascal@18440 337 if (READ_PROPERTY){ GB.ReturnFloat(THIS->scale); return; }
pascal@18440 338
pascal@18440 339 if (VPROP(GB_FLOAT)>0) { THIS->scale = VPROP(GB_FLOAT); return; }
pascal@18440 340
pascal@18440 341 GB.Error("Zoom must be a positive value");
pascal@18440 342
pascal@18440 343 END_PROPERTY
pascal@18440 344
pascal@18440 345 BEGIN_PROPERTY(PDFDOCUMENT_rotation)
pascal@18440 346
pascal@18440 347 int32_t rot;
pascal@18440 348
pascal@18440 349 if (READ_PROPERTY)
pascal@18440 350 {
pascal@18440 351 GB.ReturnInteger(THIS->rotation);
pascal@18440 352 return;
pascal@18440 353 }
pascal@18440 354
pascal@18440 355 rot=VPROP(GB_INTEGER);
pascal@18440 356
pascal@18440 357 while (rot<0) rot+=360;
pascal@18440 358 while (rot>=360) rot-=360;
pascal@18440 359
pascal@18440 360 switch (rot)
pascal@18440 361 {
pascal@18440 362 case 0:
pascal@18440 363 case 90:
pascal@18440 364 case 180:
pascal@18440 365 case 270:
pascal@18440 366 THIS->rotation = VPROP(GB_INTEGER);
pascal@18440 367 break;
pascal@18440 368 }
pascal@18440 369
pascal@18440 370 END_PROPERTY
pascal@18440 371
pascal@18440 372
pascal@18440 373 int32_t open_document (void *_object, char *sfile, int32_t lfile)
pascal@18440 374 {
pascal@18440 375 SplashColor white;
pascal@18440 376 PDFDoc *test;
pascal@18440 377 MemStream *stream;
pascal@18440 378 Object obj;
pascal@18440 379 Outline *outline;
pascal@18440 380 char *buf=NULL;
pascal@18440 381 int32_t len=0;
pascal@18440 382 int32_t ret;
pascal@18440 383
pascal@18440 384
pascal@18440 385 if ( GB.LoadFile(sfile,lfile,&buf,&len) ) return -1;
pascal@18440 386
pascal@18440 387 obj.initNull();
pascal@18440 388 stream=new MemStream(buf,0,(Guint)len,&obj);
pascal@18440 389 test=new PDFDoc (stream,0,0);
pascal@18440 390
pascal@18440 391 if (!test->isOk())
pascal@18440 392 {
pascal@18440 393 GB.ReleaseFile(&buf,len);
pascal@18440 394 ret=test->getErrorCode();
pascal@18440 395 delete test;
pascal@18440 396 test=NULL;
pascal@18440 397 if (ret == errEncrypted) return -2;
pascal@18440 398 return -3;
pascal@18440 399 }
pascal@18440 400
pascal@18440 401 free_all(_object);
pascal@18440 402
pascal@18440 403 THIS->doc=test;
pascal@18440 404 THIS->buf=buf;
pascal@18440 405 THIS->len=len;
pascal@18440 406
pascal@18440 407 white[0] = 0xFF; white[1] = 0xFF; white[2] = 0xFF;
pascal@18440 408 THIS->dev=new SplashOutputDev(splashModeRGB8, 3, gFalse, white);
pascal@18440 409
pascal@18440 410 #if POPPLER_VERSION_0_20
pascal@18440 411 THIS->dev->startDoc(THIS->doc);
pascal@18440 412 #else
pascal@18440 413 THIS->dev->startDoc(THIS->doc->getXRef ());
pascal@18440 414 #endif
pascal@18440 415
pascal@18440 416 outline=THIS->doc->getOutline();
pascal@18440 417 if (outline) THIS->index=outline->getItems();
pascal@18440 418
pascal@18440 419 //if (THIS->index)
pascal@18440 420 // if (!THIS->index->getLength()) THIS->index=NULL;
pascal@18440 421
pascal@18440 422 THIS->currindex=0;
pascal@18440 423 THIS->currpage=-1;
pascal@18440 424
pascal@18440 425 return 0;
pascal@18440 426
pascal@18440 427 }
pascal@18440 428
pascal@18440 429
pascal@18440 430 BEGIN_METHOD(PDFDOCUMENT_new, GB_STRING File)
pascal@18440 431
pascal@18440 432 THIS->scale = 1;
pascal@18440 433 THIS->rotation = 0;
pascal@18440 434
pascal@18440 435 if (!MISSING(File))
pascal@18440 436 {
pascal@18440 437 switch (open_document( _object, STRING(File), LENGTH(File)) )
pascal@18440 438 {
pascal@18440 439 case -1: GB.Error("File not found"); return;
pascal@18440 440 case -2: GB.Error("PDF is encrypted"); return;
pascal@18440 441 case -3: GB.Error("Bad PDF File"); return;
pascal@18440 442 }
pascal@18440 443 }
pascal@18440 444
pascal@18440 445 END_METHOD
pascal@18440 446
pascal@18440 447 BEGIN_METHOD (PDFDOCUMENT_open, GB_STRING File;)
pascal@18440 448
pascal@18440 449 switch (open_document( _object, STRING(File), LENGTH(File)) )
pascal@18440 450 {
pascal@18440 451 case -1: GB.Error("File not found"); return;
pascal@18440 452 case -2: GB.Error("PDF is encrypted"); return;
pascal@18440 453 case -3: GB.Error("Bad PDF File"); return;
pascal@18440 454 }
pascal@18440 455
pascal@18440 456 END_METHOD
pascal@18440 457
pascal@18440 458 BEGIN_METHOD_VOID(PDFDOCUMENT_close)
pascal@18440 459
pascal@18440 460 free_all(_object);
pascal@18440 461
pascal@18440 462 END_METHOD
pascal@18440 463
pascal@18440 464 BEGIN_METHOD(PDFDOCUMENT_get,GB_INTEGER index;)
pascal@18440 465
pascal@18440 466 if (!THIS->doc || (VARG(index)<1) || ( VARG(index)>THIS->doc->getNumPages() ) )
pascal@18440 467 {
pascal@18440 468 GB.Error("Invalid page number");
pascal@18440 469 GB.ReturnNull();
pascal@18440 470 return;
pascal@18440 471 }
pascal@18440 472
pascal@18440 473 if (THIS->currpage != (uint32_t)VARG(index) )
pascal@18440 474 {
pascal@18440 475 if (THIS->Found)
pascal@18440 476 {
pascal@18440 477 GB.FreeArray(POINTER(&THIS->Found));
pascal@18440 478 THIS->Found=NULL;
pascal@18440 479 }
pascal@18440 480
pascal@18440 481 if (THIS->links)
pascal@18440 482 {
pascal@18440 483 delete THIS->links;
pascal@18440 484 THIS->links=NULL;
pascal@18440 485 }
pascal@18440 486
pascal@18440 487 THIS->page=THIS->doc->getCatalog()->getPage(VARG(index));
pascal@18440 488 THIS->currpage=VARG(index);
pascal@18440 489 }
pascal@18440 490
pascal@18440 491 RETURN_SELF();
pascal@18440 492
pascal@18440 493 END_METHOD
pascal@18440 494
pascal@18440 495 BEGIN_PROPERTY(PDFDOCUMENT_ready)
pascal@18440 496
pascal@18440 497 GB.ReturnBoolean( (bool)THIS->doc );
pascal@18440 498
pascal@18440 499 END_PROPERTY
pascal@18440 500
pascal@18440 501 BEGIN_PROPERTY(PDFDOCUMENT_count)
pascal@18440 502
pascal@18440 503 GB.ReturnInteger( (int32_t) (THIS->doc ? THIS->doc->getNumPages() : 0));
pascal@18440 504
pascal@18440 505 END_PROPERTY
pascal@18440 506
pascal@18440 507 BEGIN_PROPERTY(PDFDOCUMENT_info)
pascal@18440 508
pascal@18440 509 if (THIS->doc) RETURN_SELF();
pascal@18440 510 else GB.ReturnNull();
pascal@18440 511
pascal@18440 512 END_PROPERTY
pascal@18440 513
pascal@18440 514 /*****************************************************************************
pascal@18440 515
pascal@18440 516 PDF document information
pascal@18440 517
pascal@18440 518 ******************************************************************************/
pascal@18440 519
pascal@18440 520 BEGIN_PROPERTY(PDFINFO_title)
pascal@18440 521
pascal@18440 522 aux_return_string_info(_object,"Title");
pascal@18440 523
pascal@18440 524 END_PROPERTY
pascal@18440 525
pascal@18440 526 BEGIN_PROPERTY(PDFINFO_format)
pascal@18440 527
pascal@18440 528 char ctx[16];
pascal@18440 529 #if POPPLER_VERSION_0_11_3
pascal@18440 530 snprintf(ctx, sizeof(ctx), "%.2g", THIS->doc->getPDFMajorVersion () + THIS->doc->getPDFMinorVersion() / 10.0);
pascal@18440 531 #else
pascal@18440 532 snprintf(ctx, sizeof(ctx), "%.2g", THIS->doc->getPDFVersion());
pascal@18440 533 #endif
pascal@18440 534 GB.ReturnNewZeroString(ctx);
pascal@18440 535
pascal@18440 536 END_PROPERTY
pascal@18440 537
pascal@18440 538 BEGIN_PROPERTY(PDFINFO_author)
pascal@18440 539
pascal@18440 540 aux_return_string_info(_object,"Author");
pascal@18440 541
pascal@18440 542 END_PROPERTY
pascal@18440 543
pascal@18440 544 BEGIN_PROPERTY(PDFINFO_subject)
pascal@18440 545
pascal@18440 546 aux_return_string_info(_object,"Subject");
pascal@18440 547
pascal@18440 548 END_PROPERTY
pascal@18440 549
pascal@18440 550 BEGIN_PROPERTY(PDFINFO_keywords)
pascal@18440 551
pascal@18440 552 aux_return_string_info(_object,"Keywords");
pascal@18440 553
pascal@18440 554 END_PROPERTY
pascal@18440 555
pascal@18440 556 BEGIN_PROPERTY(PDFINFO_creator)
pascal@18440 557
pascal@18440 558 aux_return_string_info(_object,"Creator");
pascal@18440 559
pascal@18440 560 END_PROPERTY
pascal@18440 561
pascal@18440 562 BEGIN_PROPERTY(PDFINFO_producer)
pascal@18440 563
pascal@18440 564 aux_return_string_info(_object,"Producer");
pascal@18440 565
pascal@18440 566 END_PROPERTY
pascal@18440 567
pascal@18440 568 BEGIN_PROPERTY(PDFINFO_linearized)
pascal@18440 569
pascal@18440 570 GB.ReturnBoolean(THIS->doc->isLinearized());
pascal@18440 571
pascal@18440 572 END_PROPERTY
pascal@18440 573
pascal@18440 574 BEGIN_PROPERTY(PDFINFO_layout)
pascal@18440 575
pascal@18440 576 Catalog *catalog;
pascal@18440 577
pascal@18440 578 catalog=THIS->doc->getCatalog();
pascal@18440 579 if (!catalog) { GB.ReturnInteger(Catalog::pageLayoutNone); return; }
pascal@18440 580 if (!catalog->isOk()) { GB.ReturnInteger(Catalog::pageLayoutNone); return; }
pascal@18440 581
pascal@18440 582 GB.ReturnInteger(catalog->getPageLayout());
pascal@18440 583
pascal@18440 584 END_PROPERTY
pascal@18440 585
pascal@18440 586 BEGIN_PROPERTY(PDFINFO_mode)
pascal@18440 587
pascal@18440 588 Catalog *catalog;
pascal@18440 589
pascal@18440 590 catalog=THIS->doc->getCatalog();
pascal@18440 591 if (!catalog) { GB.ReturnInteger(Catalog::pageModeNone); return; }
pascal@18440 592 if (!catalog->isOk()) { GB.ReturnInteger(Catalog::pageModeNone); return; }
pascal@18440 593
pascal@18440 594 GB.ReturnInteger(catalog->getPageMode());
pascal@18440 595
pascal@18440 596
pascal@18440 597 END_PROPERTY
pascal@18440 598
pascal@18440 599 BEGIN_PROPERTY(PDFINFO_canprint)
pascal@18440 600
pascal@18440 601 GB.ReturnBoolean(THIS->doc->okToPrint());
pascal@18440 602
pascal@18440 603 END_PROPERTY
pascal@18440 604
pascal@18440 605 BEGIN_PROPERTY(PDFINFO_canmodify)
pascal@18440 606
pascal@18440 607 GB.ReturnBoolean(THIS->doc->okToChange());
pascal@18440 608
pascal@18440 609 END_PROPERTY
pascal@18440 610
pascal@18440 611 BEGIN_PROPERTY(PDFINFO_cancopy)
pascal@18440 612
pascal@18440 613 GB.ReturnBoolean(THIS->doc->okToCopy());
pascal@18440 614
pascal@18440 615 END_PROPERTY
pascal@18440 616
pascal@18440 617 BEGIN_PROPERTY(PDFINFO_canaddnotes)
pascal@18440 618
pascal@18440 619 GB.ReturnBoolean(THIS->doc->okToAddNotes());
pascal@18440 620
pascal@18440 621 END_PROPERTY
pascal@18440 622
pascal@18440 623 BEGIN_PROPERTY(PDFINFO_creation)
pascal@18440 624
pascal@18440 625 aux_return_date_info(_object,"CreationDate");
pascal@18440 626
pascal@18440 627 END_PROPERTY
pascal@18440 628
pascal@18440 629 BEGIN_PROPERTY(PDFINFO_modification)
pascal@18440 630
pascal@18440 631 aux_return_date_info(_object,"ModDate");
pascal@18440 632
pascal@18440 633 END_PROPERTY
pascal@18440 634
pascal@18440 635
pascal@18440 636 /*****************************************************************************
pascal@18440 637
pascal@18440 638 PDF document index
pascal@18440 639
pascal@18440 640 ******************************************************************************/
pascal@18440 641
pascal@18440 642
pascal@18440 643 BEGIN_PROPERTY(PDFDOCUMENT_has_index)
pascal@18440 644
pascal@18440 645 GB.ReturnBoolean(THIS->index && THIS->index->getLength());
pascal@18440 646
pascal@18440 647 END_PROPERTY
pascal@18440 648
pascal@18440 649 BEGIN_PROPERTY(PDFDOCUMENT_index)
pascal@18440 650
pascal@18440 651 if (!THIS->index) { GB.ReturnNull(); return; }
pascal@18440 652
pascal@18440 653 THIS->action=((OutlineItem*)THIS->index->get(THIS->currindex))->getAction();
pascal@18440 654 RETURN_SELF();
pascal@18440 655
pascal@18440 656 END_PROPERTY
pascal@18440 657
pascal@18440 658 BEGIN_PROPERTY(PDFINDEX_count)
pascal@18440 659
pascal@18440 660 GB.ReturnInteger(THIS->index->getLength());
pascal@18440 661
pascal@18440 662 END_PROPERTY
pascal@18440 663
pascal@18440 664 BEGIN_PROPERTY(PDFINDEX_has_children)
pascal@18440 665
pascal@18440 666 OutlineItem *item;
pascal@18440 667
pascal@18440 668 item = (OutlineItem *)THIS->index->get (THIS->currindex);
pascal@18440 669 GB.ReturnBoolean(item->getKids() && item->getKids()->getLength());
pascal@18440 670
pascal@18440 671 END_PROPERTY
pascal@18440 672
pascal@18440 673 BEGIN_PROPERTY(PDFINDEX_is_open)
pascal@18440 674
pascal@18440 675 OutlineItem *item;
pascal@18440 676
pascal@18440 677 item = (OutlineItem *)THIS->index->get (THIS->currindex);
pascal@18440 678
pascal@18440 679 if (READ_PROPERTY)
pascal@18440 680 { GB.ReturnBoolean(item->isOpen()); return; }
pascal@18440 681
pascal@18440 682 if (VPROP(GB_INTEGER)) item->open();
pascal@18440 683 else item->close();
pascal@18440 684
pascal@18440 685 END_PROPERTY
pascal@18440 686
pascal@18440 687 BEGIN_PROPERTY(PDFINDEX_title)
pascal@18440 688
pascal@18440 689 OutlineItem *item;
pascal@18440 690
pascal@18440 691 item = (OutlineItem *)THIS->index->get (THIS->currindex);
pascal@18440 692 aux_return_unicode_string(item->getTitle(),item->getTitleLength());
pascal@18440 693
pascal@18440 694 END_PROPERTY
pascal@18440 695
pascal@18440 696
pascal@18440 697 BEGIN_METHOD_VOID(PDFINDEX_root)
pascal@18440 698
pascal@18440 699 Outline *outline;
pascal@18440 700
pascal@18440 701 outline=THIS->doc->getOutline();
pascal@18440 702 if (outline) THIS->index=outline->getItems();
pascal@18440 703 THIS->currindex=0;
pascal@18440 704 if (THIS->pindex) { GB.FreeArray(POINTER(&THIS->pindex)); THIS->pindex=NULL; }
pascal@18440 705 if (THIS->oldindex) { GB.FreeArray(POINTER(&THIS->oldindex)); THIS->oldindex=NULL; }
pascal@18440 706
pascal@18440 707 END_METHOD
pascal@18440 708
pascal@18440 709 BEGIN_METHOD_VOID(PDFINDEX_prev)
pascal@18440 710
pascal@18440 711 if (!THIS->currindex) { GB.ReturnBoolean(true); return; }
pascal@18440 712
pascal@18440 713 THIS->currindex--;
pascal@18440 714 GB.ReturnBoolean(false);
pascal@18440 715
pascal@18440 716 END_METHOD
pascal@18440 717
pascal@18440 718 BEGIN_METHOD_VOID(PDFINDEX_next)
pascal@18440 719
pascal@18440 720 if ( (THIS->currindex+1) >= (uint32_t)THIS->index->getLength() )
pascal@18440 721 { GB.ReturnBoolean(true); return; }
pascal@18440 722
pascal@18440 723 THIS->currindex++;
pascal@18440 724 GB.ReturnBoolean(false);
pascal@18440 725
pascal@18440 726 END_METHOD
pascal@18440 727
pascal@18440 728 BEGIN_METHOD_VOID(PDFINDEX_child)
pascal@18440 729
pascal@18440 730 OutlineItem *item;
pascal@18440 731
pascal@18440 732 item = (OutlineItem *)THIS->index->get (THIS->currindex);
pascal@18440 733
pascal@18440 734 if (!item->hasKids() || item->getKids()->getLength() == 0) { GB.ReturnBoolean(true); return; }
pascal@18440 735
pascal@18440 736 if (THIS->pindex)
pascal@18440 737 {
pascal@18440 738 GB.Add(POINTER(&THIS->pindex));
pascal@18440 739 GB.Add(POINTER(&THIS->oldindex));
pascal@18440 740 }
pascal@18440 741 else
pascal@18440 742 {
pascal@18440 743 GB.NewArray(POINTER(&THIS->pindex),sizeof(void*),1);
pascal@18440 744 GB.NewArray(POINTER(&THIS->oldindex),sizeof(uint32_t),1);
pascal@18440 745 }
pascal@18440 746
pascal@18440 747 if (!item->isOpen()) item->open();
pascal@18440 748 THIS->pindex[GB.Count(POINTER(THIS->pindex))-1]=(void*)THIS->index;
pascal@18440 749 THIS->oldindex[GB.Count(POINTER(THIS->pindex))-1]=THIS->currindex;
pascal@18440 750 THIS->index=item->getKids();
pascal@18440 751 THIS->currindex=0;
pascal@18440 752
pascal@18440 753 GB.ReturnBoolean(false);
pascal@18440 754
pascal@18440 755 END_METHOD
pascal@18440 756
pascal@18440 757 BEGIN_METHOD_VOID(PDFINDEX_parent)
pascal@18440 758
pascal@18440 759 if (!THIS->pindex) { GB.ReturnBoolean(true); return; }
pascal@18440 760
pascal@18440 761 THIS->index=(GooList*)THIS->pindex[GB.Count(POINTER(THIS->pindex))-1];
pascal@18440 762 THIS->currindex=THIS->oldindex[GB.Count(POINTER(THIS->pindex))-1];
pascal@18440 763 if (GB.Count(POINTER(THIS->pindex))==1)
pascal@18440 764 {
pascal@18440 765 GB.FreeArray(POINTER(&THIS->pindex));
pascal@18440 766 GB.FreeArray(POINTER(&THIS->oldindex));
pascal@18440 767 THIS->oldindex=NULL;
pascal@18440 768 THIS->pindex=NULL;
pascal@18440 769 }
pascal@18440 770 else
pascal@18440 771 {
pascal@18440 772 GB.Remove(POINTER(&THIS->pindex),GB.Count(POINTER(THIS->pindex))-1,1);
pascal@18440 773 GB.Remove(POINTER(&THIS->oldindex),GB.Count(POINTER(THIS->oldindex))-1,1);
pascal@18440 774 }
pascal@18440 775
pascal@18440 776 GB.ReturnBoolean(false);
pascal@18440 777
pascal@18440 778 END_METHOD
pascal@18440 779
pascal@18440 780 /*****************************************************************************
pascal@18440 781
pascal@18440 782 PDF pages
pascal@18440 783
pascal@18440 784 ******************************************************************************/
pascal@18440 785
pascal@18440 786 BEGIN_PROPERTY (PDFPAGE_width)
pascal@18440 787
pascal@18440 788 if ( (THIS->rotation==90) || (THIS->rotation==270) )
pascal@18440 789 GB.ReturnInteger((int32_t)(THIS->page->getMediaHeight()*THIS->scale));
pascal@18440 790 else
pascal@18440 791 GB.ReturnInteger((int32_t)(THIS->page->getMediaWidth()*THIS->scale));
pascal@18440 792
pascal@18440 793 END_PROPERTY
pascal@18440 794
pascal@18440 795 BEGIN_PROPERTY (PDFPAGE_height)
pascal@18440 796
pascal@18440 797 if ( (THIS->rotation==90) || (THIS->rotation==270) )
pascal@18440 798 GB.ReturnInteger((int32_t)(THIS->page->getMediaWidth()*THIS->scale));
pascal@18440 799 else
pascal@18440 800 GB.ReturnInteger((int32_t)(THIS->page->getMediaHeight()*THIS->scale));
pascal@18440 801
pascal@18440 802 END_PROPERTY
pascal@18440 803
pascal@18440 804 static uint32_t *get_page_data(CPDFDOCUMENT *_object, int32_t x, int32_t y, int32_t *width, int32_t *height, double scale, int32_t rotation)
pascal@18440 805 {
pascal@18440 806 SplashBitmap *map;
pascal@18440 807 uint32_t *data;
pascal@18440 808 int32_t w, h;
pascal@18440 809 int32_t rw;
pascal@18440 810 int32_t rh;
pascal@18440 811
pascal@18440 812 if ( (THIS->rotation==90) || (THIS->rotation==270) )
pascal@18440 813 {
pascal@18440 814 rh=(int32_t)(THIS->page->getMediaWidth()*THIS->scale);
pascal@18440 815 rw=(int32_t)(THIS->page->getMediaHeight()*THIS->scale);
pascal@18440 816 }
pascal@18440 817 else
pascal@18440 818 {
pascal@18440 819 rw=(int32_t)(THIS->page->getMediaWidth()*THIS->scale);
pascal@18440 820 rh=(int32_t)(THIS->page->getMediaHeight()*THIS->scale);
pascal@18440 821 }
pascal@18440 822
pascal@18440 823 w = *width;
pascal@18440 824 h = *height;
pascal@18440 825
pascal@18440 826 if (w < 0) w = rw;
pascal@18440 827 if (h < 0) h = rh;
pascal@18440 828
pascal@18440 829 if (x<0) x=0;
pascal@18440 830 if (y<0) y=0;
pascal@18440 831 if (w<1) w=1;
pascal@18440 832 if (h<1) h=1;
pascal@18440 833
pascal@18440 834
pascal@18440 835 if ( (x+w) > rw ) w=rw-x;
pascal@18440 836 if ( (y+h) > rh ) h=rh-y;
pascal@18440 837
pascal@18440 838 if ( (w<0) || (h<0) ) return NULL;
pascal@18440 839
pascal@18440 840 #if POPPLER_VERSION_0_20
pascal@18440 841 THIS->page->displaySlice(THIS->dev,72.0*scale,72.0*scale,
pascal@18440 842 rotation,
pascal@18440 843 gFalse,
pascal@18440 844 gTrue,
pascal@18440 845 x,y,w,h,
pascal@18440 846 gFalse);
pascal@18440 847 #else
pascal@18440 848 THIS->page->displaySlice(THIS->dev,72.0*scale,72.0*scale,
pascal@18440 849 rotation,
pascal@18440 850 gFalse,
pascal@18440 851 gTrue,
pascal@18440 852 x,y,w,h,
pascal@18440 853 gFalse,
pascal@18440 854 THIS->doc->getCatalog ());
pascal@18440 855 #endif
pascal@18440 856
pascal@18440 857 map=THIS->dev->getBitmap();
pascal@18440 858
pascal@18440 859 data=(uint32_t*)map->getDataPtr();
pascal@18440 860
pascal@18440 861
pascal@18440 862 *width = w;
pascal@18440 863 *height = h;
pascal@18440 864
pascal@18440 865 return data;
pascal@18440 866 }
pascal@18440 867
pascal@18440 868 BEGIN_METHOD(PDFPAGE_image, GB_INTEGER x; GB_INTEGER y; GB_INTEGER w; GB_INTEGER h)
pascal@18440 869
pascal@18440 870 GB_IMAGE img = NULL;
pascal@18440 871 uint32_t *data;
pascal@18440 872 int32_t x,y, w, h;
pascal@18440 873
pascal@18440 874 x = VARGOPT(x, 0);
pascal@18440 875 y = VARGOPT(y, 0);
pascal@18440 876 w = VARGOPT(w, -1);
pascal@18440 877 h = VARGOPT(h, -1);
pascal@18440 878
pascal@18440 879 data = get_page_data(THIS, x, y, &w, &h, THIS->scale, THIS->rotation);
pascal@18440 880 if (!data) { GB.ReturnNull(); return; }
pascal@18440 881 GB.Image.Create(&img, data, w, h, GB_IMAGE_RGB);
pascal@18440 882 GB.ReturnObject(img);
pascal@18440 883
pascal@18440 884 END_METHOD
pascal@18440 885
pascal@18440 886 BEGIN_PROPERTY (PDFPAGE_property_image)
pascal@18440 887
pascal@18440 888 int32_t w=-1;
pascal@18440 889 int32_t h=-1;
pascal@18440 890 GB_IMAGE img = NULL;
pascal@18440 891 uint32_t *data;
pascal@18440 892
pascal@18440 893 data = get_page_data(THIS, 0, 0, &w, &h, THIS->scale, THIS->rotation);
pascal@18440 894 if (!data) { GB.ReturnNull(); return; }
pascal@18440 895 GB.Image.Create(&img, data, w, h, GB_IMAGE_RGB);
pascal@18440 896 GB.ReturnObject(img);
pascal@18440 897
pascal@18440 898 END_PROPERTY
pascal@18440 899
pascal@18440 900
pascal@18440 901 BEGIN_METHOD(PDFPAGE_picture, GB_INTEGER x; GB_INTEGER y; GB_INTEGER w; GB_INTEGER h)
pascal@18440 902
pascal@18440 903 GB_IMAGE img = NULL;
pascal@18440 904 uint32_t *data;
pascal@18440 905 int32_t x,y, w, h;
pascal@18440 906
pascal@18440 907 x = VARGOPT(x, 0);
pascal@18440 908 y = VARGOPT(y, 0);
pascal@18440 909 w = VARGOPT(w, -1);
pascal@18440 910 h = VARGOPT(h, -1);
pascal@18440 911
pascal@18440 912 data = get_page_data(THIS, x, y, &w, &h, THIS->scale, THIS->rotation);
pascal@18440 913 if (!data) { GB.ReturnNull(); return; }
pascal@18440 914 GB.Picture.Create(&img, data, w, h, GB_IMAGE_RGB);
pascal@18440 915 GB.ReturnObject(img);
pascal@18440 916
pascal@18440 917 END_METHOD
pascal@18440 918
pascal@18440 919 BEGIN_PROPERTY (PDFPAGE_property_picture)
pascal@18440 920
pascal@18440 921 int32_t w=-1;
pascal@18440 922 int32_t h=-1;
pascal@18440 923 GB_IMAGE img = NULL;
pascal@18440 924 uint32_t *data;
pascal@18440 925
pascal@18440 926 data = get_page_data(THIS, 0, 0, &w, &h, THIS->scale, THIS->rotation);
pascal@18440 927 if (!data) { GB.ReturnNull(); return; }
pascal@18440 928 GB.Picture.Create(&img, data, w, h, GB_IMAGE_RGB);
pascal@18440 929 GB.ReturnObject(img);
pascal@18440 930
pascal@18440 931 END_PROPERTY
pascal@18440 932
pascal@18440 933 BEGIN_METHOD(PDFPAGE_select, GB_INTEGER X; GB_INTEGER Y; GB_INTEGER W; GB_INTEGER H)
pascal@18440 934
pascal@18440 935 TextOutputDev *dev;
pascal@18440 936 GooString *str;
pascal@18440 937 Gfx *gfx;
pascal@18440 938 int32_t x,y,w,h;
pascal@18440 939
pascal@18440 940 x = VARGOPT(X, 0);
pascal@18440 941 y = VARGOPT(Y, 0);
pascal@18440 942 w = VARGOPT(W, (int32_t)THIS->page->getMediaWidth());
pascal@18440 943 h = VARGOPT(H, (int32_t)THIS->page->getMediaHeight());
pascal@18440 944
pascal@18440 945 #if POPPLER_VERSION_0_20
pascal@18440 946 dev = new TextOutputDev (NULL, gTrue, 0, gFalse, gFalse);
pascal@18440 947 gfx = THIS->page->createGfx(dev,72.0,72.0,0,gFalse,gTrue,-1, -1, -1, -1, gFalse, NULL, NULL);
pascal@18440 948 #else
pascal@18440 949 dev = new TextOutputDev (NULL, gTrue, gFalse, gFalse);
pascal@18440 950 gfx = THIS->page->createGfx(dev,72.0,72.0,0,gFalse,gTrue,-1, -1, -1, -1, \
pascal@18440 951 gFalse,THIS->doc->getCatalog (),NULL, NULL, NULL, NULL);
pascal@18440 952 #endif
pascal@18440 953
pascal@18440 954 THIS->page->display(gfx);
pascal@18440 955 dev->endPage();
pascal@18440 956
pascal@18440 957 str=dev->getText((double)x,(double)y,(double)(w+x),(double)(h+y));
pascal@18440 958
pascal@18440 959 delete gfx;
pascal@18440 960 delete dev;
pascal@18440 961
pascal@18440 962 if (!str)
pascal@18440 963 {
pascal@18440 964 GB.ReturnNewZeroString("");
pascal@18440 965 return;
pascal@18440 966 }
pascal@18440 967
pascal@18440 968 GB.ReturnNewString(str->getCString(),str->getLength());
pascal@18440 969 delete str;
pascal@18440 970
pascal@18440 971 END_METHOD
pascal@18440 972
pascal@18440 973 /*****************************************************************************
pascal@18440 974
pascal@18440 975 Bookmarks of a PDF page
pascal@18440 976
pascal@18440 977 ******************************************************************************/
pascal@18440 978
pascal@18440 979 void aux_fill_links(void *_object)
pascal@18440 980 {
pascal@18440 981 #if POPPLER_VERSION_0_20
pascal@18440 982 THIS->links = new Links (THIS->page->getAnnots ());
pascal@18440 983 #elif POPPLER_VERSION_0_17
pascal@18440 984 THIS->links = new Links (THIS->page->getAnnots (THIS->doc->getCatalog()));
pascal@18440 985 #else
pascal@18440 986 Object obj;
pascal@18440 987
pascal@18440 988 THIS->links = new Links (THIS->page->getAnnots (&obj),THIS->doc->getCatalog()->getBaseURI ());
pascal@18440 989 obj.free();
pascal@18440 990 #endif
pascal@18440 991 }
pascal@18440 992
pascal@18440 993 BEGIN_PROPERTY (PDFPAGELINKS_count)
pascal@18440 994
pascal@18440 995 if (!THIS->links) aux_fill_links(_object);
pascal@18440 996 if (!THIS->links) { GB.ReturnInteger(0); return; }
pascal@18440 997 GB.ReturnInteger(THIS->links->getNumLinks());
pascal@18440 998
pascal@18440 999
pascal@18440 1000 END_PROPERTY
pascal@18440 1001
pascal@18440 1002 BEGIN_METHOD (PDFPAGELINKS_get,GB_INTEGER ind;)
pascal@18440 1003
pascal@18440 1004 bool pok=true;
pascal@18440 1005
pascal@18440 1006 if (!THIS->links) aux_fill_links(_object);
pascal@18440 1007 if (!THIS->links) pok=false;
pascal@18440 1008 else
pascal@18440 1009 {
pascal@18440 1010 if (VARG(ind)<0) pok=false;
pascal@18440 1011 else
pascal@18440 1012 {
pascal@18440 1013 if (VARG(ind)>=THIS->links->getNumLinks()) pok=false;
pascal@18440 1014 }
pascal@18440 1015 }
pascal@18440 1016
pascal@18440 1017 if (!pok) { GB.Error("Out of bounds"); GB.ReturnNull(); return; }
pascal@18440 1018
pascal@18440 1019 THIS->lcurrent=VARG(ind);
pascal@18440 1020 THIS->action=THIS->links->getLink(THIS->lcurrent)->getAction();
pascal@18440 1021
pascal@18440 1022 RETURN_SELF();
pascal@18440 1023
pascal@18440 1024 END_METHOD
pascal@18440 1025
pascal@18440 1026 BEGIN_PROPERTY (PDFPAGELINKDATA_parameters)
pascal@18440 1027
pascal@18440 1028 if (THIS->action->getKind() != actionLaunch )
pascal@18440 1029 {
pascal@18440 1030 GB.ReturnNewZeroString("");
pascal@18440 1031 return;
pascal@18440 1032 }
pascal@18440 1033
pascal@18440 1034 GB.ReturnNewZeroString(((LinkLaunch*)THIS->action)->getParams()->getCString());
pascal@18440 1035
pascal@18440 1036 END_PROPERTY
pascal@18440 1037
pascal@18440 1038 BEGIN_PROPERTY (PDFPAGELINKDATA_uri)
pascal@18440 1039
pascal@18440 1040 char *uri;
pascal@18440 1041
pascal@18440 1042 uri=aux_get_target_from_action(THIS->action);
pascal@18440 1043
pascal@18440 1044 GB.ReturnNewZeroString(uri);
pascal@18440 1045 if (uri) GB.FreeString(&uri);
pascal@18440 1046
pascal@18440 1047 END_PROPERTY
pascal@18440 1048
pascal@18440 1049 BEGIN_PROPERTY(PDFPAGELINKDATA_left)
pascal@18440 1050
pascal@18440 1051 int32_t vl;
pascal@18440 1052
pascal@18440 1053 aux_get_dimensions_from_action(THIS->action,&vl, NULL, NULL, NULL);
pascal@18440 1054 GB.ReturnInteger(vl);
pascal@18440 1055
pascal@18440 1056 END_PROPERTY
pascal@18440 1057
pascal@18440 1058 BEGIN_PROPERTY(PDFPAGELINKDATA_right)
pascal@18440 1059
pascal@18440 1060 int32_t vl;
pascal@18440 1061
pascal@18440 1062 aux_get_dimensions_from_action(THIS->action,NULL,&vl, NULL, NULL);
pascal@18440 1063 GB.ReturnInteger(vl);
pascal@18440 1064
pascal@18440 1065 END_PROPERTY
pascal@18440 1066
pascal@18440 1067 BEGIN_PROPERTY(PDFPAGELINKDATA_top)
pascal@18440 1068
pascal@18440 1069 int32_t vl;
pascal@18440 1070
pascal@18440 1071 aux_get_dimensions_from_action(THIS->action,NULL,NULL,&vl, NULL);
pascal@18440 1072 GB.ReturnInteger(vl);
pascal@18440 1073
pascal@18440 1074 END_PROPERTY
pascal@18440 1075
pascal@18440 1076 BEGIN_PROPERTY(PDFPAGELINKDATA_bottom)
pascal@18440 1077
pascal@18440 1078 int32_t vl;
pascal@18440 1079
pascal@18440 1080 aux_get_dimensions_from_action(THIS->action,NULL, NULL, NULL,&vl);
pascal@18440 1081
pascal@18440 1082 GB.ReturnInteger(vl);
pascal@18440 1083
pascal@18440 1084 END_PROPERTY
pascal@18440 1085
pascal@18440 1086 BEGIN_PROPERTY(PDFPAGELINKDATA_zoom)
pascal@18440 1087
pascal@18440 1088 GB.ReturnFloat(aux_get_zoom_from_action(THIS->action));
pascal@18440 1089
pascal@18440 1090 END_PROPERTY
pascal@18440 1091
pascal@18440 1092 BEGIN_PROPERTY(PDFPAGELINKDATA_page)
pascal@18440 1093
pascal@18440 1094 GB.ReturnInteger(aux_get_page_from_action(_object,THIS->action));
pascal@18440 1095
pascal@18440 1096 END_PROPERTY
pascal@18440 1097
pascal@18440 1098 BEGIN_PROPERTY (PDFPAGELINKDATA_type)
pascal@18440 1099
pascal@18440 1100 GB.ReturnInteger ( (int32_t)THIS->action->getKind() );
pascal@18440 1101
pascal@18440 1102 END_PROPERTY
pascal@18440 1103
pascal@18440 1104 BEGIN_PROPERTY(PDFPAGELINKDATA_check)
pascal@18440 1105
pascal@18440 1106 if (THIS->action)
pascal@18440 1107 RETURN_SELF();
pascal@18440 1108 else
pascal@18440 1109 GB.ReturnNull();
pascal@18440 1110
pascal@18440 1111 END_PROPERTY
pascal@18440 1112
pascal@18440 1113 void aux_get_link_dimensions(void *_object,int32_t *left, int32_t *top, int32_t *width, int32_t *height)
pascal@18440 1114 {
pascal@18440 1115 double l,t,w,h;
pascal@18440 1116 double pw,ph;
pascal@18440 1117
pascal@18440 1118 pw=THIS->page->getMediaWidth();
pascal@18440 1119 ph=THIS->page->getMediaHeight();
pascal@18440 1120
pascal@18440 1121 THIS->links->getLink(THIS->lcurrent)->getRect(&l, &t, &w, &h);
pascal@18440 1122 w=w-l;
pascal@18440 1123 h=h-t;
pascal@18440 1124
pascal@18440 1125 switch (THIS->rotation)
pascal@18440 1126 {
pascal@18440 1127 case 0:
pascal@18440 1128 if (left) *left=(int32_t)(l*THIS->scale);
pascal@18440 1129 if (top) *top=(int32_t)((ph-t-h)*THIS->scale);
pascal@18440 1130 if (width) *width=(int32_t)(w*THIS->scale);
pascal@18440 1131 if (height) *height=(int32_t)(h*THIS->scale);
pascal@18440 1132 break;
pascal@18440 1133
pascal@18440 1134 case 90:
pascal@18440 1135 if (top) *top=(int32_t)(l*THIS->scale);
pascal@18440 1136 if (left) *left=(int32_t)(t*THIS->scale);
pascal@18440 1137 if (height) *height=(int32_t)(w*THIS->scale);
pascal@18440 1138 if (width) *width=(int32_t)(h*THIS->scale);
pascal@18440 1139 break;
pascal@18440 1140
pascal@18440 1141 case 180:
pascal@18440 1142 if (left) *left=(int32_t)((l-w)*THIS->scale);
pascal@18440 1143 if (top) *top=(int32_t)(t*THIS->scale);
pascal@18440 1144 if (width) *width=(int32_t)(w*THIS->scale);
pascal@18440 1145 if (height) *height=(int32_t)(h*THIS->scale);
pascal@18440 1146 break;
pascal@18440 1147
pascal@18440 1148 case 270:
pascal@18440 1149 if (top) *top=(int32_t)((pw-l-w)*THIS->scale);
pascal@18440 1150 if (left) *left=(int32_t)((ph-t-h)*THIS->scale);
pascal@18440 1151 if (height) *height=(int32_t)(w*THIS->scale);
pascal@18440 1152 if (width) *width=(int32_t)(h*THIS->scale);
pascal@18440 1153 break;
pascal@18440 1154 }
pascal@18440 1155
pascal@18440 1156 }
pascal@18440 1157
pascal@18440 1158 BEGIN_PROPERTY (PDFPAGELINK_width)
pascal@18440 1159
pascal@18440 1160 int32_t vl;
pascal@18440 1161
pascal@18440 1162 aux_get_link_dimensions(_object,NULL,NULL,&vl,NULL);
pascal@18440 1163 GB.ReturnInteger(vl);
pascal@18440 1164
pascal@18440 1165 END_PROPERTY
pascal@18440 1166
pascal@18440 1167 BEGIN_PROPERTY (PDFPAGELINK_height)
pascal@18440 1168
pascal@18440 1169 int32_t vl;
pascal@18440 1170
pascal@18440 1171 aux_get_link_dimensions(_object,NULL,NULL,NULL,&vl);
pascal@18440 1172 GB.ReturnInteger(vl);
pascal@18440 1173
pascal@18440 1174
pascal@18440 1175 END_PROPERTY
pascal@18440 1176
pascal@18440 1177 BEGIN_PROPERTY (PDFPAGELINK_left)
pascal@18440 1178
pascal@18440 1179 int32_t vl;
pascal@18440 1180
pascal@18440 1181 aux_get_link_dimensions(_object,&vl,NULL,NULL,NULL);
pascal@18440 1182 GB.ReturnInteger(vl);
pascal@18440 1183
pascal@18440 1184
pascal@18440 1185 END_PROPERTY
pascal@18440 1186
pascal@18440 1187 BEGIN_PROPERTY (PDFPAGELINK_top)
pascal@18440 1188
pascal@18440 1189 int32_t vl;
pascal@18440 1190
pascal@18440 1191 aux_get_link_dimensions(_object,NULL,&vl,NULL,NULL);
pascal@18440 1192 GB.ReturnInteger(vl);
pascal@18440 1193
pascal@18440 1194 END_PROPERTY
pascal@18440 1195
pascal@18440 1196 /*****************************************************************************
pascal@18440 1197
pascal@18440 1198 Finding a text in a PDF page
pascal@18440 1199
pascal@18440 1200 ******************************************************************************/
pascal@18440 1201
pascal@18440 1202 BEGIN_METHOD (PDFPAGE_find,GB_STRING Text; GB_BOOLEAN Sensitive;)
pascal@18440 1203
pascal@18440 1204 TextOutputDev *textdev;
pascal@18440 1205 double x0=0, y0=0;
pascal@18440 1206 double x1, y1;
pascal@18440 1207 FoundRect *el;
pascal@18440 1208 Unicode *block=NULL;
pascal@18440 1209 int32_t nlen=0;
pascal@18440 1210 bool sensitive=false;
pascal@18440 1211
pascal@18440 1212 // TODO: Use UCS-4BE on big endian systems?
pascal@18440 1213 if (GB.ConvString ((char **)(void *)&block,STRING(Text),LENGTH(Text),"UTF-8","UCS-4LE"))
pascal@18440 1214 {
pascal@18440 1215 GB.Error("Invalid UTF-8 string");
pascal@18440 1216 return;
pascal@18440 1217 }
pascal@18440 1218
pascal@18440 1219 nlen=GB.StringLength((char*)block)/sizeof(Unicode);
pascal@18440 1220
pascal@18440 1221 if (!MISSING(Sensitive)) sensitive=VARG(Sensitive);
pascal@18440 1222
pascal@18440 1223 #if POPPLER_VERSION_0_20
pascal@18440 1224 textdev = new TextOutputDev (NULL, true, 0, false, false);
pascal@18440 1225 THIS->page->display (textdev, 72, 72, 0, false, false, false);
pascal@18440 1226 #else
pascal@18440 1227 textdev = new TextOutputDev (NULL, true, false, false);
pascal@18440 1228 THIS->page->display (textdev, 72, 72, 0, false, false, false, THIS->doc->getCatalog());
pascal@18440 1229 #endif
pascal@18440 1230
pascal@18440 1231 if (THIS->Found) { GB.FreeArray(POINTER(&THIS->Found)); THIS->Found=NULL; }
pascal@18440 1232
pascal@18440 1233 #if POPPLER_VERSION_0_20
pascal@18440 1234 while (textdev->findText (block,nlen,gFalse,gTrue,gTrue,gFalse,sensitive,gFalse,gFalse,&x0,&y0,&x1,&y1))
pascal@18440 1235 #else
pascal@18440 1236 while (textdev->findText (block,nlen,gFalse,gTrue,gTrue,gFalse,sensitive,gFalse,&x0,&y0,&x1,&y1))
pascal@18440 1237 #endif
pascal@18440 1238 {
pascal@18440 1239 if (!THIS->Found) {
pascal@18440 1240 GB.NewArray(POINTER(&THIS->Found),sizeof(FoundRect),1);
pascal@18440 1241 }
pascal@18440 1242 else {
pascal@18440 1243 GB.Add(POINTER(&THIS->Found));
pascal@18440 1244 }
pascal@18440 1245
pascal@18440 1246 el=(FoundRect*)&((FoundRect*)THIS->Found)[GB.Count(POINTER(THIS->Found))-1];
pascal@18440 1247
pascal@18440 1248 switch (THIS->rotation)
pascal@18440 1249 {
pascal@18440 1250 case 0:
pascal@18440 1251 el->x0=(int32_t)(x0*THIS->scale);
pascal@18440 1252 el->y0=(int32_t)(y0*THIS->scale);
pascal@18440 1253 el->x1=(int32_t)((x1-x0)*THIS->scale);
pascal@18440 1254 el->y1=(int32_t)((y1-y0)*THIS->scale);
pascal@18440 1255 break;
pascal@18440 1256
pascal@18440 1257 case 90:
pascal@18440 1258 el->y1=(int32_t)((x1-x0)*THIS->scale);
pascal@18440 1259 el->x1=(int32_t)(y1-y0);
pascal@18440 1260 el->y0=(int32_t)(x0*THIS->scale);
pascal@18440 1261 el->x0=(int32_t)((THIS->page->getMediaHeight()-y0-el->x1)*THIS->scale);
pascal@18440 1262 el->x1=(int32_t)(el->x1*THIS->scale);
pascal@18440 1263 break;
pascal@18440 1264
pascal@18440 1265 case 180:
pascal@18440 1266 el->x1=(int32_t)(x1-x0);
pascal@18440 1267 el->y1=(int32_t)(y1-y0);
pascal@18440 1268 el->x0=(int32_t)((THIS->page->getMediaWidth()-x0-el->x1)*THIS->scale);
pascal@18440 1269 el->y0=(int32_t)((THIS->page->getMediaHeight()-y0-el->y1)*THIS->scale);
pascal@18440 1270 el->x1=(int32_t)(el->x1*THIS->scale);
pascal@18440 1271 el->y1=(int32_t)(el->y1*THIS->scale);
pascal@18440 1272 break;
pascal@18440 1273
pascal@18440 1274 case 270:
pascal@18440 1275 el->x1=(int32_t)((y1-y0)*THIS->scale);
pascal@18440 1276 el->y1=(int32_t)(x1-x0);
pascal@18440 1277 el->x0=(int32_t)(y0*THIS->scale);
pascal@18440 1278 el->y0=(int32_t)((THIS->page->getMediaWidth()-x0-el->y1)*THIS->scale);
pascal@18440 1279 el->y1=(int32_t)(el->y1*THIS->scale);
pascal@18440 1280 break;
pascal@18440 1281
pascal@18440 1282 }
pascal@18440 1283 }
pascal@18440 1284
pascal@18440 1285 delete textdev;
pascal@18440 1286
pascal@18440 1287
pascal@18440 1288 END_METHOD
pascal@18440 1289
pascal@18440 1290
pascal@18440 1291 BEGIN_METHOD (PDFPAGERESULT_get,GB_INTEGER Index;)
pascal@18440 1292
pascal@18440 1293 bool bok=true;
pascal@18440 1294
pascal@18440 1295 if (!THIS->Found) bok=false;
pascal@18440 1296 else
pascal@18440 1297 {
pascal@18440 1298 if (VARG(Index)<0) bok=false;
pascal@18440 1299 if (VARG(Index)>= GB.Count(POINTER(THIS->Found)) ) bok=false;
pascal@18440 1300 }
pascal@18440 1301 if (!bok) { GB.Error("Out of bounds"); GB.ReturnNull(); return; }
pascal@18440 1302
pascal@18440 1303 THIS->fcurrent=VARG(Index);
pascal@18440 1304 RETURN_SELF();
pascal@18440 1305
pascal@18440 1306 END_METHOD
pascal@18440 1307
pascal@18440 1308 BEGIN_PROPERTY (PDFPAGERESULT_count)
pascal@18440 1309
pascal@18440 1310 if (!THIS->Found) { GB.ReturnInteger(0); return; }
pascal@18440 1311 GB.ReturnInteger( GB.Count(POINTER(THIS->Found)) );
pascal@18440 1312
pascal@18440 1313 END_PROPERTY
pascal@18440 1314
pascal@18440 1315 BEGIN_PROPERTY (PDFPAGERESULT_width)
pascal@18440 1316
pascal@18440 1317 FoundRect *el=(FoundRect*)&((FoundRect*)THIS->Found)[THIS->fcurrent];
pascal@18440 1318 GB.ReturnInteger((int32_t)el->x1);
pascal@18440 1319
pascal@18440 1320 END_PROPERTY
pascal@18440 1321
pascal@18440 1322 BEGIN_PROPERTY (PDFPAGERESULT_height)
pascal@18440 1323
pascal@18440 1324 FoundRect *el=(FoundRect*)&((FoundRect*)THIS->Found)[THIS->fcurrent];
pascal@18440 1325 GB.ReturnInteger((int32_t)el->y1);
pascal@18440 1326
pascal@18440 1327 END_PROPERTY
pascal@18440 1328
pascal@18440 1329 BEGIN_PROPERTY (PDFPAGERESULT_left)
pascal@18440 1330
pascal@18440 1331 FoundRect *el=(FoundRect*)&((FoundRect*)THIS->Found)[THIS->fcurrent];
pascal@18440 1332 GB.ReturnInteger((int32_t)el->x0);
pascal@18440 1333
pascal@18440 1334 END_PROPERTY
pascal@18440 1335
pascal@18440 1336 BEGIN_PROPERTY (PDFPAGERESULT_top)
pascal@18440 1337
pascal@18440 1338 FoundRect *el=(FoundRect*)&((FoundRect*)THIS->Found)[THIS->fcurrent];
pascal@18440 1339 GB.ReturnInteger((int32_t)el->y0);
pascal@18440 1340
pascal@18440 1341 END_PROPERTY
pascal@18440 1342
pascal@18440 1343 /**********************************************************************
pascal@18440 1344
pascal@18440 1345 Gambas Interface
pascal@18440 1346
pascal@18440 1347 ***********************************************************************/
pascal@18440 1348
pascal@18440 1349
pascal@18440 1350 GB_DESC PdfResultItemDesc[]=
pascal@18440 1351 {
pascal@18440 1352 GB_DECLARE(".PdfResultItem",0), GB_VIRTUAL_CLASS(),
pascal@18440 1353
pascal@18440 1354 GB_PROPERTY_READ("Left","i",PDFPAGERESULT_left),
pascal@18440 1355 GB_PROPERTY_READ("Top","i",PDFPAGERESULT_top),
pascal@18440 1356 GB_PROPERTY_READ("Width","i",PDFPAGERESULT_width),
pascal@18440 1357 GB_PROPERTY_READ("Height","i",PDFPAGERESULT_height),
pascal@18440 1358
pascal@18440 1359 GB_END_DECLARE
pascal@18440 1360 };
pascal@18440 1361
pascal@18440 1362 GB_DESC PdfResultDesc[]=
pascal@18440 1363 {
pascal@18440 1364 GB_DECLARE(".PdfResult",0), GB_VIRTUAL_CLASS(),
pascal@18440 1365
pascal@18440 1366 GB_METHOD("_get",".PdfResultItem",PDFPAGERESULT_get,"(Index)i"),
pascal@18440 1367 GB_PROPERTY_READ("Count","i",PDFPAGERESULT_count),
pascal@18440 1368
pascal@18440 1369 GB_END_DECLARE
pascal@18440 1370 };
pascal@18440 1371
pascal@18440 1372
pascal@18440 1373 GB_DESC PdfLinkDataDesc[]=
pascal@18440 1374 {
pascal@18440 1375 GB_DECLARE(".PdfLinkData",0), GB_VIRTUAL_CLASS(),
pascal@18440 1376
pascal@18440 1377 GB_PROPERTY_READ("Type","i",PDFPAGELINKDATA_type),
pascal@18440 1378 GB_PROPERTY_READ("Target","s",PDFPAGELINKDATA_uri),
pascal@18440 1379 GB_PROPERTY_READ("Parameters","s",PDFPAGELINKDATA_parameters),
pascal@18440 1380 GB_PROPERTY_READ("Page","i",PDFPAGELINKDATA_page),
pascal@18440 1381 GB_PROPERTY_READ("Left","i",PDFPAGELINKDATA_left),
pascal@18440 1382 GB_PROPERTY_READ("Top","i",PDFPAGELINKDATA_top),
pascal@18440 1383 GB_PROPERTY_READ("Right","i",PDFPAGELINKDATA_right),
pascal@18440 1384 GB_PROPERTY_READ("Bottom","i",PDFPAGELINKDATA_bottom),
pascal@18440 1385 GB_PROPERTY_READ("Zoom","f",PDFPAGELINKDATA_zoom),
pascal@18440 1386
pascal@18440 1387 GB_END_DECLARE
pascal@18440 1388 };
pascal@18440 1389
pascal@18440 1390 GB_DESC PdfLinkDesc[]=
pascal@18440 1391 {
pascal@18440 1392 GB_DECLARE(".PdfLink",0), GB_VIRTUAL_CLASS(),
pascal@18440 1393
pascal@18440 1394 GB_PROPERTY_READ("Left","i",PDFPAGELINK_left),
pascal@18440 1395 GB_PROPERTY_READ("Top","i",PDFPAGELINK_top),
pascal@18440 1396 GB_PROPERTY_READ("Width","i",PDFPAGELINK_width),
pascal@18440 1397 GB_PROPERTY_READ("Height","i",PDFPAGELINK_height),
pascal@18440 1398 GB_PROPERTY_READ("Data", ".PdfLinkData", PDFPAGELINKDATA_check),
pascal@18440 1399
pascal@18440 1400 GB_END_DECLARE
pascal@18440 1401 };
pascal@18440 1402
pascal@18440 1403 GB_DESC PdfIndexDesc[]=
pascal@18440 1404 {
pascal@18440 1405 GB_DECLARE(".PdfIndex",0), GB_VIRTUAL_CLASS(),
pascal@18440 1406
pascal@18440 1407 GB_PROPERTY("Expanded","b",PDFINDEX_is_open),
pascal@18440 1408 GB_PROPERTY_READ("Count","i",PDFINDEX_count),
pascal@18440 1409 GB_PROPERTY_READ("HasChildren","b",PDFINDEX_has_children),
pascal@18440 1410 GB_PROPERTY_READ("Title","s",PDFINDEX_title),
pascal@18440 1411
pascal@18440 1412 GB_PROPERTY_READ("Data", ".PdfLinkData", PDFPAGELINKDATA_check),
pascal@18440 1413 GB_METHOD("MovePrevious","b",PDFINDEX_prev,0),
pascal@18440 1414 GB_METHOD("MoveNext","b",PDFINDEX_next,0),
pascal@18440 1415 GB_METHOD("MoveChild","b",PDFINDEX_child,0),
pascal@18440 1416 GB_METHOD("MoveParent","b",PDFINDEX_parent,0),
pascal@18440 1417 GB_METHOD("MoveRoot",0,PDFINDEX_root,0),
pascal@18440 1418
pascal@18440 1419 GB_END_DECLARE
pascal@18440 1420 };
pascal@18440 1421
pascal@18440 1422
pascal@18440 1423 GB_DESC PdfPageDesc[]=
pascal@18440 1424 {
pascal@18440 1425 GB_DECLARE(".PdfPage",0), GB_VIRTUAL_CLASS(),
pascal@18440 1426
pascal@18440 1427 GB_PROPERTY_READ("W","f",PDFPAGE_width),
pascal@18440 1428 GB_PROPERTY_READ("H","f",PDFPAGE_height),
pascal@18440 1429 GB_PROPERTY_READ("Width","f",PDFPAGE_width),
pascal@18440 1430 GB_PROPERTY_READ("Height","f",PDFPAGE_height),
pascal@18440 1431 GB_PROPERTY_READ("Picture","Picture",PDFPAGE_property_picture),
pascal@18440 1432 GB_PROPERTY_READ("Image","Image",PDFPAGE_property_image),
pascal@18440 1433 GB_PROPERTY_SELF("Result",".PdfResult"),
pascal@18440 1434
pascal@18440 1435 GB_METHOD("GetImage","Image",PDFPAGE_image,"[(X)i(Y)i(Width)i(Height)i]"),
pascal@18440 1436 GB_METHOD("GetPicture","Picture",PDFPAGE_picture,"[(X)i(Y)i(Width)i(Height)i]"),
pascal@18440 1437 GB_METHOD("Find","b",PDFPAGE_find,"(Text)s[(CaseSensitive)b]"),
pascal@18440 1438 GB_METHOD("Select","s",PDFPAGE_select,"[(X)i(Y)i(W)i(H)i]"),
pascal@18440 1439
pascal@18440 1440 GB_METHOD("_get",".PdfLink",PDFPAGELINKS_get,"(Index)i"),
pascal@18440 1441 GB_PROPERTY_READ("Count","i",PDFPAGELINKS_count),
pascal@18440 1442
pascal@18440 1443 GB_END_DECLARE
pascal@18440 1444 };
pascal@18440 1445
pascal@18440 1446 GB_DESC PdfDocumentInfo[] =
pascal@18440 1447 {
pascal@18440 1448 GB_DECLARE(".PdfInfo",0), GB_VIRTUAL_CLASS(),
pascal@18440 1449
pascal@18440 1450 GB_PROPERTY_READ("Title","s",PDFINFO_title),
pascal@18440 1451 GB_PROPERTY_READ("Format","s",PDFINFO_format),
pascal@18440 1452 GB_PROPERTY_READ("Author","s",PDFINFO_author),
pascal@18440 1453 GB_PROPERTY_READ("Subject","s",PDFINFO_subject),
pascal@18440 1454 GB_PROPERTY_READ("Keywords","s",PDFINFO_keywords),
pascal@18440 1455 GB_PROPERTY_READ("Creator","s",PDFINFO_creator),
pascal@18440 1456 GB_PROPERTY_READ("Producer","s",PDFINFO_producer),
pascal@18440 1457 GB_PROPERTY_READ("CreationDate","d",PDFINFO_creation),
pascal@18440 1458 GB_PROPERTY_READ("ModificationDate","d",PDFINFO_modification),
pascal@18440 1459 GB_PROPERTY_READ("Linearized","b",PDFINFO_linearized),
pascal@18440 1460 GB_PROPERTY_READ("Layout","i",PDFINFO_layout),
pascal@18440 1461 GB_PROPERTY_READ("Mode","i",PDFINFO_mode),
pascal@18440 1462 GB_PROPERTY_READ("CanCopy","b",PDFINFO_cancopy),
pascal@18440 1463 GB_PROPERTY_READ("CanModify","b",PDFINFO_canmodify),
pascal@18440 1464 GB_PROPERTY_READ("CanPrint","b",PDFINFO_canprint),
pascal@18440 1465 GB_PROPERTY_READ("CanAddNotes","b",PDFINFO_canaddnotes),
pascal@18440 1466
pascal@18440 1467 GB_END_DECLARE
pascal@18440 1468 };
pascal@18440 1469
pascal@18440 1470 GB_DESC PdfLayoutDesc[] =
pascal@18440 1471 {
pascal@18440 1472
pascal@18440 1473 GB_DECLARE("PdfLayout", 0), GB_NOT_CREATABLE(),
pascal@18440 1474
pascal@18440 1475 GB_CONSTANT("Unset","i",Catalog::pageLayoutNone),
pascal@18440 1476 GB_CONSTANT("SinglePage","i",Catalog::pageLayoutSinglePage),
pascal@18440 1477 GB_CONSTANT("OneColumn","i",Catalog::pageLayoutOneColumn),
pascal@18440 1478 GB_CONSTANT("TwoColumnLeft","i",Catalog::pageLayoutTwoColumnLeft),
pascal@18440 1479 GB_CONSTANT("TwoColumnRight","i",Catalog::pageLayoutTwoColumnRight),
pascal@18440 1480 GB_CONSTANT("TwoPageLeft","i",Catalog::pageLayoutTwoPageLeft),
pascal@18440 1481 GB_CONSTANT("TwoPageRight","i",Catalog::pageLayoutTwoPageRight),
pascal@18440 1482
pascal@18440 1483 GB_END_DECLARE
pascal@18440 1484 };
pascal@18440 1485
pascal@18440 1486
pascal@18440 1487 GB_DESC PdfModeDesc[] =
pascal@18440 1488 {
pascal@18440 1489 GB_DECLARE("PdfPageMode",0), GB_NOT_CREATABLE(),
pascal@18440 1490
pascal@18440 1491 GB_CONSTANT("Unset","i",Catalog::pageModeNone),
pascal@18440 1492 GB_CONSTANT("UseOutlines","i",Catalog::pageModeOutlines),
pascal@18440 1493 GB_CONSTANT("UseThumbs","i",Catalog::pageModeThumbs),
pascal@18440 1494 GB_CONSTANT("FullScreen","i",Catalog::pageModeFullScreen),
pascal@18440 1495 GB_CONSTANT("UseOC","i",Catalog::pageModeOC),
pascal@18440 1496 GB_CONSTANT("UseAttachments","i",Catalog::pageModeAttach),
pascal@18440 1497
pascal@18440 1498 GB_END_DECLARE
pascal@18440 1499 };
pascal@18440 1500
pascal@18440 1501 GB_DESC PdfDocumentDesc[] =
pascal@18440 1502 {
pascal@18440 1503
pascal@18440 1504 GB_DECLARE("PdfDocument", sizeof(CPDFDOCUMENT)),
pascal@18440 1505
pascal@18440 1506 GB_CONSTANT("Unknown","i",actionUnknown), /* unknown action */
pascal@18440 1507 GB_CONSTANT("Goto","i",actionGoTo), /* go to destination */
pascal@18440 1508 GB_CONSTANT("GotoRemote","i",actionGoToR), /* go to destination in new file */
pascal@18440 1509 GB_CONSTANT("Launch","i",actionLaunch), /* launch app or open doc. */
pascal@18440 1510 GB_CONSTANT("Uri","i",actionURI), /* URI */
pascal@18440 1511 GB_CONSTANT("Named","i",actionNamed), /* named action*/
pascal@18440 1512 GB_CONSTANT("Movie","i",actionMovie), /* movie action */
pascal@18440 1513
pascal@18440 1514 GB_CONSTANT("Normal","i",0),
pascal@18440 1515 GB_CONSTANT("Sideways","i",90),
pascal@18440 1516 GB_CONSTANT("Inverted","i",180),
pascal@18440 1517 GB_CONSTANT("SidewaysInverted","i",270),
pascal@18440 1518
pascal@18440 1519 GB_METHOD("_new", 0, PDFDOCUMENT_new, "[(File)s]"),
pascal@18440 1520 GB_METHOD("_free", 0, PDFDOCUMENT_free, 0),
pascal@18440 1521
pascal@18440 1522 GB_METHOD("Open",0,PDFDOCUMENT_open,"(File)s"),
pascal@18440 1523 GB_METHOD("Close",0,PDFDOCUMENT_close,0),
pascal@18440 1524 GB_METHOD("_get",".PdfPage",PDFDOCUMENT_get,"(Index)i"),
pascal@18440 1525
pascal@18440 1526 GB_PROPERTY("Zoom", "f", PDFDOCUMENT_scale),
pascal@18440 1527 GB_PROPERTY("Orientation", "i", PDFDOCUMENT_rotation),
pascal@18440 1528
pascal@18440 1529 GB_PROPERTY_READ("Ready","b",PDFDOCUMENT_ready),
pascal@18440 1530 GB_PROPERTY_READ("Count","i",PDFDOCUMENT_count),
pascal@18440 1531 GB_PROPERTY_READ("HasIndex","b",PDFDOCUMENT_has_index),
pascal@18440 1532 GB_PROPERTY_READ("Index",".PdfIndex",PDFDOCUMENT_index),
pascal@18440 1533 GB_PROPERTY_READ("Info",".PdfInfo",PDFDOCUMENT_info),
pascal@18440 1534
pascal@18440 1535 GB_END_DECLARE
pascal@18440 1536 };
pascal@18440 1537
pascal@18440 1538