Getting text position while parsing pdf with Quartz 2D

后端 未结 1 1514
终归单人心
终归单人心 2020-12-14 05:31

another question regarding pdf parsing... Just read PDF Reference version 1.7 \"5.3.1 Text-Positioning Operators\" and I am a little bit confused.

I wrote some code

相关标签:
1条回答
  • 2020-12-14 05:45

    @Koteg : Hi ! Have you finally managed to get it work ? For Tm, i'm able to get all the six values, but for now i can't see how to get the position of a word into a line ... I have an idea : if we are in Tj, just get the space between letters (hopping this the same everytime) and with Tm, get the position of a word. In the case of TJ, this is quite more complicated : get the value of horizontal translation to substract to Tm matrix for each part of the array, but searching a word in that array will be more complicated than for Tj.

    BTW, for others people :

    for(size_t n = 0; n < CGPDFArrayGetCount(array); n += 2)
    {
        if(n >= CGPDFArrayGetCount(array))
            continue;
    
        CGPDFStringRef string;
        success = CGPDFArrayGetString(array, n, &string);
        if(success)
        {
            NSString *data = (NSString *)CGPDFStringCopyTextString(string);
            NSLog(@"array data : %@", data);
    
            [searcher.currentData appendFormat:@"%@", data];
            [data release];
        }
    
        CGPDFReal real;
        success = CGPDFArrayGetNumber(array, n+1, &real);
        if(success)
        {
            NSLog(@"array real : %f", real);
        }
    }
    

    Thanks

    0 讨论(0)
提交回复
热议问题