Adds a <CODE>PdfWriter</CODE> to the <CODE>PdfDocument</CODE>.

@param writer the <CODE>PdfWriter</CODE> that writes everything
what is added to this document to an outputstream.
@throws DocumentException on error
161124
public void addWriter(PdfWriter writer) throws DocumentException {
        if (this.writer == null) {
            this.writer = writer;
            annotationsImp = new PdfAnnotationsImp(writer);
            return;
        }
        throw new DocumentException("You can only add a writer to a PdfDocument once.");
    }
626294
public void write(Writer out)
         throws IOException
    {
        for (int i=0; i <elements.size() ; i++)
        {
            Object element = elements.get(i);
          
            if (element instanceof Element)
                ((Element)element).write(out);
            else if (element==null)
                out.write("null");
            else 
                out.write(element.toString());
        }
    }
87521
public void write(PrintWriter writer) {
        this.output = writer;
        dispatch(base, false);
        writer.flush();
    }
879582
@SuppressWarnings("unchecked")
	public void addWriter(RecordWriter<SerializationDelegate<T>> writer)
	{
		// avoid using the array-list here to reduce one level of object indirection
		if (this.writers == null) {
			this.writers = new RecordWriter[] {writer};
		}
		else {
			RecordWriter<SerializationDelegate<T>>[] ws = new RecordWriter[this.writers.length + 1];
			System.arraycopy(this.writers, 0, ws, 0, this.writers.length);
			ws[this.writers.length] = writer;
			this.writers = ws;
		}
	}
552838
public static void appendDebugInfo(PdfWriter writer, Document document, EnhancedMap settings, StylerFactory stylerFactory) throws DocumentException, VectorPrintException {

      PdfContentByte canvas = writer.getDirectContent();
      canvas.setFontAndSize(FontFactory.getFont(FontFactory.COURIER).getBaseFont(), 8);
      canvas.setColorFill(itextHelper.fromColor(settings.getColorProperty(Color.MAGENTA, ReportConstants.DEBUGCOLOR)));
      canvas.setColorStroke(itextHelper.fromColor(settings.getColorProperty(Color.MAGENTA, ReportConstants.DEBUGCOLOR)));

      Font f = FontFactory.getFont(FontFactory.COURIER, 8);

      f.setColor(itextHelper.fromColor(settings.getColorProperty(Color.MAGENTA, ReportConstants.DEBUGCOLOR)));

      float top = document.getPageSize().getTop();

      document.add(new Phrase(new Chunk("table: ", f).setLocalDestination(DEBUGPAGE)));
      document.add(Chunk.NEWLINE);
      document.add(new Phrase("cell: ", f));
      document.add(Chunk.NEWLINE);
      document.add(new Phrase("image: ", f));
      document.add(Chunk.NEWLINE);
      document.add(new Phrase("text: ", f));
      document.add(Chunk.NEWLINE);
      document.add(new Phrase("background color is shown in a small rectangle", f));
      document.add(Chunk.NEWLINE);
      canvas.setLineWidth(2);
      canvas.setLineDash(new float[]{0.3f, 5}, 0);
      float left = document.leftMargin();
      canvas.rectangle(left + 80, top - 25, left + 80, 8);
      canvas.closePathStroke();
      canvas.setLineWidth(0.3f);
      canvas.setLineDash(new float[]{2, 2}, 0);
      canvas.rectangle(left + 80, top - 37, left + 80, 8);
      canvas.closePathStroke();
      canvas.setLineDash(new float[]{1, 0}, 0);
      canvas.rectangle(left + 80, top - 50, left + 80, 8);
      canvas.closePathStroke();
      canvas.setLineDash(new float[]{0.3f, 5}, 0);
      canvas.rectangle(left + 80, top - 63, left + 80, 8);
      canvas.closePathStroke();
      document.add(Chunk.NEWLINE);

      document.add(new Phrase("fonts available: " + FontFactory.getRegisteredFonts(), f));

      document.add(Chunk.NEWLINE);

      if (settings.getBooleanProperty(false, DEBUG)) {
         document.add(new Phrase("OVERVIEW OF STYLES FOR THIS REPORT", f));
         document.add(Chunk.NEWLINE);
         document.add(Chunk.NEWLINE);
      }

      Font b = new Font(f);
      b.setStyle("bold");
      Set<Map.Entry<String, String>> entrySet = stylerFactory.getStylerSetup().entrySet();
      for (Map.Entry<String, String> styleInfo : entrySet) {
         String key = styleInfo.getKey();
         document.add(new Chunk(key, b).setLocalDestination(key));
         document.add(new Chunk(": " + styleInfo.getValue(), f));
         document.add(Chunk.NEWLINE);
         document.add(new Phrase("   styling configured by " + key + ": ", f));
         for (BaseStyler st : (Collection<BaseStyler>) stylerFactory.getBaseStylersFromCache((key))) {
            document.add(Chunk.NEWLINE);
            document.add(new Chunk("      ", f));
            document.add(new Chunk(st.getClass().getSimpleName(), DebugHelper.debugFontLink(canvas, settings)).setLocalGoto(st.getClass().getSimpleName()));
            document.add(new Chunk(":", f));
            document.add(Chunk.NEWLINE);
            document.add(new Phrase("         non default parameters for " + st.getClass().getSimpleName() + ": " + getParamInfo(st), f));
            document.add(Chunk.NEWLINE);
            if (!st.getConditions().isEmpty()) {
               document.add(new Phrase("      conditions for this styler: ", f));
            }
            for (StylingCondition sc : (Collection<StylingCondition>) st.getConditions()) {
               document.add(Chunk.NEWLINE);
               document.add(new Chunk("         ", f));
               document.add(new Chunk(sc.getClass().getSimpleName(), DebugHelper.debugFontLink(canvas, settings)).setLocalGoto(sc.getClass().getSimpleName()));
               document.add(Chunk.NEWLINE);
               document.add(new Phrase("            non default parameters for " + sc.getClass().getSimpleName() + ": " + getParamInfo(sc), f));
            }
         }
         document.add(Chunk.NEWLINE);
         document.add(Chunk.NEWLINE);
      }

      document.newPage();

      document.add(new Phrase("Properties used for the report", f));
      document.add(Chunk.NEWLINE);

      ByteArrayOutputStream bo = new ByteArrayOutputStream();
      PrintStream ps = new PrintStream(bo);

      settings.listProperties(ps);
      ps.close();
      document.add(new Paragraph(bo.toString(), f));

      document.newPage();

      try {
         bo = new ByteArrayOutputStream();
         ps = new PrintStream(bo);
         Help.printHelpHeader(ps);
         ps.close();
         document.add(new Paragraph(bo.toString(), f));

         Help.printStylerHelp(document, f);

         Help.printConditionrHelp(document, f);

      } catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException ex) {
         log.log(Level.SEVERE, null, ex);
      }
   }
1200132
public static void write(char c, Writer writer) {
        try {
            writer.write(c);
        } catch (IOException e) {
            throw E.ioException(e);
        }
    }
1266130
void writeDocument(OutputStream outStream, Document doc) {
        DOMImplementationRegistry domRegistry = null;
        try {
            domRegistry = DOMImplementationRegistry.newInstance();
        // Fortify Mod: Broaden try block to capture all potential exceptions
        // } catch (Exception e) {
        //    LOGR.warning(e.getMessage());
        // }
        DOMImplementationLS impl = (DOMImplementationLS) domRegistry
                .getDOMImplementation("LS");
        LSSerializer writer = impl.createLSSerializer();
        writer.getDomConfig().setParameter("xml-declaration", false);
        writer.getDomConfig().setParameter("format-pretty-print", true);
        LSOutput output = impl.createLSOutput();
        output.setEncoding("UTF-8");
        output.setByteStream(outStream);
        writer.write(doc, output);
        } catch (Exception e) {
            LOGR.warning(e.getMessage());
        }
    }
1368019
public void write(Writer out)
         throws IOException
    {
        out.write("<!--\n");
        super.write(out);
        out.write("\n-->");
    }
1000053
public void setWriter (Writer writer) {
		if (!(writer instanceof JsonWriter)) writer = new JsonWriter(writer);
		this.writer = (JsonWriter)writer;
		this.writer.setOutputType(outputType);
		this.writer.setQuoteLongValues(quoteLongValues);
	}
1031990
public static PdfFileSpecification fileExtern(PdfWriter writer, String filePath) {
        PdfFileSpecification fs = new PdfFileSpecification();
        fs.writer = writer;
        fs.put(PdfName.F, new PdfString(filePath));
        fs.setUnicodeFileName(filePath, false);
        return fs;
    }
1328538
public void generateOutput(Writer outputWriter) throws IOException {
        String s = generateOutput();
        outputWriter.write(s);
    }
685052
public static void writeLine(BufferedWriter writer, String line) throws IOException {
        writer.write(line);
        writer.newLine();
    }
1349841
public void writeExternal(PofWriter writer) throws IOException {
        writer.writeObject(0, expression);
        writer.writeMap(1, variables, String.class);
    }
12219
public void addDocument(Document doc) throws IOException {
		// needs to differenciate SimpleDocuments from MultiField ones
		// each class has its own way of serializing
		String serial = doc.getStringSerialization();
		raw_file_buffer.write(serial);
	}
1190077
public void toPdf(PdfWriter writer, OutputStream os) throws IOException {
        os.write('[');

        if (dash >= 0) {
            new PdfNumber(dash).toPdf(writer, os);
            if (gap >= 0) {
                os.write(' ');
                new PdfNumber(gap).toPdf(writer, os);
            }
        }
        os.write(']');
        if (phase >=0) {
            os.write(' ');
            new PdfNumber(phase).toPdf(writer, os);
        }
    }
225791
public void xmlWriteOn(FormattedWriter writer) throws IOException
  {
    writer.newLine();
    writer.taggedValue("remoteMEUuid", remoteMEUuid);
    writer.newLine();
    writer.taggedValue("streamID", streamID);
    writer.newLine();
    writer.taggedValue("initialData", initialData);
    writer.newLine();
    writer.taggedValue("type", type);
  }
303881
public void toPdf(PdfWriter writer, OutputStream os) throws IOException {
        if (bytes != null)
            os.write(bytes);
    }