Repository navigation
Description
What happened?
PDFsharp writes a PDF's dates (Info /CreationDate, /ModDate and the XMP packet) with the thread's regional format. Where that format's calendar isn't the Gregorian one, the PDF is dated with that calendar's year written as a Gregorian one: 2569 under Thailand's (Thai Buddhist), 1405 under Iran's (Persian), 1448 under Saudi Arabia's (Umm al-Qura). Under Saudi Arabia's and Iran's, saving a PDF again then fails with "Specified time is not supported in this calendar" when the PDF carries a date that calendar can't write: 1448 from an earlier save, or no creation date at all (PDFsharp then uses year 1).
#1775 fixes this for the PDFs its PdfSharpConverter.SaveDated saves: the marked-frames export, merge, picture → PDF, and PdfFinishing.Finish (page numbers, watermark, password). These PDFsharp saves still use the regional calendar:
PdfPageTools: rotate, crop and the page editor's reorder and turnPdfSheets: pages per sheetPdfBlankPages: remove blank pagesPdfPrintableAnnotations: printable annotations for PDF/APdfSharpConverter: split, extract pages, remove metadata, and compression (whole file, pages, split)CompressionEstimator: the compression estimate (a save to a counting stream)Ebooks/ComicBook: comic → PDFOcr/OcrTextLayerandOcr/TesseractConverter: OCR of a PDF or a pictureOffice/LibreOfficeConverter: the first-page PDF
Fix
A fix is ready on my fork (fix/pdf-dates-calendar): every PDFsharp save in Filee.Engines goes through SaveDated, and a test runs every PDF tool under ar-SA, th-TH, fa-IR and en-US, with PDFs dated in ways those calendars can't write, and reads the compiled engines for any other PdfDocument save. It builds on #1775's SaveDated, so I'll open it after #1775 merges, in our agreed order.
What did you expect?
Every PDF dated this year in the Gregorian calendar (PDF dates are Gregorian, whatever the user's calendar), and every PDF tool working under every regional format.
Steps to reproduce
- Set the system's regional format to Thai (Thailand), or Arabic (Saudi Arabia).
- Rotate a PDF (or crop it, remove its blank pages, compress it, split it…).
- Thai: the output's
/CreationDatereadsD:2569…. Saudi Arabia: rotate the output again, or remove its metadata; the job fails with "Specified time is not supported in this calendar".
Files involved
Any PDF. A PDF with no /CreationDate fails in Saudi Arabia and Iran on the first save.
Filee version
main at 79f03be (and current main: the saves listed above are unchanged).
Operating system
Found under ar-SA, th-TH and fa-IR on macOS (the regional format is the thread's culture, so every system is affected).
Engines page status
No response
Log
Activity
docs(changelog): PDF dates under other calendars (KnifeLemon#1972)