Back to index

tetex-bin  3.0
Classes | Defines | Functions
pdfspecial.h File Reference
#include "numbers.h"
#include "pdfobj.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  xform_info

Defines

#define M_PI   (4.0*atan(1.0))

Functions

int pdf_parse_special (char *buffer, UNSIGNED_QUAD size, double x_user, double y_user)
void pdf_finish_specials (void)
pdf_objget_reference (char **start, char *end)
struct xform_infonew_xform_info (void)
void release_xform_info (struct xform_info *p)
int validate_image_xform_info (struct xform_info *p)
void add_xform_matrix (double xoff, double yoff, double xscale, double yscale, double rotate)
void pdf_special_ignore_colors (void)
double parse_one_unit (char **start, char *end)
void pdf_scale_image (struct xform_info *p)
pdf_objembed_image (char *filename, struct xform_info *p, double x_user, double y_user, char *objname)
void pdf_special_set_grow (double g)
double pdf_special_tell_grow (void)

Class Documentation

struct xform_info

Definition at line 32 of file pdfspecial.h.

Class Members
double c_llx
double c_lly
double c_urx
double c_ury
unsigned char clip
double depth
double height
double rotate
double scale
double u_llx
double u_lly
double u_urx
double u_ury
unsigned char user_bbox
double width
double xscale
double yscale

Define Documentation

#define M_PI   (4.0*atan(1.0))

Definition at line 99 of file pdfspecial.h.


Function Documentation

void add_xform_matrix ( double  xoff,
double  yoff,
double  xscale,
double  yscale,
double  rotate 
)

Definition at line 1650 of file pdfspecial.c.

{
  double c, s;
  c = ROUND(cos(rotate),1e-5);
  s = ROUND(sin(rotate),1e-5);
  sprintf (work_buffer, " %g %g %g %g %.2f %.2f cm",
          c*xscale, s*xscale, -s*yscale, c*yscale, xoff, yoff);
  pdf_doc_add_to_page (work_buffer, strlen(work_buffer));
}

Here is the call graph for this function:

Here is the caller graph for this function:

pdf_obj* embed_image ( char *  filename,
struct xform_info p,
double  x_user,
double  y_user,
char *  objname 
)

Definition at line 971 of file pdfspecial.c.

{
  pdf_obj *result = NULL;
  char *kpse_file_name;
  FILE *image_file;
  static char res_name[16];
  static long next_image = 1;
  sprintf (res_name, "Im%ld", next_image);
  if ((kpse_file_name = kpse_find_pict (filename)) &&
      (image_file = MFOPEN (kpse_file_name, FOPEN_RBIN_MODE))) {
    fprintf (stderr, "(%s", kpse_file_name);
    if (check_for_jpeg(image_file)) {
      result = jpeg_start_image(image_file);
      if (result)
       finish_image (result, p, res_name);
    }
#ifdef HAVE_LIBPNG
    else if (check_for_png(image_file)) {
      fprintf (stderr, "<PNG>");
      result = start_png_image (image_file, NULL);
      if (result)
       finish_image (result, p, res_name);
    }
#endif
    else if (check_for_pdf (image_file)) {
      fprintf (stderr, "<PDF>");
      result = pdf_include_page (image_file, p, res_name);
    }
    else if (check_for_mp (image_file)) {
      fprintf (stderr, "<MPOST>");
      result = mp_include (image_file, p, res_name, x_user, y_user);
    }
    /* Make sure we check for PS *after* checking for MP since
       MP is a special case of PS */
    else if (check_for_ps (image_file)) {
      fprintf (stderr, "<PS>");
      result = ps_include (kpse_file_name, p,
                        res_name, x_user, y_user);
    }
    else{
      fprintf (stderr, "<?>");
      result = ps_include (kpse_file_name, p,
                        res_name, x_user, y_user);
    }
    MFCLOSE (image_file);
    fprintf (stderr, ")");
  } else {
      fprintf (stderr, "\nError locating or opening file (%s)\n", filename);
  }
  if (result) { /* Put reference to object on page */
    next_image += 1;
    pdf_doc_add_to_page_xobjects (res_name, pdf_ref_obj(result));
    pdf_doc_add_to_page (" q", 2);
    /* Handle the conversion to PDF stream units here */
    add_xform_matrix (x_user, y_user,
                    p->xscale/pdf_dev_scale(), p->yscale/pdf_dev_scale(), p->rotate);
    if (p->depth != 0.0)
      add_xform_matrix (0.0, -p->depth, 1.0, 1.0, 0.0);
    sprintf (work_buffer, " /%s Do Q", res_name);
    pdf_doc_add_to_page (work_buffer, strlen(work_buffer));
  } else {
    fprintf (stderr, "\npdf: image inclusion failed for (%s).\n", filename);
  }
  if (objname != NULL && result != NULL) {
    add_reference (objname, pdf_link_obj (result), res_name);
    /* Read the explanation for the next line in do_ann() */
    release_reference (objname);
  }
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

pdf_obj* get_reference ( char **  start,
char *  end 
)

Definition at line 316 of file ebb.c.

{
  fprintf (stderr, "get_reference():  This should never have been called\n");
  return NULL;
}

Here is the call graph for this function:

struct xform_info* new_xform_info ( void  ) [read]

Definition at line 235 of file pdfspecial.c.

{
  struct xform_info *result;
  result = NEW (1, struct xform_info);
  result -> width = 0.0;
  result -> height = 0.0;
  result -> depth = 0.0;
  result -> scale = 0.0;
  result -> xscale = 0.0;
  result -> yscale = 0.0;
  result -> rotate = 0.0;
  result -> user_bbox = 0;
  result -> clip = 0;
 /* These next two must be initialized be cause
    they represent the reference point even
    if the user doesn't specify one.  We must
    have a reference point */
  result -> u_llx = 0.0;
  result -> u_lly = 0.0;
  return result;
}

Here is the caller graph for this function:

double parse_one_unit ( char **  start,
char *  end 
)

Definition at line 326 of file pdfspecial.c.

{
  int i;
  char *unit_string = NULL, *save = *start;
  double result = -1.0;
  int errors = 0;
  skip_white(start, end);
  if ((unit_string = parse_c_ident(start, end)) != NULL) {
    for (i=0; i<sizeof(units)/sizeof(units[0]); i++) {
      if (!strcmp (units[i].s, unit_string))
       break;
    }
    if (i == sizeof(units)/sizeof(units[0])) {
      fprintf (stderr,
              "\n%s: Invalid unit of measurement (should be in, cm, pt, etc.)\n", unit_string);
      errors = 1;
    }
    if (i != sizeof(units)/sizeof(units[0]) && !units[i].is_true_unit)
      result = units[i].units;
    /* If these are "true" units, we must pre-shrink since the entire
       document is magnified */
    if (i != sizeof(units)/sizeof(units[0]) && units[i].is_true_unit)
      result = units[i].units/dvi_tell_mag();
    RELEASE (unit_string);
  }
  if (!unit_string || errors) {
    fprintf (stderr, "\nExpecting a unit here (e.g., in, cm, pt)\n");
    *start = save; 
    dump(*start, end);
  }
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1493 of file pdfspecial.c.

{
  int i;
  /* Flush out any pending objects that weren't properly closeed.
     Threads never get closed.  Is this a bug? */
  for (i=0; i<number_named_references; i++) {
    pdf_release_obj (named_references[i].object_ref);
    if (named_references[i].object != NULL) {
      pdf_release_obj (named_references[i].object);
      named_references[i].object = NULL;
    }
    if (named_references[i].res_name != NULL) {
      RELEASE (named_references[i].res_name);
      named_references[i].res_name = NULL;
    }
    RELEASE (named_references[i].name);
  }
  if (number_named_references > 0)
    RELEASE (named_references);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int pdf_parse_special ( char *  buffer,
UNSIGNED_QUAD  size,
double  x_user,
double  y_user 
)

Definition at line 1514 of file pdfspecial.c.

{
  int pdfmark, result=0;
  char *start = buffer, *end;
  end = buffer + size;

#ifdef MEM_DEBUG
MEM_START
#endif

  if (is_pdf_special(&start, end)) {
    result = 1; /* This means it really was a pdf special.  It doesn't
                 mean it succeeded */
    /* Must have a pdf special */
    pdfmark = parse_pdfmark(&start, end);
    switch (pdfmark) {
    case ANN:
      do_ann(&start, end);
      break;
    case BANN:
      do_bann(&start, end);
      break;
    case LINK_ANNOT:
      dev_link_annot(1);
      break;
    case NOLINK_ANNOT:
      dev_link_annot(0);
      break;
    case EANN:
      do_eann(&start, end);
      break;
    case OUTLINE:
      do_outline(&start, end);
      break;
    case ARTICLE:
      do_article(&start, end);
      break;
    case BEAD:
      do_bead(&start, end);
      break;
    case DEST:
      do_dest(&start, end);
      break;
    case DOCINFO:
      do_docinfo(&start, end);
      break;
    case DOCVIEW:
      do_docview(&start, end);
      break;
    case OBJ:
      do_obj(&start, end);
      break;
    case CONTENT:
      do_content(&start, end, x_user, y_user);
      break;
    case PUT:
      do_put(&start, end);
      break;
    case CLOSE:
      do_close(&start, end);
      break;
    case BOP:
      do_bop(&start, end);
      break;
    case EOP:
      do_eop(&start, end);
      break;
    case EPDF:
      do_image(&start, end, x_user, y_user);
      break;
    case IMAGE:
      do_image(&start, end, x_user, y_user);
      break;
    case BGCOLOR:
      if (!ignore_colors)
       do_bgcolor (&start, end);
      break;
    case SCOLOR:
      if (!ignore_colors)
       do_scolor (&start, end);
      break;
    case BCOLOR:
      if (!ignore_colors)
       do_bcolor (&start, end);
      break;
    case ECOLOR:
      if (!ignore_colors)
       do_ecolor ();
      break;
    case BGRAY:
      do_bgray (&start, end);
      break;
    case EGRAY:
      do_egray ();
      break;
    case BXFORM:
      do_bxform (&start, end, x_user, y_user);
      break;
    case EXFORM:
      do_exform ();
      break;
    case DVIPDFM_PAGE_SIZE:
      do_pagesize(&start, end);
      break;
    case BXOBJ:
      do_bxobj (&start, end, x_user, y_user);
      break;
    case EXOBJ:
      do_exobj ();
      break;
    case UXOBJ:
      do_uxobj (&start, end, x_user, y_user);
      break;
    default:
      dump (start, end);
      fprintf (stderr, "Invalid pdf special ignored\n");
      break;
    }
    skip_white (&start, end);
    if (start < end) {
      fprintf (stderr, "\nUnparsed material at end of special ignored...");
      dump (start, end);
    }
  } else {
    result = 0;
  }
#ifdef MEM_DEBUG
MEM_END
#endif
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pdf_scale_image ( struct xform_info p)

Definition at line 1696 of file pdfspecial.c.

{
  double xscale = 1.0, yscale = 1.0, nat_width, nat_height;
  if (p->user_bbox) {  /* Did user override natural bounding box */
    nat_width  = p->u_urx - p->u_llx;
    nat_height = p->u_ury - p->u_lly;
  } else {           /* If not, use media width and height */
    nat_width  = p->c_urx - p->c_llx;
    nat_height = p->c_ury - p->c_lly;
    p->u_llx = 0.0;    /* Initialize u_llx and u_lly because they
    p->u_lly = 0.0;       are used to set the origin within the crop
                       area */
  }
  if (p->clip && p->user_bbox) {  /* Clip to user specified bbox? */
    p->c_urx = p->u_urx;
    p->c_ury = p->u_ury;
    p->c_llx = p->u_llx;
    p->c_lly = p->u_lly;
  }
  if (p->scale != 0) {
    xscale = p->scale;
    yscale = p->scale;
  }
  if (p->xscale != 0) {
    xscale = p->xscale;
  }
  if (p->yscale != 0) {
    yscale = p->yscale;
  }
  if (p->width != 0.0 && nat_width != 0.0) {
    xscale = p->width/nat_width;
    if (p->height == 0.0)
      yscale = xscale;
  }
  if (p->height != 0.0 && nat_height != 0.0) {
    yscale = p->height/nat_height;
    if (p->width == 0.0)
      xscale = yscale;
  }
  /* We overwrite p->xscale and p->yscale to pass values back to
     caller to user */
  p->xscale = xscale;
  p->yscale = yscale;
  return;
}

Here is the caller graph for this function:

Definition at line 86 of file pdfspecial.c.

{
  ignore_colors = 1;
}

Here is the caller graph for this function:

void pdf_special_set_grow ( double  g)

Definition at line 77 of file pdfspecial.c.

{
  annot_grow = g;
}

Here is the caller graph for this function:

Definition at line 81 of file pdfspecial.c.

{
  return annot_grow;
}

Here is the caller graph for this function:

Definition at line 257 of file pdfspecial.c.

{
  RELEASE (p);
  return;
}

Here is the caller graph for this function:

Definition at line 263 of file pdfspecial.c.

{
  int result = 1;
  if (p->width != 0.0)
    if (p->scale !=0.0 || p->xscale != 0.0) {
      fprintf (stderr, "\nCan't supply both width and scale\n");
      result = 0;
    }
  if (p->height != 0.0) 
    if (p->scale !=0.0 || p->yscale != 0.0) {
      fprintf (stderr, "\nCan't supply both height and scale\n");
      result = 0;
    }
  if (p->scale != 0.0)
    if (p->xscale != 0.0 || p->yscale != 0.0) {
      fprintf (stderr, "\nCan't supply overall scale along with axis scales");
      result = 0;
    }
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function: