File tree Expand file tree Collapse file tree 2 files changed +5
-9
lines changed
main/java/com/lowagie/text/pdf
test/java/com/lowagie/text/pdf Expand file tree Collapse file tree 2 files changed +5
-9
lines changed Original file line number Diff line number Diff line change 52
52
import java .awt .Color ;
53
53
import java .awt .color .ICC_Profile ;
54
54
import java .io .ByteArrayOutputStream ;
55
- import java .io .Closeable ;
56
55
import java .io .IOException ;
57
56
import java .io .OutputStream ;
58
57
import java .security .cert .Certificate ;
104
103
*/
105
104
106
105
public class PdfWriter extends DocWriter implements
107
- AutoCloseable ,
108
- Closeable ,
109
106
PdfViewerPreferences ,
110
107
PdfEncryptionSettings ,
111
108
PdfVersion ,
@@ -1158,8 +1155,7 @@ public void open() {
1158
1155
@ Override
1159
1156
public void close () {
1160
1157
if (open ) {
1161
- if (this .document .isOpen ()) this .document .close ();
1162
-
1158
+
1163
1159
if ((currentPageNumber - 1 ) != pageReferences .size ())
1164
1160
// 2019-04-26: If you get this error, it could be that you are using OpenPDF or
1165
1161
// another library such as flying-saucer's ITextRenderer in a non-threadsafe way.
Original file line number Diff line number Diff line change @@ -34,9 +34,9 @@ void testSimplePdf() throws Exception {
34
34
void testTryWithResources_with_os_before_doc () throws Exception {
35
35
try (PdfReader reader = new PdfReader ("./src/test/resources/HelloWorldMeta.pdf" );
36
36
FileOutputStream os = new FileOutputStream (File .createTempFile ("temp-file-name" , ".pdf" ));
37
- Document document = new Document ();
38
- PdfWriter writer = PdfWriter .getInstance (document , os )
37
+ Document document = new Document ()
39
38
) {
39
+ PdfWriter writer = PdfWriter .getInstance (document , os );
40
40
document .open ();
41
41
final PdfContentByte cb = writer .getDirectContent ();
42
42
@@ -49,9 +49,9 @@ void testTryWithResources_with_os_before_doc() throws Exception {
49
49
@ Test
50
50
void testTryWithResources_with_unknown_os () throws Exception {
51
51
try (PdfReader reader = new PdfReader ("./src/test/resources/HelloWorldMeta.pdf" );
52
- Document document = new Document ();
53
- PdfWriter writer = PdfWriter .getInstance (document , new FileOutputStream (File .createTempFile ("temp-file-name" , ".pdf" )))
52
+ Document document = new Document ()
54
53
) {
54
+ PdfWriter writer = PdfWriter .getInstance (document , new FileOutputStream (File .createTempFile ("temp-file-name" , ".pdf" )));
55
55
document .open ();
56
56
final PdfContentByte cb = writer .getDirectContent ();
57
57
You can’t perform that action at this time.
0 commit comments