docs: @Override
      public void writeText(PDDocument doc, Writer outputStream) throws IOException
      {
          try
          {
              DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
              DOMImplementationLS impl = (DOMImplementationLS)registry.getDOMImplementation("LS");
              LSSerializer writer = impl.createLSSerializer();
              LSOutput output = impl.createLSOutput();
              writer.getDomConfig().setParameter("format-pretty-print", true);
              output.setCharacterStream(outputStream);
              createDOM(doc);
              writer.write(getDocument(), output);
          } catch (ClassCastException e) {
              throw new IOException("Error: cannot initialize the DOM serializer", e);
          } catch (ClassNotFoundException e) {
              throw new IOException("Error: cannot initialize the DOM serializer", e);
          } catch (InstantiationException e) {
              throw new IOException("Error: cannot initialize the DOM serializer", e);
          } catch (IllegalAccessException e) {
              throw new IOException("Error: cannot initialize the DOM serializer", e);
          }
      }