Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draw_rect scaled to very small size #3485

Closed
gxlj opened this issue May 16, 2024 · 5 comments
Closed

draw_rect scaled to very small size #3485

gxlj opened this issue May 16, 2024 · 5 comments

Comments

@gxlj
Copy link

gxlj commented May 16, 2024

Description of the bug

draw_rect behave different on existing page and new page

How to reproduce the bug

i have an existing pdf file and when i use draw_rect to draw on one of its page , eg , (100,100,600,600) , but it scaled to (20,20,200,200) , the rectangle is very small . even i set the width to more like 3000, it only can occupy 1/4 area of the whole page on left-top area .
but when create a new page , and draw on it , it works fine .

my question is , is there some possible reason that make draw_rect such behavior . actually not only draw_rect ,but also insert_text also this behavior . and i compared the new page and existing page , the transformation and other matrix are all same . i think the existing pdf page must have difference with new page , but i can't find it ...

PyMuPDF version

1.24.2

Operating system

MacOS

Python version

3.12

@JorjMcKie
Copy link
Collaborator

We can only accept a bug report complete with an example file. I also noticed that you do not use the current version.

@gxlj
Copy link
Author

gxlj commented May 16, 2024

hi ,how to remove all CTM from the pdf page ? i saw some "cm" instruction left in existing page : (0.24,0,0,-0.24,0,840) and when i darw_rect it will mulitple that ctm with input rect.
or how to get the current CTM value from current page ? after get it , how to get a reverse one as the Morph ?

@JorjMcKie
Copy link
Collaborator

hi ,how to remove all CTM from the pdf page ? i saw some "cm" instruction left in existing page : (0.24,0,0,-0.24,0,840) and when i darw_rect it will mulitple that ctm with input rect. or how to get the current CTM value from current page ? after get it , how to get a reverse one as the Morph ?

This consideration will not resolve your problem. Please repeat using the current PyMuPDF version 1.24.3.

@gxlj
Copy link
Author

gxlj commented May 16, 2024

i am using 1.24.4 to reproduce this .
i know the previous cm is (0.24,0,0,-0.24,0,0 )
how to pass the morph param to generate
"4.16,0,0,4.16,0,0 cm" (the inverse of above cm ) instruction ? (thus before draw , the two matrix multipy equal to 1)

from below code seems it depends the start point and a matrix , how to decide them ?

in shape.finish there is :

if pymupdf.CheckMorph(morph):
m1 = pymupdf.Matrix(
1, 0, 0, 1, morph[0].x + self.x, self.height - morph[0].y - self.y
)
mat = ~m1 * morph[1] * m1
self.draw_cont = _format_g(pymupdf.JM_TUPLE(mat)) + " cm\n" + self.draw_cont

@JorjMcKie
Copy link
Collaborator

First of all, this seems to be no bug report any longer.
I am therefore going to move this thread to the Discussions tab. We can pick up questions there.

@pymupdf pymupdf locked and limited conversation to collaborators May 16, 2024
@JorjMcKie JorjMcKie converted this issue into discussion #3491 May 16, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

2 participants