I notice that there is a origin attribute in the TextPage content, but when I change the MediaBox and CropBox of the pdf file, the origin becomes very weird.
For example, the following code:
text = '123'
doc = fitz.Document()
page = doc.newPage()
page.setMediaBox(fitz.Rect(100, 50, 500, 500))
page.setCropBox(fitz.Rect(0, 0, 400, 400))
rc = page.insertText((0,0), text)
page.getText('dict')
outputs origin with the value: (-100, 50)
{
'width': 2.0,
'height': 2.0,
'blocks': [
{
'number': 0,
'type': 0,
'bbox': (-100.0, 38.17499923706055, -81.6520004272461, 53.28900146484375),
'lines': [
{
'spans': [
{
'size': 11.0,
'flags': 0,
'font': 'Helvetica',
'color': 0,
'ascender': 1.0750000476837158,
'descender': -0.29899999499320984,
'text': '123',
'origin': (-100.0, 50.0),
'bbox': (-100.0, 38.17499923706055, -81.6520004272461, 53.28900146484375)
}
],
'wmode': 0,
'dir': (1.0, 0.0),
'bbox': (-100.0, 38.17499923706055, -81.6520004272461, 53.28900146484375)
}
]
}
]
}
Could you help me to figure out how this origin is computed?
I notice that there is a
originattribute in theTextPagecontent, but when I change theMediaBoxandCropBoxof the pdf file, theoriginbecomes very weird.For example, the following code:
outputs
originwith the value: (-100, 50){ 'width': 2.0, 'height': 2.0, 'blocks': [ { 'number': 0, 'type': 0, 'bbox': (-100.0, 38.17499923706055, -81.6520004272461, 53.28900146484375), 'lines': [ { 'spans': [ { 'size': 11.0, 'flags': 0, 'font': 'Helvetica', 'color': 0, 'ascender': 1.0750000476837158, 'descender': -0.29899999499320984, 'text': '123', 'origin': (-100.0, 50.0), 'bbox': (-100.0, 38.17499923706055, -81.6520004272461, 53.28900146484375) } ], 'wmode': 0, 'dir': (1.0, 0.0), 'bbox': (-100.0, 38.17499923706055, -81.6520004272461, 53.28900146484375) } ] } ] }Could you help me to figure out how this
originis computed?