static void psgen_textspan(GVJ_t * job, pointf p, textspan_t * span) { char *str; if (job->obj->pencolor.u.HSVA[3] < .5) return; /* skip transparent text */ ps_set_color(job, &(job->obj->pencolor)); gvprintdouble(job, span->font->size); gvprintf(job, " /%s set_font\n", span->font->name); str = ps_string(span->str,isLatin1); switch (span->just) { case 'r': p.x -= span->size.x; break; case 'l': p.x -= 0.0; break; case 'n': default: p.x -= span->size.x / 2.0; break; } p.y += span->yoffset_centerline; gvprintpointf(job, p); gvputs(job, " moveto "); gvprintdouble(job, span->size.x); gvprintf(job, " %s alignedtext\n", str); }
static void ps_textline(point p, char *str, int width, double fontsz, double align) { int len; char sbuf[2*1024],*buf; if ((len = strlen(str)) < sizeof(sbuf)/2) buf = sbuf; else buf = malloc(2*len+1); ps_string(str,buf); fprintf(Outfile,"%d %d moveto %s %d %.2f %.2f alignedtext\n", p.x,p.y,buf,width,fontsz,align); if (buf != sbuf) free(buf); }
static void psgen_begin_anchor(GVJ_t *job, char *url, char *tooltip, char *target, char *id) { obj_state_t *obj = job->obj; if (url && obj->url_map_p) { gvputs(job, "[ /Rect [ "); gvprintpointflist(job, obj->url_map_p, 2); gvputs(job, " ]\n"); gvprintf(job, " /Border [ 0 0 0 ]\n" " /Action << /Subtype /URI /URI %s >>\n" " /Subtype /Link\n" "/ANN pdfmark\n", ps_string(url, isLatin1)); } }
int write_worldfile(FILE *f, int eps) { double worldbox_width, worldbox_height, u; char ps_str[MAX_SLEN * 2 + 3]; set_pageglobals(eps, 1); u = page_width / world_width; if (page_height / world_height < u) { u = page_height / world_height; worldbox_width = world_width * u; worldbox_height = page_height; } else { worldbox_height = world_height * u; worldbox_width = page_width; } if (eps) { fprintf(f, "%%!PS-Adobe-3.0 EPSF-3.0\n"); fprintf(f, "%%%%BoundingBox: 0 0 %f %f\n", worldbox_width, worldbox_height); } else fprintf(f, "%%!\n"); postscript_worldheader(f, 1, 6); if (!eps) { fprintf(f, "90 rotate 0 %f translate\n", -page_y0 - page_height); fprintf(f, "/Courier-Bold findfont 12 scalefont setfont\n"); sprintf(buf, "run %s, generation %ld", simname, start_generation); fprintf(f, "%f %f moveto %s show\n", page_x0, page_y0 + worldbox_height + 8.0, ps_string(buf, ps_str)); } /* fprintf(f, "newpath %f %f moveto %f %f lineto %f %f lineto %f %f lineto closepath stroke\n", page_x0, page_y0, page_x0 + worldbox_width, page_y0, page_x0 + worldbox_width, page_y0 + worldbox_height, page_x0, page_y0 + worldbox_height); */ postscript_world(f, page_x0, page_y0, worldbox_width, worldbox_height, 6); if (eps) fprintf(f, "%%%%EOF\n"); else fprintf(f, "showpage\n"); return (0); }
Bool string_(ps_context_t *pscontext) { register int32 ssize ; register OBJECT *theo ; UNUSED_PARAM(ps_context_t *, pscontext) ; ssize = theStackSize( operandstack ) ; if ( EmptyStack( ssize )) return error_handler( STACKUNDERFLOW ) ; theo = TopStack( operandstack , ssize ) ; if ( oType(*theo) != OINTEGER ) return error_handler( TYPECHECK ) ; ssize = oInteger(*theo) ; /* Setup string and initialise strings elements to zero. */ return ps_string(theo, NULL, ssize) ; }
Bool pdf_copyobject( PDFCONTEXT *pdfc , OBJECT *srcobj , OBJECT *destobj ) { int32 i ; int32 len ; uint8 *clist ; OBJECT *alist ; PDFXCONTEXT *pdfxc = NULL ; corecontext_t *corecontext ; if ( pdfc ) { PDF_CHECK_MC( pdfc ) ; PDF_GET_XC( pdfxc ) ; if ( ++( pdfxc->recursion_depth ) > PDF_MAX_RECURSION_DEPTH ) return error_handler( LIMITCHECK ) ; corecontext = pdfxc->corecontext ; } else { corecontext = get_core_context() ; } HQASSERT( srcobj , "srcobj NULL in pdf_copyobject." ) ; HQASSERT( destobj , "destobj NULL in pdf_copyobject." ) ; HQASSERT( srcobj != destobj , "srcobj == destobj in pdf_copyobject." ) ; switch ( oXType(*srcobj) ) { case OINTEGER: case OREAL: case OBOOLEAN: case ONULL: case ONAME: case OINDIRECT: case OOPERATOR: case OFILEOFFSET: Copy( destobj , srcobj ) ; break ; case ODICTIONARY: { PDF_COPYOBJ_DWFPARAMS params ; len = theLen(*srcobj); if ( pdfxc ) { if ( ! pdf_create_dictionary( pdfc , len , destobj )) return FALSE ; } else { if ( ! ps_dictionary(destobj, len)) return FALSE ; } params.pdfc = pdfc ; params.destdict = destobj ; if ( !walk_dictionary( srcobj , pdf_copyobj_dictwalkfn , ( void * )& params )) { if ( pdfxc ) { /* Use macro to avoid VC6sp5 compiler optimisation bug */ PDF_DESTROY_DICTIONARY(pdfxc, len, destobj, corecontext); } /* Rely on restore, I s'pose */ return FALSE ; } break ; } case OSTRING: Copy( destobj , srcobj ) ; len = theLen(*srcobj) ; clist = oString(*srcobj) ; if ( len ) { if ( pdfxc ) { if ( !pdf_create_string(pdfc, len, destobj) ) return FALSE ; HqMemCpy(oString(*destobj) , clist , len ) ; } else { if ( !ps_string(destobj, clist, len) ) return error_handler( VMERROR ) ; } } break ; case OARRAY: case OPACKEDARRAY: Copy( destobj , srcobj ) ; len = theLen(*srcobj) ; if ( len ) { OBJECT *destalist ; alist = oArray(*srcobj) ; if ( pdfxc ) { destalist = PDF_ALLOCOBJECT( pdfxc , len ) ; } else destalist = get_omemory( len ) ; if ( !destalist ) return error_handler( VMERROR ) ; oArray(*destobj) = destalist ; if ( pdfxc == NULL ) SETGLOBJECT(*destobj, corecontext) ; for ( i = len ; i > 0 ; --i, ++alist, ++destalist ) { if ( !pdf_copyobject( pdfc , alist , destalist )) { if ( pdfxc ) { PDF_FREEOBJECT( pdfxc, oArray(*destobj) , len ) ; Copy(destobj, &onull); } else { /* Rely on restore, I s'pose */ } return FALSE ; } } } break ; case OLONGARRAY: case OLONGPACKEDARRAY: { OBJECT *destalist ; Copy( destobj , srcobj ) ; len = oLongArrayLen(*srcobj) ; /* always > 65535 */ if ( pdfxc ) { destalist = PDF_ALLOCOBJECT( pdfxc , len + 2 ) ; } else destalist = get_omemory( len + 2 ) ; if ( !destalist ) return error_handler( VMERROR ) ; alist = oArray(*srcobj) ; /* The old trampoline */ oArray(*destobj) = destalist ; /* The new trampoline */ Copy(destalist++, alist++) ; /* Length */ Copy(destalist, alist) ; /* array ptr */ oArray(*destalist) = destalist + 1 ; destalist += 1 ; alist = oArray(*alist) ; if ( pdfxc == NULL ) { SETGLOBJECT(*destobj, corecontext) ; SETGLOBJECT(*(destalist-2), corecontext) ; SETGLOBJECT(*(destalist-1), corecontext) ; } for ( i = len ; i > 0 ; --i, ++alist, ++destalist ) { if ( !pdf_copyobject( pdfc , alist , destalist )) { if ( pdfxc ) { PDF_FREEOBJECT( pdfxc, oArray(*destobj) , len + 2 ) ; Copy(destobj, &onull); } else { /* Rely on restore, I s'pose */ } return FALSE ; } } } break ; case OFILE: { PDFXCONTEXT *streamxc ; /* Streams are different to other objects: we don't deep copy them but rather mark them as being used on this page. */ if ( ! pdf_find_execution_context( theIPDFContextID( oFile( *srcobj )) , pdfin_xcontext_base , & streamxc )) { /* Note that if we ever revive pdfout, we'd have to check pdfout_xcontext_base here too. */ HQFAIL( "Couldn't find stream execution context" ) ; return FALSE ; } HQASSERT( streamxc != NULL , "Null context" ) ; if ( ! pdf_xrefexplicitaccess_stream( streamxc , srcobj , FALSE )) { return FALSE ; } Copy( destobj , srcobj ) ; } break ; default: HQFAIL( "Trying to copy an unsupported/undefined pdf object type." ) ; } if ( pdfxc ) { pdfxc->recursion_depth -= 1 ; HQASSERT( pdfxc->recursion_depth >= 0 , "Recursion depth went below zero!" ) ; } return TRUE ; }