@@ -528,6 +528,16 @@ def main() -> None:
528528 f"{ PATH_TO_CHROME_DRIVER_DEBUG_LOG } ."
529529 ),
530530 )
531+ command_parser_print .add_argument (
532+ "--strict" ,
533+ action = "store_true" ,
534+ help = (
535+ "Enables Strict mode. In this mode, the library always performs a "
536+ "validation of printed pages and raise a runtime error if the "
537+ "validation fails. Without the Strict mode enabled, only a warning "
538+ "message is printed and the execution continues."
539+ ),
540+ )
531541 command_parser_print .add_argument (
532542 "paths" , nargs = "+" , help = "Paths to input HTML file."
533543 )
@@ -587,12 +597,18 @@ def exit_handler() -> None:
587597 with measure_performance ("html2pdf4doc: validating page count" ):
588598 reader = PdfReader (path_to_output_pdf )
589599 if len (reader .pages ) != page_count :
590- raise RuntimeError (
591- "Something went wrong with the printed page. "
600+ error_message = (
601+ "An error occurred with the printed page. "
592602 f"Page count mismatch: "
593- f"PDF pages: { len (reader .pages )} , "
594- f"html2pdf4doc pages: { page_count } ."
603+ f"PDF pages = { len (reader .pages )} , "
604+ f"html2pdf4doc pages = { page_count } . "
605+ f"Please report this issue at: "
606+ f"https://github.com/strictdoc-project/html2pdf4doc_python."
595607 )
608+ if args .strict :
609+ raise RuntimeError (error_message )
610+ else :
611+ print ("html2pdf4doc: warning: " + error_message ) # noqa: T201
596612
597613 else :
598614 print ("html2pdf4doc: unknown command." ) # noqa: T201
0 commit comments