@@ -228,3 +228,39 @@ def test_3591():
228228 paths = page .get_drawings ()
229229 for p in paths :
230230 assert p ["width" ] == 15
231+
232+
233+ def test_4954_1 ():
234+ path_out = os .path .normpath (f'{ __file__ } /../../tests/test_4954_1.pdf' )
235+ with pymupdf .open () as document :
236+ page = document .new_page (width = 200 , height = 200 )
237+ shape = page .new_shape ()
238+ shape .draw_line ((0 , 0 ), (1 , 1 ))
239+ shape .finish (color = (0 , 0 , 0 ), width = 0.1 )
240+ shape .commit ()
241+ content = b'q\n 0.12 0 0 0.12 0 0 cm\n 2 j\n 6 w\n 100 100 m\n 800 100 l\n S\n Q\n '
242+ document .update_stream (page .get_contents ()[0 ], content , compress = 0 )
243+ document .save (path_out )
244+
245+ with pymupdf .open (path_out ) as document :
246+ d = document [0 ].get_drawings ()[- 1 ]
247+ print (f'{ d ["lineJoin" ]= } ' ) # Expected: 2, Actual: 0.24
248+ assert d ['lineJoin' ] == 2
249+
250+
251+ def test_4954_2 ():
252+ path_out = os .path .normpath (f'{ __file__ } /../../tests/test_4954_2.pdf' )
253+ with pymupdf .open () as document :
254+ page = document .new_page (width = 200 , height = 200 )
255+ shape = page .new_shape ()
256+ shape .draw_line ((0 , 0 ), (1 , 1 ))
257+ shape .finish (color = (1 , 0 , 0 ), width = 0.1 )
258+ shape .commit ()
259+ content = b'q\n 2 0 0 3 0 0 cm\n 1 w\n 10 10 m\n 90 10 l\n S\n Q\n '
260+ document .update_stream (page .get_contents ()[0 ], content , compress = 0 )
261+ document .save (path_out )
262+
263+ with pymupdf .open (path_out ) as document :
264+ d = document [0 ].get_drawings ()[- 1 ]
265+ print (f'{ d ["width" ]= } ' ) # Expected: 2.0, Actual: 1.0
266+ assert abs (d ['width' ] - 2.449 ) < 0.01
0 commit comments