pdf-parser.cpp revision cd20f44794b5102a82bd3f2344504158e28faa92
2605N/A * PDF parsing using libpoppler 2605N/A * Copyright 1996-2003 Glyph & Cog, LLC 2605N/A//------------------------------------------------------------------------ 2605N/A//------------------------------------------------------------------------ 2605N/A// Max recursive depth for a function shading fill. 2605N/A// Max delta allowed in any color component for a function shading fill. 2605N/A// Max number of splits along the t axis for an axial shading fill. 2605N/A// Max delta allowed in any color component for an axial shading fill. 2605N/A// Max number of splits along the t axis for a radial shading fill. 2605N/A// Max delta allowed in any color component for a radial shading fill. 2605N/A// Max recursive depth for a Gouraud triangle shading fill. 2605N/A// Max delta allowed in any color component for a Gouraud triangle 2605N/A// Max recursive depth for a patch mesh shading fill. 2605N/A// Max delta allowed in any color component for a patch mesh shading 2605N/A// Max number of operators kept in the history list. 2605N/A//------------------------------------------------------------------------ 2605N/A//------------------------------------------------------------------------ 2605N/A#
ifdef WIN32 // this works around a bug in the VC7 compiler #
ifdef WIN32 // this works around a bug in the VC7 compiler//------------------------------------------------------------------------ //------------------------------------------------------------------------ // start the resource stack for (i = 0; i <
6; ++i) {
// do not clip if it's not needed error(-
1,
"Weird page contents");
error(-
1,
"Weird page contents");
// scan a sequence of objects // got a command - execute it // got an argument - save it // too many arguments - something is wrong printf(
"throwing away arg: ");
// args at end with no command // Truncate list if needed error(
getPos(),
"Arg #%d to '%s' operator is wrong type (%s)",
// invariant: opTab[a] < name < opTab[b] //------------------------------------------------------------------------ // graphics state operators //------------------------------------------------------------------------ // multiply it with the previous transform // construct identity matrix for (i = 0; i <
length; ++i) {
// transparency support: blend mode, fill/stroke opacity for (i = 0; i <
4; ++i) {
error(
getPos(),
"Invalid transfer function in ExtGState");
//out->clearSoftMask(state); "Invalid transfer function in soft mask in ExtGState");
//~ need to get the parent or default color space (?) error(
getPos(),
"Invalid soft mask in ExtGState - missing group");
error(
getPos(),
"Invalid soft mask in ExtGState - missing group");
// check for excessive recursion for (i = 0; i <
4; ++i) {
for (i = 0; i <
6; ++i) {
//------------------------------------------------------------------------ //------------------------------------------------------------------------ for (i = 0; i <
4; ++i) {
for (i = 0; i <
4; ++i) {
for (i = 0; i <
3; ++i) {
for (i = 0; i <
3; ++i) {
error(
getPos(),
"Incorrect number of arguments in 'sc' command");
error(
getPos(),
"Incorrect number of arguments in 'SC' command");
error(
getPos(),
"Incorrect number of arguments in 'scn' command");
error(
getPos(),
"Incorrect number of arguments in 'scn' command");
error(
getPos(),
"Incorrect number of arguments in 'SCN' command");
error(
getPos(),
"Incorrect number of arguments in 'SCN' command");
//------------------------------------------------------------------------ // path segment operators //------------------------------------------------------------------------ //------------------------------------------------------------------------ // path painting operators //------------------------------------------------------------------------ //error(getPos(), "No path in stroke"); //error(getPos(), "No path in fill"); //error(getPos(), "No path in eofill"); error(
getPos(),
"Unimplemented pattern type (%d) in fill",
error(
getPos(),
"Unimplemented pattern type (%d) in stroke",
// save current graphics state if (0 ){
//shading->getHasBBox()) { //out->clipToStrokePath(state); // construct a (pattern space) -> (current space) transform matrix // m1 = PTM * BTM = PTM * base transform matrix // m = m1 * iCTM = (PTM * BTM) * (iCTM) // do shading type-specific operations // no need to implement these // restore graphics state // save current graphics state // do shading type-specific operations // no need to implement these // restore graphics state // compare the four corner colors for (i = 0; i <
4; ++i) {
for (j = 0; j <
nComps; ++j) {
// center of the rectangle // the four corner colors are close (or we hit the recursive limit) // -- fill the rectangle; but require at least one subdivision // (depth==0) to avoid problems when the four outer corners of the // shaded region are the same color // the four corner colors are not close enough -- subdivide the // colors[0] colorM0 colors[2] // (x0,y0) (xM,y0) (x1,y0) // +----------+----------+ // color0M | colorMM | color1M // (x0,yM) +----------+----------+ (x1,yM) // +----------+----------+ // colors[1] colorM1 colors[3] // (x0,y1) (xM,y1) (x1,y1) // upper-left sub-rectangle // lower-left sub-rectangle // upper-right sub-rectangle // lower-right sub-rectangle for (i = 0; i <
nComps; ++i) {
//~ if the shading has a Function, this should interpolate on the //~ function parameter, not on the color components for (i = 0; i <
nComps; ++i) {
double xx[
4][
8],
yy[
4][
8];
for (i = 0; i <
nComps; ++i) {
for (i = 0; i <
4; ++i) {
xx[i][
3] =
xx[i][
4] =
0.5 * (
xx[i][
2] +
xx[i][
5]);
yy[i][
3] =
yy[i][
4] =
0.5 * (
yy[i][
2] +
yy[i][
5]);
for (i = 0; i <
4; ++i) {
for (i =
4; i <
8; ++i) {
//~ if the shading has a Function, this should interpolate on the //~ function parameter, not on the color components for (i = 0; i <
nComps; ++i) {
//------------------------------------------------------------------------ // path clipping operators //------------------------------------------------------------------------ //------------------------------------------------------------------------ //------------------------------------------------------------------------ //------------------------------------------------------------------------ //------------------------------------------------------------------------ printf(
" font: tag=%s name='%s' %g\n",
//------------------------------------------------------------------------ // text positioning operators //------------------------------------------------------------------------ //------------------------------------------------------------------------ //------------------------------------------------------------------------ // this uses the absolute value of the font size to match double x, y,
dx,
dy,
dx2,
dy2,
curX,
curY,
tdx,
tdy,
lineX,
lineY;
for (i = 0; i <
6; ++i) {
if (n ==
1 && *p ==
' ') {
//~ the CTM concat values here are wrong (but never used) //out->updateCTM(state, 1, 0, 0, 1, 0, 0); if (0){
/*!out->beginType3Char(state, curX + riseX, curY + riseY, tdx, tdy, //parse(&charProc, gFalse); // TODO: parse into SVG font error(
getPos(),
"Missing or bad Type3 CharProc entry");
//out->endType3Char(state); // GfxState::restore() does *not* restore the current position, // so we deal with it here using (curX, curY) and (lineX, lineY) if (n ==
1 && *p ==
' ') {
if (n ==
1 && *p ==
' ') {
//------------------------------------------------------------------------ //------------------------------------------------------------------------ /* out->psXObject(obj1.getStream(), obj3.isStream() ? obj3.getStream() : (Stream *)NULL);*/ error(
getPos(),
"XObject subtype is missing or wrong type");
// get info from the stream // check for inverted mask //out->drawImageMask(state, ref, str, width, height, invert, inlineImg); // get color space and color map //~ handle the Matte entry /* out->drawSoftMaskedImage(state, ref, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskColorMap);*/ /* out->drawMaskedImage(state, ref, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskInvert);*/ // check for excessive recursion for (i = 0; i <
4; ++i) {
for (i = 0; i <
6; ++i) {
// check for a transparency group // push new resources on stack // save current graphics state // kill any pre-existing path // set form transformation matrix //out->clearSoftMask(state); //out->beginTransparencyGroup(state, bbox, blendingColorSpace, // isolated, knockout, softMask); for (i = 0; i <
6; ++i) {
//out->endTransparencyGroup(state); for (i = 0; i <
6; ++i) {
// restore graphics state //out->setSoftMask(state, bbox, alpha, transferFunc, backdropColor); //out->paintTransparencyGroup(state, bbox); //------------------------------------------------------------------------ // in-line image operators //------------------------------------------------------------------------ while (!(
c1 ==
'E' &&
c2 ==
'I') &&
c2 !=
EOF) {
error(
getPos(),
"Inline image dictionary key must be a name object");
//------------------------------------------------------------------------ //------------------------------------------------------------------------ //------------------------------------------------------------------------ // compatibility operators //------------------------------------------------------------------------ //------------------------------------------------------------------------ // marked content operators //------------------------------------------------------------------------ //out->beginMarkedContent(args[0].getName(),args[1].getDict()); //out->beginMarkedContent(args[0].getName()); //out->endMarkedContent(); //out->markPoint(args[0].getName(),args[1].getDict()); //out->markPoint(args[0].getName()); //------------------------------------------------------------------------ //------------------------------------------------------------------------ #
endif /* HAVE_POPPLER */