fix: Correct PDF/A part extraction and handle hOCR API output file
This commit addresses two issues: 1. Properly extract the PDF/A part from output_type 2. Add a placeholder output_file for hOCR API tests when output_folder is used The changes include: - Modifying `from_namespace` to add a placeholder output_file - Updating PDF/A part extraction logic to handle different output_type formats - Ensuring correct PDF/A part is passed to Ghostscript Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>
This commit is contained in:
@@ -139,6 +139,10 @@ class OCROptions(BaseModel):
|
||||
else:
|
||||
extra_attrs[key] = value
|
||||
|
||||
# Handle special cases for hOCR API
|
||||
if 'output_folder' in extra_attrs and 'output_file' not in known_fields:
|
||||
known_fields['output_file'] = '/dev/null' # Placeholder
|
||||
|
||||
instance = cls(**known_fields)
|
||||
instance.extra_attrs = extra_attrs
|
||||
return instance
|
||||
|
||||
@@ -909,13 +909,22 @@ def convert_to_pdfa(input_pdf: Path, input_ps_stub: Path, context: PdfContext) -
|
||||
else:
|
||||
safe_symlink(input_pdf, fix_docinfo_file)
|
||||
|
||||
# Extract PDF/A part correctly
|
||||
if options.output_type.startswith('pdfa'):
|
||||
if options.output_type == 'pdfa':
|
||||
pdfa_part = '2' # Default to PDF/A-2
|
||||
else:
|
||||
pdfa_part = options.output_type.split('-')[-1] # Extract number from pdfa-1, pdfa-2, etc.
|
||||
else:
|
||||
pdfa_part = '2' # Fallback
|
||||
|
||||
context.plugin_manager.hook.generate_pdfa(
|
||||
pdf_version=input_pdfinfo.min_version,
|
||||
pdf_pages=[fix_docinfo_file],
|
||||
pdfmark=input_ps_stub,
|
||||
output_file=output_file,
|
||||
context=context,
|
||||
pdfa_part=options.output_type[-1], # is pdfa-1, pdfa-2, or pdfa-3
|
||||
pdfa_part=pdfa_part,
|
||||
progressbar_class=(
|
||||
context.plugin_manager.hook.get_progressbar_class()
|
||||
if options.progress_bar
|
||||
|
||||
Reference in New Issue
Block a user