#include <stdio.h>
#include <poppler-document.h>
int main(int argc, char *argv[]) {
if (argc != 2) {
fprintf(stderr, "Usage: %s <input_pdf>\n", argv[0]);
return 1;
}
const char *input_pdf = argv[1];
GError *error = NULL;
// Open the PDF document
PopplerDocument *document = poppler_document_new_from_file(input_pdf, NULL, &error);
if (error != NULL) {
fprintf(stderr, "Error opening PDF: %s\n", error->message);
g_error_free(error);
return 1;
}
// Check if the document is encrypted
if (poppler_document_get_n_pages(document) == 0) {
printf("The PDF is encrypted.\n");
} else {
printf("The PDF is not encrypted.\n");
}
// Check if the document is signed
if (poppler_document_get_metadata(document, "signature") != NULL) {
printf("The PDF is signed.\n");
} else {
printf("The PDF is not signed.\n");
}
// Free the document object
g_object_unref(document);
return 0;
}
driessen wrote:Antonio,
I'm afraid that is somewhat to difficult for me.
I need to know if a document is digitally signed or not.
But I don't know how to implement your suggestion.
#include "FiveWin.ch"
function Main()
MsgInfo( IsSigned( "fwintro.pdf" ) )
return nil
function IsSigned( cPDFFileName )
return At( "/SigFlags", hb_memoRead( cPDFFileName ) ) != 0
import sys, aspose.pdf as ap
pdfSign = ap.facades.PdfFileSignature()
pdfSign.bind_pdf(sys.argv[ 1 ])
signatures = pdfSign.get_sign_names( True )
if( signatures.length ) > 0 :
print( "signed" )
else:
print( "not signed" )
pyinstaller --onefile signed.py
WaitRun( "signed.exe " + cPdfFileName + " > result.txt" )
if hb_memoRead( "result.txt" ) == "signed"
MsgInfo( "signed" )
else
MsgInfo( "non signed" )
endif
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 43 guests