Created
September 13, 2023 16:57
-
-
Save pigreco/272e58381ac896a86acbd4ccc1bc7fce to your computer and use it in GitHub Desktop.
Funzione personalizzate per field clac by Giulio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Korto19 2023 | |
from qgis.core import * | |
from qgis.gui import * | |
from PyPDF2 import PdfReader | |
@qgsfunction(group='HfcQGIS',referenced_columns=[]) | |
def Get_Pdf_N_Pages(pdfpath): | |
""" | |
Restituisce il numero di pagine di un pdf dando il percorso | |
<h2>Example usage:</h2> | |
<ul> | |
<li>Get_Pdf_N_Pages(pdfpath)-> 3</li> | |
</ul> | |
""" | |
reader = PdfReader(str(pdfpath)) | |
number_of_pages = len(reader.pages) | |
return number_of_pages |
Questa funziona
# Korto19 2023
from qgis.core import *
from qgis.gui import *
from PyPDF2 import PdfReader
@qgsfunction(group='HfcQGIS',referenced_columns=[])
def Get_Pdf_N_Pages(pdfpath, *args, **kwargs):
"""
Restituisce il numero di pagine di un pdf dando il percorso
<h2>Example usage:</h2>
<ul>
<li>Get_Pdf_N_Pages(pdfpath)-> 3</li>
</ul>
"""
reader = PdfReader(str(pdfpath))
number_of_pages = len(reader.pages)
return number_of_pages
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
errore su QGIS 3.28.10 LTR Firenze
Versione Python 3.9.5