[poppler] poppler get bounding box of whole content
Mihai Niculescu
q.quark at gmail.com
Wed May 29 14:57:44 PDT 2013
mail list included. Replay below.
On 05/29/2013 11:39 PM, Albert Astals Cid wrote:
> El Dimecres, 29 de maig de 2013, a les 21:54:43, Mihai Niculescu va escriure:
>> Hi,
>>
>> I am trying to get the bounding box of all content in a page(text,
>> images, tables, etc) in poppler, but I can’t figure this out.
>> For example, I want to dublicate the result given by ghostscript:
>>
>> gs -sDEVICE=bbox golfer.ps
>>
>> prints out
>>
>> %%BoundingBox: 0 25 583 732
>>
>> %%HiResBoundingBox: 0.808497 25.009496 582.994503 731.809445
>>
>> How can this be done with poppler?
> Is that the "real" bounding box or one of the pdf boxes (crop, bleed, etc)?
>
> Cheers,
> Albert
>
>> Thanks,
>> Mihai
>> _______________________________________________
>> poppler mailing list
>> poppler at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/poppler
> _______________________________________________
> poppler mailing list
> poppler at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/poppler
Not the pdf boxes. I mean the union of all bounding boxes of all
elements (text, images, tables, glyphs, etc) in pdf. Let me explain more.
I tried to loop over all QList<TextBox> but these do not include other
glyphs in the pdf (greek sigma - for summation in latex) or maybe
poppler does not see it as a text:
QList<Poppler::TextBox*> wholetext = pdfPage->textList();
//float minX, maxX, minY, maxY;
QRectF unitedTextbbox, textbbox;
for(int i=0; i<wholetext.size(); ++i){
Poppler::TextBox* textBox = wholetext.at(i);
textbbox = textBox->boundingBox();
if(i==0){
unitedTextbbox=textbbox;
}else{
unitedTextbbox=unitedTextbbox.united(textbbox);
}
}
This works great when there is simple text in pdf, but when there are
other symbols it does not. I need something like the example above but
to include all elements in the pdf. I'll go and use only poppler
(without qt4 wrapper) if I can have this.
Cheers,
Mihai
More information about the poppler
mailing list