<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by PDF &amp; Python Lab on Medium]]></title>
        <description><![CDATA[Stories by PDF &amp; Python Lab on Medium]]></description>
        <link>https://medium.com/@pdfpythonlab?source=rss-4aa511f43bae------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nEuaasFpkYgP4AFc-n_pNQ.png</url>
            <title>Stories by PDF &amp;amp; Python Lab on Medium</title>
            <link>https://medium.com/@pdfpythonlab?source=rss-4aa511f43bae------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 21:02:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pdfpythonlab/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A Guide to Reading PDF Metadata Using PyMuPDF]]></title>
            <link>https://medium.com/@pdfpythonlab/a-guide-to-reading-pdf-metadata-using-pymupdf-cbc9487d6fb9?source=rss-4aa511f43bae------2</link>
            <guid isPermaLink="false">https://medium.com/p/cbc9487d6fb9</guid>
            <category><![CDATA[pymupdf]]></category>
            <category><![CDATA[data-extraction]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pdf]]></category>
            <dc:creator><![CDATA[PDF & Python Lab]]></dc:creator>
            <pubDate>Fri, 13 Nov 2026 07:23:11 GMT</pubDate>
            <atom:updated>2026-11-13T19:38:56.199Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’re working with a PyMuPDF’s Document object called doc, you can access its metadata with:</p><p>metadata = doc.metadata</p><p>PyMuPDF is a Python library for working with PDF files.</p><h3>What does doc.metadata mean?</h3><p>doc.metadata contains additional information about the PDF document, rather than the PDF document’s main text.</p><p>It might contain information such as:</p><ul><li>format</li><li>title</li><li>author</li><li>creator</li></ul><h3>1. Store the metadata</h3><pre>metadata = doc.metadata</pre><p>This takes the metadata associated with doc and stores it in a variable called metadata.</p><h3>2. Print the metadata</h3><pre>print(metadata)</pre><p>This displays the metadata:</p><p>{‘format’: ‘PDF 1.5’, ‘title’: ‘Artificial Intelligence (AI) ‘, ‘author’: ‘PDF Python Hub’, ‘subject’: ‘An Overview of Artificial Intelligence, Machine Learning, Generative AI, Ethical Frameworks, and Future Outlook’, ‘keywords’: ‘Artificial Intelligence, AI, Machine Learning, Deep Learning, Generative AI, Large Language Models, AI Ethics’, ‘creator’: ‘Google Docs’, ‘producer’: ‘Skia/PDF m153 Google Docs Renderer’, ‘creationDate’: “D:20260816101230+02&#39;00&#39;”, ‘modDate’: “D:20260818145823+02&#39;00&#39;”, ‘trapped’: ‘’, ‘encryption’: None}</p><p>You can then access individual pieces of information:</p><pre>print(metadata[&quot;author&quot;])</pre><pre>print(metadata[&quot;creationDate&quot;])</pre><h3>Complete Example</h3><pre>%pip install -q -U pymupdf<br><br>from google.colab import files<br>uploaded = files.upload()<br><br>import pymupdf<br>doc = pymupdf.open(&quot;data.pdf&quot;)<br><br>metadata = doc.metadata<br>print(metadata)</pre><p><strong>Note:</strong> Before running the following code, make sure that the pymupdf package is installed, that your PDF file (data.pdf) has been uploaded to your Google Colab environment, and that you know how to open the PDF file using PyMuPDF.</p><p><strong>-Want to learn how to install the pymupdf package in Google Colab?</strong></p><p>Check out this mini-guide: <a href="https://payhip.com/PDFPythonHub/blog/news/how-to-install-pymupdf-in-google-colab">How to Install PyMuPDF in Google Colab</a>.</p><p><strong>-Want to learn how to upload your PDF file in Google Colab?</strong></p><p>Check out this mini-guide: <a href="https://payhip.com/PDFPythonHub/blog/news/uploading-files-in-google-colab">Uploading Files in Google Colab</a>.</p><p>-Want to learn how to open your PDF file in Google Colab using PyMuPDF?</p><p>Check out this mini-guide: <a href="https://payhip.com/PDFPythonHub/blog/news/open-your-first-pdf-with-pymupdf">Open Your First PDF with PyMuPDF</a>.</p><h3>Open the notebook</h3><p>Open the Google Colab notebook for this PDF mini-guide and run the code as you follow along.</p><p>[<a href="https://colab.research.google.com/drive/1o4RDtnFuxvFDG8P_3u2YlRXHu3D1_i19?usp=sharing">Open in Google Colab</a>]</p><p>This mini-guide was originally published on <a href="https://payhip.com/PDFPythonHub">PDF Python Hub</a>, where you can find more in-depth Python resources for working with PDFs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2VjzDBs9iuV9d2NUm0-43g.jpeg" /><figcaption>Image generated by Gemini</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cbc9487d6fb9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Close Your PDF with doc.close() in PyMuPDF]]></title>
            <link>https://medium.com/@pdfpythonlab/how-to-close-your-pdf-with-doc-close-in-pymupdf-eb612ad3ad20?source=rss-4aa511f43bae------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb612ad3ad20</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[pymupdf]]></category>
            <category><![CDATA[pdf]]></category>
            <category><![CDATA[pdf-processing]]></category>
            <dc:creator><![CDATA[PDF & Python Lab]]></dc:creator>
            <pubDate>Mon, 14 Sep 2026 13:26:56 GMT</pubDate>
            <atom:updated>2026-09-14T13:26:56.244Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>doc.close() </strong>closes a PDF document that you previously opened with PyMuPDF.</p><h3>What does doc.close() do?</h3><p><strong>doc.close()</strong>:</p><ul><li>Releases resources and memory associated with the document.</li><li>Closes the document and its underlying resources.</li><li>Makes the Document object unavailable for further document operations.</li></ul><h3>When should you use it?</h3><p>Use <strong>doc.close() </strong>when you are finished working with a PDF, especially when:</p><ul><li>You created or modified a PDF.</li><li>You are processing many PDFs in a loop.</li><li>You want to make sure the document is no longer being held open.</li></ul><p><strong>Important:</strong> After calling <strong>doc.close()</strong>, you can no longer work with the document. Attempting to perform operations on a closed document can raise: <strong>ValueError: document closed</strong></p><p>If you need to work with the PDF again, you can open it with <strong>pymupdf.open()</strong>:</p><pre>doc = pymupdf.open(&quot;sample.pdf&quot;)</pre><p>This creates a new Document object that you can work with normally.</p><h3>Should you save the PDF document before closing it?</h3><p>If you’ve modified the PDF, make sure you save your changes to a new file before closing the document.</p><p>For example:</p><pre>doc.save(&quot;modified.pdf&quot;)</pre><p>If you close a modified document without saving it, your changes may be lost.</p><p><strong><em>doc.close()</em></strong><em> does not save your changes.</em></p><figure><img alt="Illustration explaining how to close a PDF document in PyMuPDF using `doc.close()`, including releasing document resources, preventing further operations on the closed document, and saving any modifications before closing." src="https://cdn-images-1.medium.com/max/1024/1*RiGBuLCoTLP-onaCqbsekA.jpeg" /></figure><h3>Open the notebook</h3><p>Open the Google Colab notebook for this PDF mini-guide and run the code as you follow along.</p><p>[<a href="https://colab.research.google.com/drive/1j8jc-bC_2Fcs4IVPnzfPDA3ZiFHjqirj?usp=sharing">Open in Google Colab</a>]</p><h3>More PDF Python Resources</h3><p>Want to learn how to open a PDF file?</p><p>Check out this mini-guide: <a href="https://payhip.com/PDFPythonHub/blog/news/open-your-first-pdf-with-pymupdf">Open Your First PDF with PyMuPDF</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb612ad3ad20" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Uploading Files to Google Colab Made Easy]]></title>
            <link>https://medium.com/@pdfpythonlab/uploading-files-to-google-colab-made-easy-10940a4697e2?source=rss-4aa511f43bae------2</link>
            <guid isPermaLink="false">https://medium.com/p/10940a4697e2</guid>
            <category><![CDATA[google-colab]]></category>
            <category><![CDATA[pdf]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[pymupdf]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[PDF & Python Lab]]></dc:creator>
            <pubDate>Tue, 08 Sep 2026 17:35:58 GMT</pubDate>
            <atom:updated>2026-10-30T04:25:39.968Z</atom:updated>
            <content:encoded><![CDATA[<p>The following code lets you upload one or more files from your computer directly into a Google Colab notebook:</p><pre>from google.colab import files<br>uploaded = files.upload()</pre><h3>How it works</h3><h4>1. Import the file-upload tool</h4><pre>from google.colab import files</pre><p>This imports Colab’s <strong>files</strong> module, which provides functions for uploading and downloading files in Google Colab.</p><h3>2. Open the upload window</h3><pre>uploaded = files.upload()</pre><p>When this line runs, Colab displays a <strong>Choose Files</strong> button. You can select one or more files from your computer.</p><p>The uploaded file(s) are stored in the <strong>uploaded</strong> variable as a dictionary.</p><p><em>For example, if you select a PDF, Colab uploads it to the notebook environment and stores its information in the </em><strong><em>uploaded</em></strong><em> variable.</em></p><h3>3. Check the filename(s)</h3><pre>uploaded.keys()</pre><figure><img alt="A simple guide to uploading files in Google Colab using the Files panel." src="https://cdn-images-1.medium.com/max/1024/1*qlYFGHUeWOTkx-u-vfVK0w.jpeg" /></figure><h3>Complete Example</h3><pre>from google.colab import files<br>uploaded = files.upload()<br><br>uploaded.keys()</pre><h3>Open the notebook</h3><p>Open the Google Colab notebook for this PDF mini-guide and run the code as you follow along.</p><p>[<a href="https://colab.research.google.com/drive/1xf9r2mr0F3qWHJtl5jZXjBjWIKQK1HFh?usp=sharing">Open in Google Colab</a>]</p><p>This mini-guide was originally published on <a href="https://payhip.com/PDFPythonHub">PDF Python Hub</a>, where you can find more in-depth Python resources for working with PDFs.</p><h3>What’s Next? Open Your First PDF in Google Colab</h3><p>Want to learn how to open your first PDF in Google Colab?</p><p>Check out this mini-guide: <a href="https://payhip.com/PDFPythonHub/blog/news/open-your-first-pdf-with-pymupdf">Open Your First PDF with PyMuPDF</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10940a4697e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Simple Guide to Counting PDF Pages with PyMuPDF]]></title>
            <link>https://medium.com/@pdfpythonlab/a-simple-guide-to-counting-pdf-pages-with-pymupdf-6044c34b0dc0?source=rss-4aa511f43bae------2</link>
            <guid isPermaLink="false">https://medium.com/p/6044c34b0dc0</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pymupdf]]></category>
            <category><![CDATA[pdf]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[PDF & Python Lab]]></dc:creator>
            <pubDate>Thu, 03 Sep 2026 12:37:32 GMT</pubDate>
            <atom:updated>2026-11-04T14:39:27.190Z</atom:updated>
            <content:encoded><![CDATA[<p>Once you have opened a PDF with PyMuPDF, you can easily find out how many pages it contains.</p><h3>1. Using page_count</h3><pre>page_number = doc.page_count<br>print(page_number)</pre><p>The page_count property returns the total number of pages in the PDF.</p><p>Here, the number of pages is stored in the variable page_number, and print() displays it.</p><p>For example, if the PDF contains 44 pages, the output will be:</p><p><strong>44</strong></p><h3>2. Using len()</h3><p>You can also use Python’s built-in len() function:</p><p>len(doc)</p><p>This returns the total number of pages in the PDF as well.</p><p>For example:</p><pre>print(len(doc))</pre><p>Example Output:</p><p><strong>44</strong></p><blockquote><strong>Key takeaway</strong></blockquote><blockquote>Both approaches give you the number of pages:</blockquote><blockquote>doc.page_count</blockquote><blockquote>or</blockquote><blockquote>len(doc)</blockquote><h3>Complete Example</h3><pre>%pip install -q -U pymupdf<br><br>from google.colab import files<br>uploaded = files.upload()<br><br>import pymupdf<br>doc = pymupdf.open(&quot;data.pdf&quot;)<br><br># Method 1<br>page_number = doc.page_count<br>print(page_number)<br><br># Method 2<br>print(len(doc))</pre><p><strong>Note:</strong> Before running the following code, make sure that the <strong>pymupdf </strong>package is installed, that your PDF file (<strong>data.pdf</strong>) has been uploaded to your Google Colab environment, and that you know how to open the PDF file using PyMuPDF.</p><p><strong>-Want to learn how to install the pymupdf package in Google Colab?</strong></p><p>Check out this mini-guide: <a href="https://payhip.com/PDFPythonHub/blog/news/how-to-install-pymupdf-in-google-colab">How to Install PyMuPDF in Google Colab</a>.</p><p><strong>-Want to learn how to upload your PDF file in Google Colab?</strong></p><p>Check out this mini-guide: <a href="https://payhip.com/PDFPythonHub/blog/news/uploading-files-in-google-colab">Uploading Files in Google Colab</a>.</p><p><strong>-Want to learn how to open your PDF file in Google Colab using PyMuPDF?</strong></p><p>Check out this mini-guide: <a href="https://payhip.com/PDFPythonHub/blog/news/open-your-first-pdf-with-pymupdf">Open Your First PDF with PyMuPDF</a></p><h3>Open the notebook</h3><p>Open the Google Colab notebook for this PDF mini-guide and run the code as you follow along.</p><p>[<a href="https://colab.research.google.com/drive/1PCDK-mZzL6slYLc3YEEr1h2ZFE3m_dgC?usp=sharing">Open in Google Colab</a>]</p><p>This mini-guide was originally published on <a href="https://payhip.com/PDFPythonHub">PDF Python Hub</a>, where you can find more in-depth Python resources for working with PDFs.</p><figure><img alt="Python code using PyMuPDF to count the total number of pages in a PDF." src="https://cdn-images-1.medium.com/max/1024/1*rkTgqxbxg-S1H4XmCoX07A.jpeg" /><figcaption>Image generated by Gemini</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6044c34b0dc0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PyMuPDF for Beginners: Open Your First PDF]]></title>
            <link>https://medium.com/@pdfpythonlab/pymupdf-for-beginners-open-your-first-pdf-41c4ff02114b?source=rss-4aa511f43bae------2</link>
            <guid isPermaLink="false">https://medium.com/p/41c4ff02114b</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pdf]]></category>
            <category><![CDATA[pymupdf]]></category>
            <category><![CDATA[pdf-processing]]></category>
            <category><![CDATA[python-libraries]]></category>
            <dc:creator><![CDATA[PDF & Python Lab]]></dc:creator>
            <pubDate>Wed, 02 Sep 2026 13:25:11 GMT</pubDate>
            <atom:updated>2026-11-20T18:51:52.104Z</atom:updated>
            <content:encoded><![CDATA[<p>PyMuPDF is a Python library for working with PDF files. The code below opens an existing PDF so you can read, extract, or modify its contents.</p><h3>1. Import PyMuPDF</h3><pre>import pymupdf</pre><p>This imports the PyMuPDF library and makes its PDF tools available in your Python program.</p><h3>2. Open the PDF</h3><pre>doc = pymupdf.open(&quot;data.pdf&quot;)</pre><ul><li>pymupdf.open()opens the PDF file named data.pdf.</li><li>The returned document is stored in the variable<strong> </strong>doc, which you can then use to access the PDF’s pages and content.</li></ul><h3>Complete Example</h3><pre>%pip install -q -U pymupdf<br><br>from google.colab import files<br>uploaded = files.upload()<br><br>import pymupdf<br>doc = pymupdf.open(&quot;data.pdf&quot;)</pre><p>In short: import pymupdf loads the library, while pymupdf.open(&quot;data.pdf&quot;)opens the PDF and stores it in doc for further processing.</p><p><strong><em>Note:</em></strong><em> Make sure the </em><em>pymupdf package is installed and the PDF file (</em><em>data.pdf) is uploaded to your Google Colab environment before running the following code.</em></p><h4>-Want to learn how to install the pymupdf package in Google Colab?</h4><p>Check out this mini-guide: <a href="https://payhip.com/PDFPythonHub/blog/news/how-to-install-pymupdf-in-google-colab">How to Install PyMuPDF in Google Colab</a>.</p><h4>-Want to learn how to upload your PDF file in Google Colab?</h4><p>Check out this mini-guide: <a href="https://payhip.com/PDFPythonHub/blog/news/uploading-files-in-google-colab">Uploading Files in Google Colab</a>.</p><h3>Open the notebook</h3><p>Open the Google Colab notebook for this PDF mini-guide and run the code as you follow along.</p><p>[<a href="https://colab.research.google.com/drive/1zlZaeJzMq7iXaaRAXeiQ4KhwTniGyEX4?usp=sharing">Open in Google Colab</a>]</p><p>This mini-guide was originally published on <a href="https://payhip.com/PDFPythonHub">PDF Python Hub</a>, where you can find more in-depth Python resources for working with PDFs.</p><figure><img alt="Python code using PyMuPDF to import the library and open a PDF file named sample.pdf." src="https://cdn-images-1.medium.com/max/1024/1*kAvQJWem_iISuDvIt9K8IQ.jpeg" /><figcaption>Image generated by Gemini</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41c4ff02114b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Install PyMuPDF in Google Colab: A Beginner’s Guide]]></title>
            <link>https://medium.com/@pdfpythonlab/build-a-pdf-inspector-free-course-tutorial-1-installing-pymupdf-3d7d9b4dd444?source=rss-4aa511f43bae------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d7d9b4dd444</guid>
            <category><![CDATA[google-colab]]></category>
            <category><![CDATA[python-beginner]]></category>
            <category><![CDATA[pymupdf]]></category>
            <category><![CDATA[pdf]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[PDF & Python Lab]]></dc:creator>
            <pubDate>Fri, 31 Jul 2026 11:10:14 GMT</pubDate>
            <atom:updated>2026-11-19T18:48:18.346Z</atom:updated>
            <content:encoded><![CDATA[<h4>PyMuPDF is a Python library for working with PDF files. The following commands install the library, import it, and check which version is installed.</h4><h3>1. Install PyMuPDF</h3><pre>%pip install -q -U pymupdf</pre><ul><li>%pip runs pip directly from a Jupyter Notebook or Google Colab cell.</li><li>install tells pipto install a package.</li><li>-U (or --upgrade) tells pipto install the package if it is not already installed or upgrade it to the latest available compatible version if it is already installed.</li><li>-q (or --quiet) reduces the amount of installation output.</li><li>pymupdf is the package name.</li></ul><h3>2. Import PyMuPDF</h3><pre>import pymupdf</pre><p>This makes the PyMuPDF library available in your Python code.</p><h3>3. Check the Installed Version</h3><pre>print(pymupdf.__version__)</pre><p>This prints the version of PyMuPDF currently installed.</p><p>You should see output similar to:</p><p>1.x.x</p><h3>Complete Example</h3><pre>%pip install -q -U pymupdf<br><br>import pymupdf<br><br>print(pymupdf.__version__)</pre><p><em>The exact version will depend on the latest version available when you run the installation.</em></p><h3>Open the notebook</h3><p>Open the Google Colab notebook for this PDF mini-guide and run the code as you follow along.</p><p>[<a href="https://colab.research.google.com/drive/1i1YBr1Xg6ZfEyeb9NNYgY-ViKSrVu-df?usp=sharing">Open in Google Colab</a>]</p><p>This mini-guide was originally published on <a href="https://payhip.com/PDFPythonHub">PDF Python Hub</a>, where you can find more in-depth Python resources for working with PDFs.</p><h3>What’s Next? Upload Your PDF in Google Colab</h3><p>Want to learn how to upload your PDF in Google Colab?</p><p>Check out this mini-guide: <a href="https://payhip.com/PDFPythonHub/blog/news/uploading-files-in-google-colab">Uploading FIles in Google Colab</a></p><figure><img alt="Learn how to install PyMuPDF in Google Colab using Python." src="https://cdn-images-1.medium.com/max/1024/1*71ZW2l6nmd7pVhJLR_KZQw.png" /><figcaption>Image generated by ChatGPT</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d7d9b4dd444" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>