PdfCopy.java

1
/*
2
 * $Id: PdfCopy.java 3912 2009-04-26 08:38:15Z blowagie $
3
 *
4
 * Copyright (C) 2002 Mark Thompson
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * (the "License"); you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at http://www.mozilla.org/MPL/
9
 *
10
 * Software distributed under the License is distributed on an "AS IS" basis,
11
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
 * for the specific language governing rights and limitations under the License.
13
 *
14
 * The Original Code is 'iText, a free JAVA-PDF library'.
15
 *
16
 * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
17
 * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
18
 * All Rights Reserved.
19
 * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
20
 * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
21
 *
22
 * Contributor(s): all the names of the contributors are added in the source code
23
 * where applicable.
24
 *
25
 * Alternatively, the contents of this file may be used under the terms of the
26
 * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
27
 * provisions of LGPL are applicable instead of those above.  If you wish to
28
 * allow use of your version of this file only under the terms of the LGPL
29
 * License and not to allow others to use your version of this file under
30
 * the MPL, indicate your decision by deleting the provisions above and
31
 * replace them with the notice and other provisions required by the LGPL.
32
 * If you do not delete the provisions above, a recipient may use your version
33
 * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
34
 *
35
 * This library is free software; you can redistribute it and/or modify it
36
 * under the terms of the MPL as stated above or under the terms of the GNU
37
 * Library General Public License as published by the Free Software Foundation;
38
 * either version 2 of the License, or any later version.
39
 *
40
 * This library is distributed in the hope that it will be useful, but WITHOUT
41
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
42
 * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
43
 * details.
44
 *
45
 * If you didn't download this code from the following link, you should check if
46
 * you aren't using an obsolete version:
47
 * http://www.lowagie.com/iText/
48
 */
49
package com.lowagie.text.pdf;
50
51
import java.io.IOException;
52
import java.io.OutputStream;
53
import java.util.HashMap;
54
55
import com.lowagie.text.Document;
56
import com.lowagie.text.DocumentException;
57
58
import com.lowagie.text.Rectangle;
59
import com.lowagie.text.ExceptionConverter;
60
61
import java.util.ArrayList;
62
import java.util.List;
63
import java.util.Map;
64
65
/**
66
 * Make copies of PDF documents. Documents can be edited after reading and before writing them out.
67
 *
68
 * @author Mark Thompson
69
 */
70
71
public class PdfCopy extends PdfWriter {
72
73
  /**
74
   * This class holds information about indirect references, since they are renumbered by iText.
75
   */
76
  static class IndirectReferences {
77
78
    PdfIndirectReference theRef;
79
    boolean hasCopied;
80
81
    IndirectReferences(PdfIndirectReference ref) {
82
      theRef = ref;
83
      hasCopied = false;
84
    }
85
86
    void setCopied() {
87
      hasCopied = true;
88
    }
89
90
    boolean getCopied() {
91
      return hasCopied;
92
    }
93
94
    PdfIndirectReference getRef() {
95
      return theRef;
96
    }
97
  }
98
99
  protected HashMap<RefKey, IndirectReferences> indirects;
100
  protected HashMap<PdfReader, HashMap<RefKey, IndirectReferences>> indirectMap;
101
  protected PdfReader reader;
102
  protected PdfIndirectReference acroForm;
103
  protected int[] namePtr = {0};
104
  /**
105
   * Holds value of property rotateContents.
106
   */
107
  private boolean rotateContents = true;
108
  protected PdfArray fieldArray;
109
  protected HashMap<PdfTemplate, Object> fieldTemplates;
110
111
  /**
112
   * A key to allow us to hash indirect references
113
   */
114
  protected static class RefKey {
115
116
    int num;
117
    int gen;
118
119
    RefKey(int num, int gen) {
120
      this.num = num;
121
      this.gen = gen;
122
    }
123
124
    RefKey(PdfIndirectReference ref) {
125
      num = ref.getNumber();
126
      gen = ref.getGeneration();
127
    }
128
129
    RefKey(PRIndirectReference ref) {
130
      num = ref.getNumber();
131
      gen = ref.getGeneration();
132
    }
133
134
    public int hashCode() {
135
      return (gen << 16) + num;
136
    }
137
138
    public boolean equals(Object o) {
139 1 1. equals : negated conditional → NO_COVERAGE
      if (!(o instanceof RefKey)) {
140 1 1. equals : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
        return false;
141
      }
142
      RefKey other = (RefKey) o;
143 3 1. equals : negated conditional → NO_COVERAGE
2. equals : negated conditional → NO_COVERAGE
3. equals : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
      return this.gen == other.gen && this.num == other.num;
144
    }
145
146
    public String toString() {
147
      return Integer.toString(num) + ' ' + gen;
148
    }
149
  }
150
151
  /**
152
   * Constructor
153
   *
154
   * @param os outputstream
155
   */
156
  public PdfCopy(Document document, OutputStream os) throws DocumentException {
157
    super(new PdfDocument(), os);
158 1 1. : removed call to com/lowagie/text/Document::addDocListener → NO_COVERAGE
    document.addDocListener(pdf);
159 1 1. : removed call to com/lowagie/text/pdf/PdfDocument::addWriter → NO_COVERAGE
    pdf.addWriter(this);
160
    indirectMap = new HashMap<>();
161
  }
162
163
  /**
164
   * Getter for property rotateContents.
165
   *
166
   * @return Value of property rotateContents.
167
   */
168
  public boolean isRotateContents() {
169
    return this.rotateContents;
170
  }
171
172
  /**
173
   * Setter for property rotateContents.
174
   *
175
   * @param rotateContents New value of property rotateContents.
176
   */
177
  public void setRotateContents(boolean rotateContents) {
178
    this.rotateContents = rotateContents;
179
  }
180
181
  /**
182
   * Grabs a page from the input document
183
   *
184
   * @param reader the reader of the document
185
   * @param pageNumber which page to get
186
   * @return the page
187
   */
188
  public PdfImportedPage getImportedPage(PdfReader reader, int pageNumber) {
189 1 1. getImportedPage : negated conditional → NO_COVERAGE
    if (currentPdfReaderInstance != null) {
190 1 1. getImportedPage : negated conditional → NO_COVERAGE
      if (currentPdfReaderInstance.getReader() != reader) {
191
        try {
192 1 1. getImportedPage : removed call to com/lowagie/text/pdf/PdfReader::close → NO_COVERAGE
          currentPdfReaderInstance.getReader().close();
193 1 1. getImportedPage : removed call to com/lowagie/text/pdf/RandomAccessFileOrArray::close → NO_COVERAGE
          currentPdfReaderInstance.getReaderFile().close();
194
        } catch (IOException ioe) {
195
          // empty on purpose
196
        }
197
        currentPdfReaderInstance = reader.getPdfReaderInstance(this);
198
      }
199
    } else {
200
      currentPdfReaderInstance = reader.getPdfReaderInstance(this);
201
    }
202 1 1. getImportedPage : mutated return of Object value for com/lowagie/text/pdf/PdfCopy::getImportedPage to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
    return currentPdfReaderInstance.getImportedPage(pageNumber);
203
  }
204
205
206
  /**
207
   * Translate a PRIndirectReference to a PdfIndirectReference In addition, translates the object numbers, and copies the referenced object
208
   * to the output file. NB: PRIndirectReferences (and PRIndirectObjects) really need to know what file they came from, because each file
209
   * has its own namespace. The translation we do from their namespace to ours is *at best* heuristic, and guaranteed to fail under some
210
   * circumstances.
211
   */
212
  protected PdfIndirectReference copyIndirect(PRIndirectReference in) throws IOException, BadPdfFormatException {
213
    PdfIndirectReference theRef;
214
    RefKey key = new RefKey(in);
215
    IndirectReferences iRef = indirects.get(key);
216 1 1. copyIndirect : negated conditional → NO_COVERAGE
    if (iRef != null) {
217
      theRef = iRef.getRef();
218 1 1. copyIndirect : negated conditional → NO_COVERAGE
      if (iRef.getCopied()) {
219 1 1. copyIndirect : mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyIndirect to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return theRef;
220
      }
221
    } else {
222
      theRef = body.getPdfIndirectReference();
223
      iRef = new IndirectReferences(theRef);
224
      indirects.put(key, iRef);
225
    }
226
    PdfObject obj = PdfReader.getPdfObjectRelease(in);
227 2 1. copyIndirect : negated conditional → NO_COVERAGE
2. copyIndirect : negated conditional → NO_COVERAGE
    if (obj != null && obj.isDictionary()) {
228
      PdfObject type = PdfReader.getPdfObjectRelease(((PdfDictionary) obj).get(PdfName.TYPE));
229 1 1. copyIndirect : negated conditional → NO_COVERAGE
      if (PdfName.PAGE.equals(type)) {
230 1 1. copyIndirect : mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyIndirect to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return theRef;
231
      }
232
    }
233 1 1. copyIndirect : removed call to com/lowagie/text/pdf/PdfCopy$IndirectReferences::setCopied → NO_COVERAGE
    iRef.setCopied();
234
    obj = copyObject(obj);
235
    addToBody(obj, theRef);
236 1 1. copyIndirect : mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyIndirect to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
    return theRef;
237
  }
238
239
  /**
240
   * Translate a PRDictionary to a PdfDictionary. Also translate all of the objects contained in it.
241
   */
242
  protected PdfDictionary copyDictionary(PdfDictionary in)
243
      throws IOException, BadPdfFormatException {
244
    PdfDictionary out = new PdfDictionary();
245
    PdfObject type = PdfReader.getPdfObjectRelease(in.get(PdfName.TYPE));
246
247
      for (PdfName key : in.getKeys()) {
248
          PdfObject value = in.get(key);
249
          //        System.out.println("Copy " + key);
250 1 1. copyDictionary : negated conditional → NO_COVERAGE
          if (PdfName.PAGE.equals(type)) {
251 2 1. copyDictionary : negated conditional → NO_COVERAGE
2. copyDictionary : negated conditional → NO_COVERAGE
              if (!key.equals(PdfName.B) && !key.equals(PdfName.PARENT)) {
252 1 1. copyDictionary : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
                  out.put(key, copyObject(value));
253
              }
254
          } else {
255 1 1. copyDictionary : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
              out.put(key, copyObject(value));
256
          }
257
      }
258 1 1. copyDictionary : mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyDictionary to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
    return out;
259
  }
260
261
  /**
262
   * Translate a PRStream to a PdfStream. The data part copies itself.
263
   */
264
  protected PdfStream copyStream(PRStream in) throws IOException, BadPdfFormatException {
265
    PRStream out = new PRStream(in, null);
266
267
    for (PdfName key : in.getKeys()) {
268
      PdfObject value = in.get(key);
269 1 1. copyStream : removed call to com/lowagie/text/pdf/PRStream::put → NO_COVERAGE
      out.put(key, copyObject(value));
270
    }
271
272 1 1. copyStream : mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyStream to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
    return out;
273
  }
274
275
276
  /**
277
   * Translate a PRArray to a PdfArray. Also translate all of the objects contained in it
278
   */
279
  protected PdfArray copyArray(PdfArray in) throws IOException, BadPdfFormatException {
280
    PdfArray out = new PdfArray();
281
282
    for (PdfObject value : in.getElements()) {
283
      out.add(copyObject(value));
284
    }
285 1 1. copyArray : mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyArray to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
    return out;
286
  }
287
288
  /**
289
   * Translate a PR-object to a Pdf-object
290
   */
291
  protected PdfObject copyObject(PdfObject in) throws IOException, BadPdfFormatException {
292 1 1. copyObject : negated conditional → NO_COVERAGE
    if (in == null) {
293 1 1. copyObject : mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
      return PdfNull.PDFNULL;
294
    }
295
    switch (in.type) {
296
      case PdfObject.DICTIONARY:
297
        //            System.out.println("Dictionary: " + in.toString());
298 1 1. copyObject : mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return copyDictionary((PdfDictionary) in);
299
      case PdfObject.INDIRECT:
300 1 1. copyObject : mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return copyIndirect((PRIndirectReference) in);
301
      case PdfObject.ARRAY:
302 1 1. copyObject : mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return copyArray((PdfArray) in);
303
      case PdfObject.NUMBER:
304
      case PdfObject.NAME:
305
      case PdfObject.STRING:
306
      case PdfObject.NULL:
307
      case PdfObject.BOOLEAN:
308
      case 0:
309 1 1. copyObject : mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return in;
310
      case PdfObject.STREAM:
311 1 1. copyObject : mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return copyStream((PRStream) in);
312
      //                return in;
313
      default:
314 2 1. copyObject : changed conditional boundary → NO_COVERAGE
2. copyObject : negated conditional → NO_COVERAGE
        if (in.type < 0) {
315
          String lit = in.toString();
316 2 1. copyObject : negated conditional → NO_COVERAGE
2. copyObject : negated conditional → NO_COVERAGE
          if (lit.equals("true") || lit.equals("false")) {
317 1 1. copyObject : mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
            return new PdfBoolean(lit);
318
          }
319 1 1. copyObject : mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
          return new PdfLiteral(lit);
320
        }
321 1 1. copyObject : removed call to java/io/PrintStream::println → NO_COVERAGE
        System.out.println("CANNOT COPY type " + in.type);
322 1 1. copyObject : mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return null;
323
    }
324
  }
325
326
  /**
327
   * convenience method. Given an imported page, set our "globals"
328
   */
329
  protected int setFromIPage(PdfImportedPage iPage) {
330
    int pageNum = iPage.getPageNumber();
331
    PdfReaderInstance inst = currentPdfReaderInstance = iPage.getPdfReaderInstance();
332
    reader = inst.getReader();
333 1 1. setFromIPage : removed call to com/lowagie/text/pdf/PdfCopy::setFromReader → NO_COVERAGE
    setFromReader(reader);
334 1 1. setFromIPage : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
    return pageNum;
335
  }
336
337
  /**
338
   * convenience method. Given a reader, set our "globals"
339
   */
340
  protected void setFromReader(PdfReader reader) {
341
    this.reader = reader;
342
    indirects = indirectMap.get(reader);
343 1 1. setFromReader : negated conditional → NO_COVERAGE
    if (indirects == null) {
344
      indirects = new HashMap<>();
345
      indirectMap.put(reader, indirects);
346
      PdfDictionary catalog = reader.getCatalog();
347
      PRIndirectReference ref;
348
      PdfObject o = catalog.get(PdfName.ACROFORM);
349 2 1. setFromReader : negated conditional → NO_COVERAGE
2. setFromReader : negated conditional → NO_COVERAGE
      if (o == null || o.type() != PdfObject.INDIRECT) {
350
        return;
351
      }
352
      ref = (PRIndirectReference) o;
353 1 1. setFromReader : negated conditional → NO_COVERAGE
      if (acroForm == null) {
354
        acroForm = body.getPdfIndirectReference();
355
      }
356
      indirects.put(new RefKey(ref), new IndirectReferences(acroForm));
357
    }
358
  }
359
360
  /**
361
   * Add an imported page to our output
362
   *
363
   * @param iPage an imported page
364
   * @throws IOException, BadPdfFormatException
365
   */
366
  public void addPage(PdfImportedPage iPage) throws IOException, BadPdfFormatException {
367
    int pageNum = setFromIPage(iPage);
368
369
    PdfDictionary thePage = reader.getPageN(pageNum);
370
    PRIndirectReference origRef = reader.getPageOrigRef(pageNum);
371 1 1. addPage : removed call to com/lowagie/text/pdf/PdfReader::releasePage → NO_COVERAGE
    reader.releasePage(pageNum);
372
    RefKey key = new RefKey(origRef);
373
    PdfIndirectReference pageRef;
374
    IndirectReferences iRef = indirects.get(key);
375 2 1. addPage : negated conditional → NO_COVERAGE
2. addPage : negated conditional → NO_COVERAGE
    if (iRef != null && !iRef.getCopied()) {
376
      pageReferences.add(iRef.getRef());
377 1 1. addPage : removed call to com/lowagie/text/pdf/PdfCopy$IndirectReferences::setCopied → NO_COVERAGE
      iRef.setCopied();
378
    }
379
    pageRef = getCurrentPage();
380 1 1. addPage : negated conditional → NO_COVERAGE
    if (iRef == null) {
381
      iRef = new IndirectReferences(pageRef);
382
      indirects.put(key, iRef);
383
    }
384 1 1. addPage : removed call to com/lowagie/text/pdf/PdfCopy$IndirectReferences::setCopied → NO_COVERAGE
    iRef.setCopied();
385
    PdfDictionary newPage = copyDictionary(thePage);
386 1 1. addPage : removed call to com/lowagie/text/pdf/PdfPages::addPage → NO_COVERAGE
    root.addPage(newPage);
387 1 1. addPage : Replaced integer addition with subtraction → NO_COVERAGE
    ++currentPageNumber;
388
  }
389
390
  /**
391
   * Adds a blank page.
392
   *
393
   * @param  rect The page dimension
394
   * @param  rotation The rotation angle in degrees
395
   * @since 2.1.5
396
   */
397
  public void addPage(Rectangle rect, int rotation) {
398
    PdfRectangle mediabox = new PdfRectangle(rect, rotation);
399
    PageResources resources = new PageResources();
400
    PdfPage page = new PdfPage(mediabox, new HashMap<>(), resources.getResources(), 0);
401 1 1. addPage : removed call to com/lowagie/text/pdf/PdfPage::put → NO_COVERAGE
    page.put(PdfName.TABS, getTabs());
402 1 1. addPage : removed call to com/lowagie/text/pdf/PdfPages::addPage → NO_COVERAGE
    root.addPage(page);
403 1 1. addPage : Replaced integer addition with subtraction → NO_COVERAGE
    ++currentPageNumber;
404
  }
405
406
  /**
407
   * Copy the acroform for an input document. Note that you can only have one, we make no effort to merge them.
408
   *
409
   * @param reader The reader of the input file that is being copied
410
   * @throws IOException, BadPdfFormatException
411
   */
412
  public void copyAcroForm(PdfReader reader) throws IOException, BadPdfFormatException {
413 1 1. copyAcroForm : removed call to com/lowagie/text/pdf/PdfCopy::setFromReader → NO_COVERAGE
    setFromReader(reader);
414
415
    PdfDictionary catalog = reader.getCatalog();
416
    PRIndirectReference hisRef = null;
417
    PdfObject o = catalog.get(PdfName.ACROFORM);
418 2 1. copyAcroForm : negated conditional → NO_COVERAGE
2. copyAcroForm : negated conditional → NO_COVERAGE
    if (o != null && o.type() == PdfObject.INDIRECT) {
419
      hisRef = (PRIndirectReference) o;
420
    }
421 1 1. copyAcroForm : negated conditional → NO_COVERAGE
    if (hisRef == null) {
422
      return; // bugfix by John Englar
423
    }
424
    RefKey key = new RefKey(hisRef);
425
    PdfIndirectReference myRef;
426
    IndirectReferences iRef = indirects.get(key);
427 1 1. copyAcroForm : negated conditional → NO_COVERAGE
    if (iRef != null) {
428
      acroForm = myRef = iRef.getRef();
429
    } else {
430
      acroForm = myRef = body.getPdfIndirectReference();
431
      iRef = new IndirectReferences(myRef);
432
      indirects.put(key, iRef);
433
    }
434 1 1. copyAcroForm : negated conditional → NO_COVERAGE
    if (!iRef.getCopied()) {
435 1 1. copyAcroForm : removed call to com/lowagie/text/pdf/PdfCopy$IndirectReferences::setCopied → NO_COVERAGE
      iRef.setCopied();
436
      PdfDictionary theForm = copyDictionary((PdfDictionary) PdfReader.getPdfObject(hisRef));
437
      addToBody(theForm, myRef);
438
    }
439
  }
440
441
  /*
442
   * the getCatalog method is part of PdfWriter.
443
   * we wrap this so that we can extend it
444
   */
445
  protected PdfDictionary getCatalog(PdfIndirectReference rootObj) {
446
    try {
447
      PdfDictionary theCat = pdf.getCatalog(rootObj);
448 1 1. getCatalog : negated conditional → NO_COVERAGE
      if (fieldArray == null) {
449 1 1. getCatalog : negated conditional → NO_COVERAGE
        if (acroForm != null) {
450 1 1. getCatalog : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
          theCat.put(PdfName.ACROFORM, acroForm);
451
        }
452
      } else {
453 1 1. getCatalog : removed call to com/lowagie/text/pdf/PdfCopy::addFieldResources → NO_COVERAGE
        addFieldResources(theCat);
454
      }
455 1 1. getCatalog : mutated return of Object value for com/lowagie/text/pdf/PdfCopy::getCatalog to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
      return theCat;
456
    } catch (IOException e) {
457
      throw new ExceptionConverter(e);
458
    }
459
  }
460
461
  private void addFieldResources(PdfDictionary catalog) throws IOException {
462 1 1. addFieldResources : negated conditional → NO_COVERAGE
    if (fieldArray == null) {
463
      return;
464
    }
465
    PdfDictionary acroForm = new PdfDictionary();
466 1 1. addFieldResources : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
    catalog.put(PdfName.ACROFORM, acroForm);
467 1 1. addFieldResources : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
    acroForm.put(PdfName.FIELDS, fieldArray);
468 1 1. addFieldResources : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
    acroForm.put(PdfName.DA, new PdfString("/Helv 0 Tf 0 g "));
469 1 1. addFieldResources : negated conditional → NO_COVERAGE
    if (fieldTemplates.isEmpty()) {
470
      return;
471
    }
472
    PdfDictionary dr = new PdfDictionary();
473 1 1. addFieldResources : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
    acroForm.put(PdfName.DR, dr);
474
    for (Object o : fieldTemplates.keySet()) {
475
      PdfTemplate template = (PdfTemplate) o;
476 1 1. addFieldResources : removed call to com/lowagie/text/pdf/PdfFormField::mergeResources → NO_COVERAGE
      PdfFormField.mergeResources(dr, (PdfDictionary) template.getResources());
477
    }
478
    // if (dr.get(PdfName.ENCODING) == null) dr.put(PdfName.ENCODING, PdfName.WIN_ANSI_ENCODING);
479
    PdfDictionary fonts = dr.getAsDict(PdfName.FONT);
480 1 1. addFieldResources : negated conditional → NO_COVERAGE
    if (fonts == null) {
481
      fonts = new PdfDictionary();
482 1 1. addFieldResources : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
      dr.put(PdfName.FONT, fonts);
483
    }
484 1 1. addFieldResources : negated conditional → NO_COVERAGE
    if (!fonts.contains(PdfName.HELV)) {
485
      PdfDictionary dic = new PdfDictionary(PdfName.FONT);
486 1 1. addFieldResources : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
      dic.put(PdfName.BASEFONT, PdfName.HELVETICA);
487 1 1. addFieldResources : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
      dic.put(PdfName.ENCODING, PdfName.WIN_ANSI_ENCODING);
488 1 1. addFieldResources : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
      dic.put(PdfName.NAME, PdfName.HELV);
489 1 1. addFieldResources : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
      dic.put(PdfName.SUBTYPE, PdfName.TYPE1);
490 1 1. addFieldResources : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
      fonts.put(PdfName.HELV, addToBody(dic).getIndirectReference());
491
    }
492 1 1. addFieldResources : negated conditional → NO_COVERAGE
    if (!fonts.contains(PdfName.ZADB)) {
493
      PdfDictionary dic = new PdfDictionary(PdfName.FONT);
494 1 1. addFieldResources : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
      dic.put(PdfName.BASEFONT, PdfName.ZAPFDINGBATS);
495 1 1. addFieldResources : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
      dic.put(PdfName.NAME, PdfName.ZADB);
496 1 1. addFieldResources : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
      dic.put(PdfName.SUBTYPE, PdfName.TYPE1);
497 1 1. addFieldResources : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
      fonts.put(PdfName.ZADB, addToBody(dic).getIndirectReference());
498
    }
499
  }
500
501
  /**
502
   * Signals that the <CODE>Document</CODE> was closed and that no other
503
   * <CODE>Elements</CODE> will be added.
504
   * <P>
505
   * The pages-tree is built and written to the outputstream. A Catalog is constructed, as well as an Info-object, the reference table is
506
   * composed and everything is written to the outputstream embedded in a Trailer.
507
   */
508
509
  public void close() {
510 1 1. close : negated conditional → NO_COVERAGE
    if (open) {
511
      PdfReaderInstance ri = currentPdfReaderInstance;
512 1 1. close : removed call to com/lowagie/text/pdf/PdfDocument::close → NO_COVERAGE
      pdf.close();
513 1 1. close : removed call to com/lowagie/text/pdf/PdfWriter::close → NO_COVERAGE
      super.close();
514 1 1. close : negated conditional → NO_COVERAGE
      if (ri != null) {
515
        try {
516 1 1. close : removed call to com/lowagie/text/pdf/PdfReader::close → NO_COVERAGE
          ri.getReader().close();
517 1 1. close : removed call to com/lowagie/text/pdf/RandomAccessFileOrArray::close → NO_COVERAGE
          ri.getReaderFile().close();
518
        } catch (IOException ioe) {
519
          // empty on purpose
520
        }
521
      }
522
    }
523
  }
524
525
  public PdfIndirectReference add(PdfOutline outline) {
526
    return null;
527
  }
528
529
  public void addAnnotation(PdfAnnotation annot) {
530
  }
531
532
  PdfIndirectReference add(PdfPage page, PdfContents contents) throws PdfException {
533
    return null;
534
  }
535
536
  public void freeReader(PdfReader reader) throws IOException {
537
    indirectMap.remove(reader);
538 1 1. freeReader : negated conditional → NO_COVERAGE
    if (currentPdfReaderInstance != null) {
539 1 1. freeReader : negated conditional → NO_COVERAGE
      if (currentPdfReaderInstance.getReader() == reader) {
540
        try {
541 1 1. freeReader : removed call to com/lowagie/text/pdf/PdfReader::close → NO_COVERAGE
          currentPdfReaderInstance.getReader().close();
542 1 1. freeReader : removed call to com/lowagie/text/pdf/RandomAccessFileOrArray::close → NO_COVERAGE
          currentPdfReaderInstance.getReaderFile().close();
543
        } catch (IOException ioe) {
544
          // empty on purpose
545
        }
546
        currentPdfReaderInstance = null;
547
      }
548
    }
549
  }
550
551
  /**
552
   * Create a page stamp. New content and annotations, including new fields, are allowed. The fields added cannot have parents in another
553
   * pages. This method modifies the PdfReader instance.<p> The general usage to stamp something in a page is:
554
   * <p>
555
   * <pre>
556
   * PdfImportedPage page = copy.getImportedPage(reader, 1);
557
   * PdfCopy.PageStamp ps = copy.createPageStamp(page);
558
   * ps.addAnnotation(PdfAnnotation.createText(copy, new Rectangle(50, 180, 70, 200), "Hello", "No Thanks", true, "Comment"));
559
   * PdfContentByte under = ps.getUnderContent();
560
   * under.addImage(img);
561
   * PdfContentByte over = ps.getOverContent();
562
   * over.beginText();
563
   * over.setFontAndSize(bf, 18);
564
   * over.setTextMatrix(30, 30);
565
   * over.showText("total page " + totalPage);
566
   * over.endText();
567
   * ps.alterContents();
568
   * copy.addPage(page);
569
   * </pre>
570
   *
571
   * @param iPage an imported page
572
   * @return the <CODE>PageStamp</CODE>
573
   */
574
  public PageStamp createPageStamp(PdfImportedPage iPage) {
575
    int pageNum = iPage.getPageNumber();
576
    PdfReader reader = iPage.getPdfReaderInstance().getReader();
577
    PdfDictionary pageN = reader.getPageN(pageNum);
578 1 1. createPageStamp : mutated return of Object value for com/lowagie/text/pdf/PdfCopy::createPageStamp to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
    return new PageStamp(reader, pageN, this);
579
  }
580
581
  public static class PageStamp {
582
583
    PdfDictionary pageN;
584
    PdfCopy.StampContent under;
585
    PdfCopy.StampContent over;
586
    PageResources pageResources;
587
    PdfReader reader;
588
    PdfCopy cstp;
589
590
    PageStamp(PdfReader reader, PdfDictionary pageN, PdfCopy cstp) {
591
      this.pageN = pageN;
592
      this.reader = reader;
593
      this.cstp = cstp;
594
    }
595
596
    public PdfContentByte getUnderContent() {
597 1 1. getUnderContent : negated conditional → NO_COVERAGE
      if (under == null) {
598 1 1. getUnderContent : negated conditional → NO_COVERAGE
        if (pageResources == null) {
599
          pageResources = new PageResources();
600
          PdfDictionary resources = pageN.getAsDict(PdfName.RESOURCES);
601 1 1. getUnderContent : removed call to com/lowagie/text/pdf/PageResources::setOriginalResources → NO_COVERAGE
          pageResources.setOriginalResources(resources, cstp.namePtr);
602
        }
603
        under = new PdfCopy.StampContent(cstp, pageResources);
604
      }
605 1 1. getUnderContent : mutated return of Object value for com/lowagie/text/pdf/PdfCopy$PageStamp::getUnderContent to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
      return under;
606
    }
607
608
    public PdfContentByte getOverContent() {
609 1 1. getOverContent : negated conditional → NO_COVERAGE
      if (over == null) {
610 1 1. getOverContent : negated conditional → NO_COVERAGE
        if (pageResources == null) {
611
          pageResources = new PageResources();
612
          PdfDictionary resources = pageN.getAsDict(PdfName.RESOURCES);
613 1 1. getOverContent : removed call to com/lowagie/text/pdf/PageResources::setOriginalResources → NO_COVERAGE
          pageResources.setOriginalResources(resources, cstp.namePtr);
614
        }
615
        over = new PdfCopy.StampContent(cstp, pageResources);
616
      }
617 1 1. getOverContent : mutated return of Object value for com/lowagie/text/pdf/PdfCopy$PageStamp::getOverContent to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
      return over;
618
    }
619
620
    public void alterContents() throws IOException {
621 2 1. alterContents : negated conditional → NO_COVERAGE
2. alterContents : negated conditional → NO_COVERAGE
      if (over == null && under == null) {
622
        return;
623
      }
624
      PdfArray ar = null;
625
      PdfObject content = PdfReader.getPdfObject(pageN.get(PdfName.CONTENTS), pageN);
626 1 1. alterContents : negated conditional → NO_COVERAGE
      if (content == null) {
627
        ar = new PdfArray();
628 1 1. alterContents : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
        pageN.put(PdfName.CONTENTS, ar);
629 1 1. alterContents : negated conditional → NO_COVERAGE
      } else if (content.isArray()) {
630
        ar = (PdfArray) content;
631 1 1. alterContents : negated conditional → NO_COVERAGE
      } else if (content.isStream()) {
632
        ar = new PdfArray();
633
        ar.add(pageN.get(PdfName.CONTENTS));
634 1 1. alterContents : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
        pageN.put(PdfName.CONTENTS, ar);
635
      } else {
636
        ar = new PdfArray();
637 1 1. alterContents : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
        pageN.put(PdfName.CONTENTS, ar);
638
      }
639
      ByteBuffer out = new ByteBuffer();
640 1 1. alterContents : negated conditional → NO_COVERAGE
      if (under != null) {
641
        out.append(PdfContents.SAVESTATE);
642 1 1. alterContents : removed call to com/lowagie/text/pdf/PdfCopy$PageStamp::applyRotation → NO_COVERAGE
        applyRotation(pageN, out);
643
        out.append(under.getInternalBuffer());
644
        out.append(PdfContents.RESTORESTATE);
645
      }
646 1 1. alterContents : negated conditional → NO_COVERAGE
      if (over != null) {
647
        out.append(PdfContents.SAVESTATE);
648
      }
649
      PdfStream stream = new PdfStream(out.toByteArray());
650 1 1. alterContents : removed call to com/lowagie/text/pdf/PdfStream::flateCompress → NO_COVERAGE
      stream.flateCompress(cstp.getCompressionLevel());
651
      PdfIndirectReference ref1 = cstp.addToBody(stream).getIndirectReference();
652 1 1. alterContents : removed call to com/lowagie/text/pdf/PdfArray::addFirst → NO_COVERAGE
      ar.addFirst(ref1);
653 1 1. alterContents : removed call to com/lowagie/text/pdf/ByteBuffer::reset → NO_COVERAGE
      out.reset();
654 1 1. alterContents : negated conditional → NO_COVERAGE
      if (over != null) {
655
        out.append(' ');
656
        out.append(PdfContents.RESTORESTATE);
657
        out.append(PdfContents.SAVESTATE);
658 1 1. alterContents : removed call to com/lowagie/text/pdf/PdfCopy$PageStamp::applyRotation → NO_COVERAGE
        applyRotation(pageN, out);
659
        out.append(over.getInternalBuffer());
660
        out.append(PdfContents.RESTORESTATE);
661
        stream = new PdfStream(out.toByteArray());
662 1 1. alterContents : removed call to com/lowagie/text/pdf/PdfStream::flateCompress → NO_COVERAGE
        stream.flateCompress(cstp.getCompressionLevel());
663
        ar.add(cstp.addToBody(stream).getIndirectReference());
664
      }
665 1 1. alterContents : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
      pageN.put(PdfName.RESOURCES, pageResources.getResources());
666
    }
667
668
    void applyRotation(PdfDictionary pageN, ByteBuffer out) {
669 1 1. applyRotation : negated conditional → NO_COVERAGE
      if (!cstp.rotateContents) {
670
        return;
671
      }
672
      Rectangle page = reader.getPageSizeWithRotation(pageN);
673
      int rotation = page.getRotation();
674
      switch (rotation) {
675
        case 90:
676
          out.append(PdfContents.ROTATE90);
677
          out.append(page.getTop());
678
          out.append(' ').append('0').append(PdfContents.ROTATEFINAL);
679
          break;
680
        case 180:
681
          out.append(PdfContents.ROTATE180);
682
          out.append(page.getRight());
683
          out.append(' ');
684
          out.append(page.getTop());
685
          out.append(PdfContents.ROTATEFINAL);
686
          break;
687
        case 270:
688
          out.append(PdfContents.ROTATE270);
689
          out.append('0').append(' ');
690
          out.append(page.getRight());
691
          out.append(PdfContents.ROTATEFINAL);
692
          break;
693
      }
694
    }
695
696
    private void addDocumentField(PdfIndirectReference ref) {
697 1 1. addDocumentField : negated conditional → NO_COVERAGE
      if (cstp.fieldArray == null) {
698
        cstp.fieldArray = new PdfArray();
699
      }
700
      cstp.fieldArray.add(ref);
701
    }
702
703
    private void expandFields(PdfFormField field, ArrayList allAnnots) {
704
      allAnnots.add(field);
705
      List<PdfFormField> kids = field.getKids();
706 1 1. expandFields : negated conditional → NO_COVERAGE
      if (kids != null) {
707
          for (PdfFormField kid : kids) {
708 1 1. expandFields : removed call to com/lowagie/text/pdf/PdfCopy$PageStamp::expandFields → NO_COVERAGE
              expandFields(kid, allAnnots);
709
          }
710
      }
711
    }
712
713
    public void addAnnotation(PdfAnnotation annot) {
714
      try {
715
        ArrayList<PdfAnnotation> allAnnots = new ArrayList<>();
716 1 1. addAnnotation : negated conditional → NO_COVERAGE
        if (annot.isForm()) {
717
          PdfFormField field = (PdfFormField) annot;
718 1 1. addAnnotation : negated conditional → NO_COVERAGE
          if (field.getParent() != null) {
719
            return;
720
          }
721 1 1. addAnnotation : removed call to com/lowagie/text/pdf/PdfCopy$PageStamp::expandFields → NO_COVERAGE
          expandFields(field, allAnnots);
722 1 1. addAnnotation : negated conditional → NO_COVERAGE
          if (cstp.fieldTemplates == null) {
723
            cstp.fieldTemplates = new HashMap<>();
724
          }
725
        } else {
726
          allAnnots.add(annot);
727
        }
728
        for (PdfAnnotation allAnnot : allAnnots) {
729
          annot = allAnnot;
730 1 1. addAnnotation : negated conditional → NO_COVERAGE
          if (annot.isForm()) {
731 1 1. addAnnotation : negated conditional → NO_COVERAGE
            if (!annot.isUsed()) {
732
              Map<PdfTemplate, Object> templates = annot.getTemplates();
733 1 1. addAnnotation : negated conditional → NO_COVERAGE
              if (templates != null) {
734 1 1. addAnnotation : removed call to java/util/HashMap::putAll → NO_COVERAGE
                cstp.fieldTemplates.putAll(templates);
735
              }
736
            }
737
            PdfFormField field = (PdfFormField) annot;
738 1 1. addAnnotation : negated conditional → NO_COVERAGE
            if (field.getParent() == null) {
739 1 1. addAnnotation : removed call to com/lowagie/text/pdf/PdfCopy$PageStamp::addDocumentField → NO_COVERAGE
              addDocumentField(field.getIndirectReference());
740
            }
741
          }
742 1 1. addAnnotation : negated conditional → NO_COVERAGE
          if (annot.isAnnotation()) {
743
            PdfObject pdfobj = PdfReader.getPdfObject(pageN.get(PdfName.ANNOTS), pageN);
744
            PdfArray annots;
745 2 1. addAnnotation : negated conditional → NO_COVERAGE
2. addAnnotation : negated conditional → NO_COVERAGE
            if (pdfobj == null || !pdfobj.isArray()) {
746
              annots = new PdfArray();
747 1 1. addAnnotation : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
              pageN.put(PdfName.ANNOTS, annots);
748
            } else {
749
              annots = (PdfArray) pdfobj;
750
            }
751
            annots.add(annot.getIndirectReference());
752 1 1. addAnnotation : negated conditional → NO_COVERAGE
            if (!annot.isUsed()) {
753
              PdfRectangle rect = (PdfRectangle) annot.get(PdfName.RECT);
754 5 1. addAnnotation : negated conditional → NO_COVERAGE
2. addAnnotation : negated conditional → NO_COVERAGE
3. addAnnotation : negated conditional → NO_COVERAGE
4. addAnnotation : negated conditional → NO_COVERAGE
5. addAnnotation : negated conditional → NO_COVERAGE
              if (rect != null && (rect.left() != 0 || rect.right() != 0 || rect.top() != 0 || rect.bottom() != 0)) {
755
                int rotation = reader.getPageRotation(pageN);
756
                Rectangle pageSize = reader.getPageSizeWithRotation(pageN);
757
                switch (rotation) {
758
                  case 90:
759 1 1. addAnnotation : removed call to com/lowagie/text/pdf/PdfAnnotation::put → NO_COVERAGE
                    annot.put(PdfName.RECT, new PdfRectangle(
760 1 1. addAnnotation : Replaced float subtraction with addition → NO_COVERAGE
                        pageSize.getTop() - rect.bottom(),
761
                        rect.left(),
762 1 1. addAnnotation : Replaced float subtraction with addition → NO_COVERAGE
                        pageSize.getTop() - rect.top(),
763
                        rect.right()));
764
                    break;
765
                  case 180:
766 1 1. addAnnotation : removed call to com/lowagie/text/pdf/PdfAnnotation::put → NO_COVERAGE
                    annot.put(PdfName.RECT, new PdfRectangle(
767 1 1. addAnnotation : Replaced float subtraction with addition → NO_COVERAGE
                        pageSize.getRight() - rect.left(),
768 1 1. addAnnotation : Replaced float subtraction with addition → NO_COVERAGE
                        pageSize.getTop() - rect.bottom(),
769 1 1. addAnnotation : Replaced float subtraction with addition → NO_COVERAGE
                        pageSize.getRight() - rect.right(),
770 1 1. addAnnotation : Replaced float subtraction with addition → NO_COVERAGE
                        pageSize.getTop() - rect.top()));
771
                    break;
772
                  case 270:
773 1 1. addAnnotation : removed call to com/lowagie/text/pdf/PdfAnnotation::put → NO_COVERAGE
                    annot.put(PdfName.RECT, new PdfRectangle(
774
                        rect.bottom(),
775 1 1. addAnnotation : Replaced float subtraction with addition → NO_COVERAGE
                        pageSize.getRight() - rect.left(),
776
                        rect.top(),
777 1 1. addAnnotation : Replaced float subtraction with addition → NO_COVERAGE
                        pageSize.getRight() - rect.right()));
778
                    break;
779
                }
780
              }
781
            }
782
          }
783 1 1. addAnnotation : negated conditional → NO_COVERAGE
          if (!annot.isUsed()) {
784 1 1. addAnnotation : removed call to com/lowagie/text/pdf/PdfAnnotation::setUsed → NO_COVERAGE
            annot.setUsed();
785
            cstp.addToBody(annot, annot.getIndirectReference());
786
          }
787
        }
788
      } catch (IOException e) {
789
        throw new ExceptionConverter(e);
790
      }
791
    }
792
  }
793
794
  public static class StampContent extends PdfContentByte {
795
796
    PageResources pageResources;
797
798
    /**
799
     * Creates a new instance of StampContent
800
     */
801
    StampContent(PdfWriter writer, PageResources pageResources) {
802
      super(writer);
803
      this.pageResources = pageResources;
804
    }
805
806
    /**
807
     * Gets a duplicate of this <CODE>PdfContentByte</CODE>. All the members are copied by reference but the buffer stays different.
808
     *
809
     * @return a copy of this <CODE>PdfContentByte</CODE>
810
     */
811
    public PdfContentByte getDuplicate() {
812 1 1. getDuplicate : mutated return of Object value for com/lowagie/text/pdf/PdfCopy$StampContent::getDuplicate to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
      return new PdfCopy.StampContent(writer, pageResources);
813
    }
814
815
    PageResources getPageResources() {
816
      return pageResources;
817
    }
818
  }
819
}

Mutations

139

1.1
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

140

1.1
Location : equals
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

143

1.1
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

3.3
Location : equals
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

158

1.1
Location :
Killed by : none
removed call to com/lowagie/text/Document::addDocListener → NO_COVERAGE

159

1.1
Location :
Killed by : none
removed call to com/lowagie/text/pdf/PdfDocument::addWriter → NO_COVERAGE

189

1.1
Location : getImportedPage
Killed by : none
negated conditional → NO_COVERAGE

190

1.1
Location : getImportedPage
Killed by : none
negated conditional → NO_COVERAGE

192

1.1
Location : getImportedPage
Killed by : none
removed call to com/lowagie/text/pdf/PdfReader::close → NO_COVERAGE

193

1.1
Location : getImportedPage
Killed by : none
removed call to com/lowagie/text/pdf/RandomAccessFileOrArray::close → NO_COVERAGE

202

1.1
Location : getImportedPage
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopy::getImportedPage to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

216

1.1
Location : copyIndirect
Killed by : none
negated conditional → NO_COVERAGE

218

1.1
Location : copyIndirect
Killed by : none
negated conditional → NO_COVERAGE

219

1.1
Location : copyIndirect
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyIndirect to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

227

1.1
Location : copyIndirect
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : copyIndirect
Killed by : none
negated conditional → NO_COVERAGE

229

1.1
Location : copyIndirect
Killed by : none
negated conditional → NO_COVERAGE

230

1.1
Location : copyIndirect
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyIndirect to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

233

1.1
Location : copyIndirect
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopy$IndirectReferences::setCopied → NO_COVERAGE

236

1.1
Location : copyIndirect
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyIndirect to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

250

1.1
Location : copyDictionary
Killed by : none
negated conditional → NO_COVERAGE

251

1.1
Location : copyDictionary
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : copyDictionary
Killed by : none
negated conditional → NO_COVERAGE

252

1.1
Location : copyDictionary
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

255

1.1
Location : copyDictionary
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

258

1.1
Location : copyDictionary
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyDictionary to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

269

1.1
Location : copyStream
Killed by : none
removed call to com/lowagie/text/pdf/PRStream::put → NO_COVERAGE

272

1.1
Location : copyStream
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyStream to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

285

1.1
Location : copyArray
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyArray to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

292

1.1
Location : copyObject
Killed by : none
negated conditional → NO_COVERAGE

293

1.1
Location : copyObject
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

298

1.1
Location : copyObject
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

300

1.1
Location : copyObject
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

302

1.1
Location : copyObject
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

309

1.1
Location : copyObject
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

311

1.1
Location : copyObject
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

314

1.1
Location : copyObject
Killed by : none
changed conditional boundary → NO_COVERAGE

2.2
Location : copyObject
Killed by : none
negated conditional → NO_COVERAGE

316

1.1
Location : copyObject
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : copyObject
Killed by : none
negated conditional → NO_COVERAGE

317

1.1
Location : copyObject
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

319

1.1
Location : copyObject
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

321

1.1
Location : copyObject
Killed by : none
removed call to java/io/PrintStream::println → NO_COVERAGE

322

1.1
Location : copyObject
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopy::copyObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

333

1.1
Location : setFromIPage
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopy::setFromReader → NO_COVERAGE

334

1.1
Location : setFromIPage
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

343

1.1
Location : setFromReader
Killed by : none
negated conditional → NO_COVERAGE

349

1.1
Location : setFromReader
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : setFromReader
Killed by : none
negated conditional → NO_COVERAGE

353

1.1
Location : setFromReader
Killed by : none
negated conditional → NO_COVERAGE

371

1.1
Location : addPage
Killed by : none
removed call to com/lowagie/text/pdf/PdfReader::releasePage → NO_COVERAGE

375

1.1
Location : addPage
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : addPage
Killed by : none
negated conditional → NO_COVERAGE

377

1.1
Location : addPage
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopy$IndirectReferences::setCopied → NO_COVERAGE

380

1.1
Location : addPage
Killed by : none
negated conditional → NO_COVERAGE

384

1.1
Location : addPage
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopy$IndirectReferences::setCopied → NO_COVERAGE

386

1.1
Location : addPage
Killed by : none
removed call to com/lowagie/text/pdf/PdfPages::addPage → NO_COVERAGE

387

1.1
Location : addPage
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

401

1.1
Location : addPage
Killed by : none
removed call to com/lowagie/text/pdf/PdfPage::put → NO_COVERAGE

402

1.1
Location : addPage
Killed by : none
removed call to com/lowagie/text/pdf/PdfPages::addPage → NO_COVERAGE

403

1.1
Location : addPage
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

413

1.1
Location : copyAcroForm
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopy::setFromReader → NO_COVERAGE

418

1.1
Location : copyAcroForm
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : copyAcroForm
Killed by : none
negated conditional → NO_COVERAGE

421

1.1
Location : copyAcroForm
Killed by : none
negated conditional → NO_COVERAGE

427

1.1
Location : copyAcroForm
Killed by : none
negated conditional → NO_COVERAGE

434

1.1
Location : copyAcroForm
Killed by : none
negated conditional → NO_COVERAGE

435

1.1
Location : copyAcroForm
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopy$IndirectReferences::setCopied → NO_COVERAGE

448

1.1
Location : getCatalog
Killed by : none
negated conditional → NO_COVERAGE

449

1.1
Location : getCatalog
Killed by : none
negated conditional → NO_COVERAGE

450

1.1
Location : getCatalog
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

453

1.1
Location : getCatalog
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopy::addFieldResources → NO_COVERAGE

455

1.1
Location : getCatalog
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopy::getCatalog to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

462

1.1
Location : addFieldResources
Killed by : none
negated conditional → NO_COVERAGE

466

1.1
Location : addFieldResources
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

467

1.1
Location : addFieldResources
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

468

1.1
Location : addFieldResources
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

469

1.1
Location : addFieldResources
Killed by : none
negated conditional → NO_COVERAGE

473

1.1
Location : addFieldResources
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

476

1.1
Location : addFieldResources
Killed by : none
removed call to com/lowagie/text/pdf/PdfFormField::mergeResources → NO_COVERAGE

480

1.1
Location : addFieldResources
Killed by : none
negated conditional → NO_COVERAGE

482

1.1
Location : addFieldResources
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

484

1.1
Location : addFieldResources
Killed by : none
negated conditional → NO_COVERAGE

486

1.1
Location : addFieldResources
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

487

1.1
Location : addFieldResources
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

488

1.1
Location : addFieldResources
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

489

1.1
Location : addFieldResources
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

490

1.1
Location : addFieldResources
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

492

1.1
Location : addFieldResources
Killed by : none
negated conditional → NO_COVERAGE

494

1.1
Location : addFieldResources
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

495

1.1
Location : addFieldResources
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

496

1.1
Location : addFieldResources
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

497

1.1
Location : addFieldResources
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

510

1.1
Location : close
Killed by : none
negated conditional → NO_COVERAGE

512

1.1
Location : close
Killed by : none
removed call to com/lowagie/text/pdf/PdfDocument::close → NO_COVERAGE

513

1.1
Location : close
Killed by : none
removed call to com/lowagie/text/pdf/PdfWriter::close → NO_COVERAGE

514

1.1
Location : close
Killed by : none
negated conditional → NO_COVERAGE

516

1.1
Location : close
Killed by : none
removed call to com/lowagie/text/pdf/PdfReader::close → NO_COVERAGE

517

1.1
Location : close
Killed by : none
removed call to com/lowagie/text/pdf/RandomAccessFileOrArray::close → NO_COVERAGE

538

1.1
Location : freeReader
Killed by : none
negated conditional → NO_COVERAGE

539

1.1
Location : freeReader
Killed by : none
negated conditional → NO_COVERAGE

541

1.1
Location : freeReader
Killed by : none
removed call to com/lowagie/text/pdf/PdfReader::close → NO_COVERAGE

542

1.1
Location : freeReader
Killed by : none
removed call to com/lowagie/text/pdf/RandomAccessFileOrArray::close → NO_COVERAGE

578

1.1
Location : createPageStamp
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopy::createPageStamp to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

597

1.1
Location : getUnderContent
Killed by : none
negated conditional → NO_COVERAGE

598

1.1
Location : getUnderContent
Killed by : none
negated conditional → NO_COVERAGE

601

1.1
Location : getUnderContent
Killed by : none
removed call to com/lowagie/text/pdf/PageResources::setOriginalResources → NO_COVERAGE

605

1.1
Location : getUnderContent
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopy$PageStamp::getUnderContent to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

609

1.1
Location : getOverContent
Killed by : none
negated conditional → NO_COVERAGE

610

1.1
Location : getOverContent
Killed by : none
negated conditional → NO_COVERAGE

613

1.1
Location : getOverContent
Killed by : none
removed call to com/lowagie/text/pdf/PageResources::setOriginalResources → NO_COVERAGE

617

1.1
Location : getOverContent
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopy$PageStamp::getOverContent to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

621

1.1
Location : alterContents
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : alterContents
Killed by : none
negated conditional → NO_COVERAGE

626

1.1
Location : alterContents
Killed by : none
negated conditional → NO_COVERAGE

628

1.1
Location : alterContents
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

629

1.1
Location : alterContents
Killed by : none
negated conditional → NO_COVERAGE

631

1.1
Location : alterContents
Killed by : none
negated conditional → NO_COVERAGE

634

1.1
Location : alterContents
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

637

1.1
Location : alterContents
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

640

1.1
Location : alterContents
Killed by : none
negated conditional → NO_COVERAGE

642

1.1
Location : alterContents
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopy$PageStamp::applyRotation → NO_COVERAGE

646

1.1
Location : alterContents
Killed by : none
negated conditional → NO_COVERAGE

650

1.1
Location : alterContents
Killed by : none
removed call to com/lowagie/text/pdf/PdfStream::flateCompress → NO_COVERAGE

652

1.1
Location : alterContents
Killed by : none
removed call to com/lowagie/text/pdf/PdfArray::addFirst → NO_COVERAGE

653

1.1
Location : alterContents
Killed by : none
removed call to com/lowagie/text/pdf/ByteBuffer::reset → NO_COVERAGE

654

1.1
Location : alterContents
Killed by : none
negated conditional → NO_COVERAGE

658

1.1
Location : alterContents
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopy$PageStamp::applyRotation → NO_COVERAGE

662

1.1
Location : alterContents
Killed by : none
removed call to com/lowagie/text/pdf/PdfStream::flateCompress → NO_COVERAGE

665

1.1
Location : alterContents
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

669

1.1
Location : applyRotation
Killed by : none
negated conditional → NO_COVERAGE

697

1.1
Location : addDocumentField
Killed by : none
negated conditional → NO_COVERAGE

706

1.1
Location : expandFields
Killed by : none
negated conditional → NO_COVERAGE

708

1.1
Location : expandFields
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopy$PageStamp::expandFields → NO_COVERAGE

716

1.1
Location : addAnnotation
Killed by : none
negated conditional → NO_COVERAGE

718

1.1
Location : addAnnotation
Killed by : none
negated conditional → NO_COVERAGE

721

1.1
Location : addAnnotation
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopy$PageStamp::expandFields → NO_COVERAGE

722

1.1
Location : addAnnotation
Killed by : none
negated conditional → NO_COVERAGE

730

1.1
Location : addAnnotation
Killed by : none
negated conditional → NO_COVERAGE

731

1.1
Location : addAnnotation
Killed by : none
negated conditional → NO_COVERAGE

733

1.1
Location : addAnnotation
Killed by : none
negated conditional → NO_COVERAGE

734

1.1
Location : addAnnotation
Killed by : none
removed call to java/util/HashMap::putAll → NO_COVERAGE

738

1.1
Location : addAnnotation
Killed by : none
negated conditional → NO_COVERAGE

739

1.1
Location : addAnnotation
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopy$PageStamp::addDocumentField → NO_COVERAGE

742

1.1
Location : addAnnotation
Killed by : none
negated conditional → NO_COVERAGE

745

1.1
Location : addAnnotation
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : addAnnotation
Killed by : none
negated conditional → NO_COVERAGE

747

1.1
Location : addAnnotation
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

752

1.1
Location : addAnnotation
Killed by : none
negated conditional → NO_COVERAGE

754

1.1
Location : addAnnotation
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : addAnnotation
Killed by : none
negated conditional → NO_COVERAGE

3.3
Location : addAnnotation
Killed by : none
negated conditional → NO_COVERAGE

4.4
Location : addAnnotation
Killed by : none
negated conditional → NO_COVERAGE

5.5
Location : addAnnotation
Killed by : none
negated conditional → NO_COVERAGE

759

1.1
Location : addAnnotation
Killed by : none
removed call to com/lowagie/text/pdf/PdfAnnotation::put → NO_COVERAGE

760

1.1
Location : addAnnotation
Killed by : none
Replaced float subtraction with addition → NO_COVERAGE

762

1.1
Location : addAnnotation
Killed by : none
Replaced float subtraction with addition → NO_COVERAGE

766

1.1
Location : addAnnotation
Killed by : none
removed call to com/lowagie/text/pdf/PdfAnnotation::put → NO_COVERAGE

767

1.1
Location : addAnnotation
Killed by : none
Replaced float subtraction with addition → NO_COVERAGE

768

1.1
Location : addAnnotation
Killed by : none
Replaced float subtraction with addition → NO_COVERAGE

769

1.1
Location : addAnnotation
Killed by : none
Replaced float subtraction with addition → NO_COVERAGE

770

1.1
Location : addAnnotation
Killed by : none
Replaced float subtraction with addition → NO_COVERAGE

773

1.1
Location : addAnnotation
Killed by : none
removed call to com/lowagie/text/pdf/PdfAnnotation::put → NO_COVERAGE

775

1.1
Location : addAnnotation
Killed by : none
Replaced float subtraction with addition → NO_COVERAGE

777

1.1
Location : addAnnotation
Killed by : none
Replaced float subtraction with addition → NO_COVERAGE

783

1.1
Location : addAnnotation
Killed by : none
negated conditional → NO_COVERAGE

784

1.1
Location : addAnnotation
Killed by : none
removed call to com/lowagie/text/pdf/PdfAnnotation::setUsed → NO_COVERAGE

812

1.1
Location : getDuplicate
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopy$StampContent::getDuplicate to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.4.2