File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import pymupdf
2+ import pathlib
3+
4+
5+ def test_archive_markdown ():
6+ """Test Archive support."""
7+ path = pathlib .Path ().absolute () / "resources"
8+ md = b"\n \n **A referenced image.**"
9+ md_doc = pymupdf .open (stream = md , filetype = "md" , archive = path .name )
10+ pdfdata = md_doc .convert_to_pdf ()
11+ doc = pymupdf .open (stream = pdfdata )
12+ page = doc [0 ]
13+ images = page .get_image_info ()
14+ assert len (images ) == 1
15+
16+ def test_archive_links ():
17+ """Create an internal and an external link and confirm
18+ that they are correctly converted to PDF links."""
19+ md = """Some text containing an external [link](http://www.google.com) to Google.
20+ Now an internal link to a header in this document: [Some Header](#some-header). The header is here:
21+
22+ <h2 id="some-header">Some Header</h2>
23+
24+ Some text following the header.
25+ """
26+ md_doc = pymupdf .open (stream = md .encode (), filetype = "md" )
27+ pdfdata = md_doc .convert_to_pdf ()
28+ doc = pymupdf .open (stream = pdfdata )
29+ page = doc [0 ]
30+ links = page .get_links ()
31+ assert len (links ) == 2
32+ assert links [0 ]["uri" ] == "http://www.google.com"
33+ assert links [0 ]["kind" ] == pymupdf .LINK_URI
34+ assert links [1 ]["kind" ] == pymupdf .LINK_GOTO
You can’t perform that action at this time.
0 commit comments