1
votes

According to the "Pdf Reference Version 1.7" the text-positioning operator "Tm" is described as follows:

...Although the operands specify a matrix, they are passed to Tm as six separate numbers, not as an array.

I don't understand how I'm supposed to retrieve a series of numbers that are not an array, string, or anything similar. When I implement this code I get that the object type is real, and when I try to get its value all I end up with is the last number of the array.

CGPDFOperatorTableSetCallback(table, "Tm", positioningOperator);

...

void positioningOperator(CGPDFScannerRef scanner, void *info)
{
    [(__bridge CTPDFParser *)info operatorPositionScanned:scanner];
}

...

- (void)operatorPositionScanned:(CGPDFScannerRef)scanner
{
    CGPDFContentStreamRef streamRef = CGPDFScannerGetContentStream(scanner);

    CGPDFObjectRef object;
    CGPDFScannerPopObject(scanner, &object);

    CGPDFObjectType type = CGPDFObjectGetType(object);

    if( type == kCGPDFObjectTypeReal)
    {
        CGPDFReal real;
        if( CGPDFObjectGetValue(object, type, &real) )
        {
            // 1 0 0 1 256.3246 669.3472 Tm
            NSLog(@"%f", real); // Prints only 669.347168
        }
    }
}

I checked if the passed value was of any other type, but it was just real so I really don't know how to retrieve the other numbers.

Any help would be appreciated.

1
Have you tried popping more than one object from the scanner? There should be six numbers to pop.mkl
Thank you! This is what I was looking forDiego A. Rincon

1 Answers

2
votes

Each PDF operator has its operands on the stack. For each operator you handle you have to pop from the stack the required number of operands, as described by PDF specification.

For Tm operator you have to pop 6 operands from the stack.