The Debian packaging of OCRmyPDF is maintained using dgit.  For the
sake of an efficient workflow, Debian modifications to the upstream
source are squashed into a single diff, rather than a series of quilt
patches.  To obtain a patch queue for package version 1.2.3-1:

    # apt-get install dgit
    % dgit clone ocrmypdf
    % cd ocrmypdf
    % git log --oneline 1.2.3..debian/1.2.3-1 -- . ':!debian'

See dgit(1), dgit(7) and dgit-maint-merge(7) for more information.
--- ocrmypdf-4.3.5.orig/docs/cookbook.rst
+++ ocrmypdf-4.3.5/docs/cookbook.rst
@@ -110,7 +110,7 @@ To set up a "hot folder" that will trigg
 
 .. code-block:: bash
 
-	pip install watchdog
+	apt-get install python-watchdog
 
 watchdog installs the command line program ``watchmedo``, which can be told to run ``ocrmypdf`` on any .pdf added to the current directory (``.``) and place the result in the previously created ``out/`` folder.
 
--- ocrmypdf-4.3.5.orig/docs/index.rst
+++ ocrmypdf-4.3.5/docs/index.rst
@@ -17,7 +17,6 @@ Contents:
    :maxdepth: 2
 
    introduction
-   installation
    languages
    cookbook
    security
--- ocrmypdf-4.3.5.orig/docs/languages.rst
+++ ocrmypdf-4.3.5/docs/languages.rst
@@ -7,10 +7,7 @@ OCRmyPDF uses Tesseract for OCR, and rel
 
 Tesseract supports `most languages <https://github.com/tesseract-ocr/tesseract/blob/master/doc/tesseract.1.asc#languages>`_.
 
-For Linux users, you can often find packages that provide language packs:
-
-Debian and Ubuntu users
------------------------
+You can often find packages that provide language packs:
 
 .. code-block:: bash
 
@@ -23,16 +20,6 @@ Debian and Ubuntu users
 You can then pass the ``-l LANG`` argument to OCRmyPDF to give a hint as to what languages it should search for. Multiple
 languages can be requested using either ``-l eng+fre`` (English and French) or ``-l eng -l fre``.
 
-Mac OS X (macOS) users
-----------------------
-
-You can install additional language packs by :ref:`installing Tesseract using Homebrew with all language packs <macos-all-languages>`.
-
-Docker users
-------------
-
-Users of the Docker image may use the alternative :ref:`"polyglot" container <docker-polyglot>` which includes all languages.
-
 Known limitations
 -----------------
 
@@ -45,4 +32,4 @@ As of v4.2, users of ocrmypdf working la
 The reasons for this are:
 
 * The latest version of Ghostscript (9.19 as of this writing) has unfixed bugs in Unicode handling that generate invalid character maps, so Ghostscript cannot be used for PDF/A conversion
-* The default "hocr" PDF renderer does not handle Asian fonts properly
\ No newline at end of file
+* The default "hocr" PDF renderer does not handle Asian fonts properly
--- ocrmypdf-4.3.5.orig/ocrmypdf/__main__.py
+++ ocrmypdf-4.3.5/ocrmypdf/__main__.py
@@ -143,17 +143,17 @@ your PDF, use --output-type pdf.
 
 If OCRmyPDF is given an image file as input, it will attempt to convert the
 image to a PDF before processing.  For more control over the conversion of
-images to PDF, use the Python package img2pdf or other image to PDF software.
+images to PDF, use img2pdf, or other image to PDF software.
 
 For example, this command uses img2pdf to convert all .png files beginning
 with the 'page' prefix to a PDF, fitting each image on A4-sized paper, and
-sending the result to OCRmyPDF through a pipe.  img2pdf is a dependency of
-ocrmypdf so it is already installed.
+sending the result to OCRmyPDF through a pipe.
 
     img2pdf --pagesize A4 page*.png | ocrmypdf - myfile.pdf
 
-Online documentation is located at:
-    https://ocrmypdf.readthedocs.io/en/latest/introduction.html
+HTML documentation is located at:
+    /usr/share/doc/ocrmypdf/html/index.html
+after installing the ocrmypdf-doc package.
 
 """)
 
--- ocrmypdf-4.3.5.orig/ocrmypdf/pdfa.py
+++ ocrmypdf-4.3.5/ocrmypdf/pdfa.py
@@ -28,11 +28,7 @@ pdfa_def_template = u"""%!
 /ICCProfile ($icc_profile)
 def
 
-[ /Title <$title>
-  /Author <$author>
-  /Subject <$subject>
-  /Keywords <$keywords>
-  /Creator <$creator>
+[$docinfo
   /DOCINFO pdfmark
 
 % Define an ICC profile :
@@ -91,16 +87,26 @@ def encode_text_string(s: str) -> str:
 
 
 def _get_pdfa_def(icc_profile, icc_identifier, pdfmark):
-    pdfmark_utf16 = {k: encode_text_string(v) for k, v in pdfmark.items()}
+    # Ghostscript <= 9.21 has a bug where null entries in DOCINFO might produce
+    # ERROR: VMerror (-25) on closing pdfwrite device.
+    # https://bugs.ghostscript.com/show_bug.cgi?id=697684
+    # Work around this by only adding keys that have a nontrivial value
+    docinfo_keys = ('/Title', '/Author', '/Subject', '/Creator', '/Keywords')
+    docinfo_line_template = '  {key} <{value}>'
+
+    def docinfo_gen():
+        for key in docinfo_keys:
+            if key in pdfmark and pdfmark[key].strip() != '':
+                line = docinfo_line_template.format(
+                    key=key, value=encode_text_string(pdfmark[key]))
+                yield line
+
+    docinfo = '\n'.join(docinfo_gen())
 
     t = Template(pdfa_def_template)
     result = t.substitute(icc_profile=icc_profile,
                           icc_identifier=icc_identifier,
-                          title=pdfmark_utf16.get('/Title', ''),
-                          author=pdfmark_utf16.get('/Author', ''),
-                          subject=pdfmark_utf16.get('/Subject', ''),
-                          creator=pdfmark_utf16.get('/Creator', ''),
-                          keywords=pdfmark_utf16.get('/Keywords', ''))
+                          docinfo=docinfo)
     return result
 
 
--- ocrmypdf-4.3.5.orig/tests/test_main.py
+++ ocrmypdf-4.3.5/tests/test_main.py
@@ -257,16 +257,13 @@ def test_preserve_metadata(spoof_tessera
 def test_override_metadata(spoof_tesseract_noop, output_type):
     input_file = _infile('c02-22.pdf')
     output_file = _outfile('test_override_metadata.pdf')
-
     german = 'Du siehst den Wald vor lauter Bäumen nicht.'
     chinese = '孔子'
-    high_unicode = 'U+1030C is: 𐌌'
 
     p, out, err = run_ocrmypdf(
         input_file, output_file,
         '--title', german,
         '--author', chinese,
-        '--subject', high_unicode,
         '--output-type', output_type,
         env=spoof_tesseract_noop)
 
@@ -283,7 +280,6 @@ def test_override_metadata(spoof_tessera
 
     assert pdfinfo['Title'] == german
     assert pdfinfo['Author'] == chinese
-    assert pdfinfo['Subject'] == high_unicode
     assert pdfinfo.get('Keywords', '') == ''
 
     pdfa_info = file_claims_pdfa(output_file)
