Lines 98-103
public class PDFDocument {
Link Here
|
98 |
/** the objects themselves */ |
98 |
/** the objects themselves */ |
99 |
private List objects = new LinkedList(); |
99 |
private List objects = new LinkedList(); |
100 |
|
100 |
|
|
|
101 |
/** the objects themselves (to be cleared after writing) */ |
102 |
private List clearobjects = new LinkedList(); |
103 |
|
101 |
/** Indicates what PDF version is active */ |
104 |
/** Indicates what PDF version is active */ |
102 |
private int pdfVersion = PDF_VERSION_1_4; |
105 |
private int pdfVersion = PDF_VERSION_1_4; |
103 |
|
106 |
|
Lines 378-383
public class PDFDocument {
Link Here
|
378 |
} |
381 |
} |
379 |
|
382 |
|
380 |
/** |
383 |
/** |
|
|
384 |
* Registers a {@link PDFObject} in this PDF document. |
385 |
* The object is assigned a new object number. |
386 |
* |
387 |
* @param obj {@link PDFObject} to add |
388 |
* @param clear object after writing |
389 |
* @return the added {@link PDFObject} added (with its object number set) |
390 |
*/ |
391 |
public PDFObject registerObject(PDFObject obj, boolean clear) { |
392 |
assignObjectNumber(obj); |
393 |
addObject(obj, clear); |
394 |
return obj; |
395 |
} |
396 |
|
397 |
/** |
381 |
* Assigns the {@link PDFObject} an object number, |
398 |
* Assigns the {@link PDFObject} an object number, |
382 |
* and sets the parent of the {@link PDFObject} to this document. |
399 |
* and sets the parent of the {@link PDFObject} to this document. |
383 |
* |
400 |
* |
Lines 413-418
public class PDFDocument {
Link Here
|
413 |
* @param obj {@link PDFObject} to add |
430 |
* @param obj {@link PDFObject} to add |
414 |
*/ |
431 |
*/ |
415 |
public void addObject(PDFObject obj) { |
432 |
public void addObject(PDFObject obj) { |
|
|
433 |
addObject(obj, false); |
434 |
} |
435 |
|
436 |
/** |
437 |
* Adds a {@link PDFObject} to this document. |
438 |
* The object <em>MUST</em> have an object number assigned. |
439 |
* |
440 |
* @param obj {@link PDFObject} to add |
441 |
* @param clear Clear object after writing (if possible) |
442 |
*/ |
443 |
public void addObject(PDFObject obj, boolean clear) { |
416 |
if (obj == null) { |
444 |
if (obj == null) { |
417 |
throw new NullPointerException("obj must not be null"); |
445 |
throw new NullPointerException("obj must not be null"); |
418 |
} |
446 |
} |
Lines 423-429
public class PDFDocument {
Link Here
|
423 |
} |
451 |
} |
424 |
|
452 |
|
425 |
//Add object to list |
453 |
//Add object to list |
426 |
this.objects.add(obj); |
454 |
if (clear) |
|
|
455 |
this.clearobjects.add(obj); |
456 |
else |
457 |
this.objects.add(obj); |
427 |
|
458 |
|
428 |
//Add object to special lists where necessary |
459 |
//Add object to special lists where necessary |
429 |
if (obj instanceof PDFFunction) { |
460 |
if (obj instanceof PDFFunction) { |
Lines 927-932
public class PDFDocument {
Link Here
|
927 |
this.position += object.output(stream); |
958 |
this.position += object.output(stream); |
928 |
} |
959 |
} |
929 |
|
960 |
|
|
|
961 |
while (this.clearobjects.size() > 0) { |
962 |
/* Retrieve first */ |
963 |
PDFObject object = (PDFObject)this.clearobjects.remove(0); |
964 |
/* |
965 |
* add the position of this object to the list of object |
966 |
* locations |
967 |
*/ |
968 |
setLocation(object.getObjectNumber() - 1, this.position); |
969 |
|
970 |
/* |
971 |
* output the object and increment the character position |
972 |
* by the object's length |
973 |
*/ |
974 |
this.position += object.output(stream); |
975 |
if (object instanceof PDFClearable) |
976 |
((PDFClearable)object).clear(); |
977 |
} |
978 |
|
930 |
//Clear all objects written to the file |
979 |
//Clear all objects written to the file |
931 |
//this.objects.clear(); |
980 |
//this.objects.clear(); |
932 |
} |
981 |
} |
933 |
- |
|
|