From 2605869f17e18afdf144724177b0fa9581fba17f Mon Sep 17 00:00:00 2001 From: asturio Date: Mon, 26 Feb 2024 11:43:45 +0100 Subject: [PATCH] #156: Throw Exception if PdfWriter.close() is called directly (#1081) * #156: Throw Exception if PdfWriter.close() is called directly - Throw an IllegalStateException if PdfWriter.close() is called before Document.close() is called. - Delete old *.lng files in src/main/java - Update *.lng files in src/main/resources - BoyScout rule in PdfWriter * #156: Throw Exception if PdfWriter.close() is called directly - Codacy Issues (cherry picked from commit 6c675f73cd4003f5eb5e0a18ce41b25c7b30e45f) --- .../com/lowagie/text/error_messages/en.lng | 407 --- .../com/lowagie/text/error_messages/nl.lng | 407 --- .../com/lowagie/text/error_messages/pt.lng | 8 - .../java/com/lowagie/text/pdf/PdfWriter.java | 2177 ++++++++++------- .../com/lowagie/text/error_messages/en.lng | 6 +- .../com/lowagie/text/error_messages/nl.lng | 7 +- .../com/lowagie/text/error_messages/pt.lng | 1 + .../com/lowagie/text/pdf/PdfWriterTest.java | 42 + 8 files changed, 1306 insertions(+), 1749 deletions(-) delete mode 100644 openpdf/src/main/java/com/lowagie/text/error_messages/en.lng delete mode 100644 openpdf/src/main/java/com/lowagie/text/error_messages/nl.lng delete mode 100644 openpdf/src/main/java/com/lowagie/text/error_messages/pt.lng create mode 100644 openpdf/src/test/java/com/lowagie/text/pdf/PdfWriterTest.java diff --git a/openpdf/src/main/java/com/lowagie/text/error_messages/en.lng b/openpdf/src/main/java/com/lowagie/text/error_messages/en.lng deleted file mode 100644 index 730010285..000000000 --- a/openpdf/src/main/java/com/lowagie/text/error_messages/en.lng +++ /dev/null @@ -1,407 +0,0 @@ -# default language English -1.2.does.not.contain.an.usable.cmap={1} {2} does not contain an usable cmap. -1.2.is.not.a.ttf.font.file={1} {2} is not a TTF font file. -1.at.file.pointer.2={1} at file pointer {2} -1.bit.samples.are.not.supported.for.horizontal.differencing.predictor={1}-bit samples are not supported for Horizontal differencing Predictor. -1.cannot.be.embedded.due.to.licensing.restrictions={1} cannot be embedded due to licensing restrictions. -1.component.s.is.not.supported={1} component(s) is not supported -1.corrupted.jfif.marker={1} corrupted JFIF marker. -1.is.an.unknown.graphics.state.dictionary={1} is an unknown graphics state dictionary -1.is.an.unknown.image.format={1} is an unknown Image format. -1.is.not.a.true.type.file={1} is not a true type file. -1.is.not.a.ttf.otf.or.ttc.font.file={1} is not a TTF, OTF or TTC font file. -1.is.not.a.valid.jpeg.file={1} is not a valid JPEG-file. -1.is.not.a.valid.number.2={1} is not a valid number - {2} -1.is.not.a.valid.page.size.format.2={1} is not a valid page size format: {2} -1.is.not.a.valid.placeable.windows.metafile={1} is not a valid placeable windows metafile. -1.is.not.a.valid.ttc.file={1} is not a valid TTC file. -1.is.not.a.valid.ttf.file={1} is not a valid TTF file. -1.is.not.a.valid.ttf.or.otf.file={1} is not a valid TTF or OTF file. -1.is.not.an.acceptable.value.for.the.field.2={1} is not an acceptable value for the field {2} -1.is.not.an.afm.or.pfm.font.file={1} is not an AFM or PFM font file. -1.must.have.8.bits.per.component={1} must have 8 bits per component. -1.near.line.2.column.3={1} near line {2}, column {3} -1.not.found.as.file.or.resource={1} not found as file or resource. -1.not.found.as.resource={1} not found as resource. -1.unsupported.jpeg.marker.2={1}: unsupported JPEG marker: {2} -a.pattern.can.not.be.used.as.a.template.to.create.an.image=A pattern can not be used as a template to create an image. -a.pdfx.conforming.document.cannot.be.encrypted=A PDFX conforming document cannot be encrypted. -a.string.1.was.passed.in.state.only.on.off.and.toggle.are.allowed=A string '{1} was passed in state. Only 'ON', 'OFF' and 'Toggle' are allowed. -a.tab.position.may.not.be.lower.than.0.yours.is.1=A tab position may not be lower than 0; yours is {1} -a.table.should.have.at.least.1.column=A table should have at least 1 column. -a.tiling.or.shading.pattern.cannot.be.used.as.a.color.space.in.a.shading.pattern=A tiling or shading pattern cannot be used as a color space in a shading pattern -a.title.is.not.a.layer=A title is not a layer -addcell.cell.has.null.value=addCell - cell has null-value -addcell.error.in.reserve=addCell - error in reserve -addcell.illegal.column.argument=addCell - illegal column argument -addcell.null.argument=addCell - null argument -addcell.only.cells.or.tables.allowed=addCell - only Cells or Tables allowed -addcell.point.has.null.value=addCell - point has null-value -adding.a.cell.at.the.location.1.2.with.a.colspan.of.3.and.a.rowspan.of.4.is.illegal.beyond.boundaries.overlapping=Adding a cell at the location ({1},{2}) with a colspan of {3} and a rowspan of {4} is illegal (beyond boundaries/overlapping). -ai.not.found.1=AI not found: ({1}) -ai.too.short.1=AI too short: ({1}) -all.fill.bits.preceding.eol.code.must.be.0=All fill bits preceding EOL code must be 0. -all.the.fonts.must.be.embedded.this.one.isn.t.1=All the fonts must be embedded. This one isn't: {1} -already.attempted.a.read.on.this.jbig2.file=already attempted a read() on this Jbig2 File -an.appearance.was.requested.without.a.variable.text.field=An appearance was requested without a variable text field. -an.image.mask.cannot.contain.another.image.mask=An image mask cannot contain another image mask. -an.uncolored.pattern.was.expected=An uncolored pattern was expected. -an.uncolored.tile.pattern.can.not.have.another.pattern.or.shading.as.color=An uncolored tile pattern can not have another pattern or shading as color. -append.mode.does.not.support.changing.the.encryption.status=Append mode does not support changing the encryption status. -append.mode.requires.a.document.without.errors.even.if.recovery.was.possible=Append mode requires a document without errors even if recovery was possible. -authenticated.attribute.is.missing.the.digest=Authenticated attribute is missing the digest. -b.type.before.end.of.paragraph.at.index.1=B type before end of paragraph at index: {1} -bad.certificate.and.key=Bad certificate and key. -bad.endianness.tag.not.0x4949.or.0x4d4d=Bad endianness tag (not 0x4949 or 0x4d4d). -bad.linebreak.1.at.index.2=bad linebreak: {1} at index: {2} -bad.magic.number.should.be.42=Bad magic number, should be 42. -bad.user.password=Bad user password -badly.formated.directory.string=badly formated directory string -badly.formed.ucc.string.1=Badly formed UCC string: {1} -base64.input.not.properly.padded=Base64 input not properly padded. -bbox.must.be.a.4.element.array=BBox must be a 4 element array. -bits.per.component.must.be.1.2.4.or.8=Bits-per-component must be 1, 2, 4, or 8. -bits.per.sample.1.is.not.supported=Bits per sample {1} is not supported. -blend.mode.1.not.allowed=Blend mode {1} not allowed. -bookmark.end.tag.out.of.place=Bookmark end tag out of place. -both.colors.must.be.of.the.same.type=Both colors must be of the same type. -buffersize.1=bufferSize {1} -can.only.push.back.one.byte=Can only push back one byte -can.t.add.1.to.multicolumntext.with.complex.columns=Can't add {1} to MultiColumnText with complex columns -can.t.decode.pkcs7signeddata.object=can't decode PKCS7SignedData object -can.t.find.page.size.1=Can't find page size {1} -can.t.find.signing.certificate.with.serial.1=Can't find signing certificate with serial {1} -cannot.change.destination.of.external.link=Cannot change destination of external link -cannot.handle.box.sizes.higher.than.2.32=Cannot handle box sizes higher than 2^32 -cf.not.found.encryption=/CF not found (encryption) -codabar.must.have.at.least.a.start.and.stop.character=Codabar must have at least a start and stop character. -codabar.must.have.one.of.abcd.as.start.stop.character=Codabar must have one of 'ABCD' as start/stop character. -colors.are.not.allowed.in.uncolored.tile.patterns=Colors are not allowed in uncolored tile patterns. -colorspace.calrgb.is.not.allowed=Colorspace CalRGB is not allowed. -colorspace.rgb.is.not.allowed=Colorspace RGB is not allowed. -column.coordinate.of.location.must.be.gt.eq.0.and.lt.nr.of.columns=column coordinate of location must be >= 0 and < nr of columns -columntext.go.with.simulate.eq.eq.false.and.text.eq.eq.null=ColumnText.go with simulate==false and text==null. -components.must.be.1.3.or.4=Components must be 1, 3, or 4. -compression.jpeg.is.only.supported.with.a.single.strip.this.image.has.1.strips=Compression JPEG is only supported with a single strip. This image has {1} strips. -content.can.not.be.added.to.a.pdfimportedpage=Content can not be added to a PdfImportedPage. -content.was.already.written.to.the.output=Content was already written to the output. -corrupted.png.file=Corrupted PNG file. -could.not.find.web.browser=Could not find web browser. -count.of.referred.to.segments.had.bad.value.in.header.for.segment.1.starting.at.2=count of referred-to segments had bad value in header for segment {1} starting at {2} -defaultcryptfilter.not.found.encryption=/DefaultCryptFilter not found (encryption) -destination.end.tag.out.of.place=Destination end tag out of place. -dictionary.key.is.not.a.name=Dictionary key is not a name. -dimensions.of.a.cell.are.attributed.automagically.see.the.faq=Dimensions of a Cell are attributed automagically. See the FAQ. -dimensions.of.a.cell.can.t.be.calculated.see.the.faq=Dimensions of a Cell can't be calculated. See the FAQ. -dimensions.of.a.table.can.t.be.calculated.see.the.faq=Dimensions of a Table can't be calculated. See the FAQ. -directory.number.too.large=Directory number too large. -document.already.pre.closed=Document already pre closed. -element.not.allowed=Element not allowed. -encryption.can.only.be.added.before.opening.the.document=Encryption can only be added before opening the document. -eol.code.word.encountered.in.black.run=EOL code word encountered in Black run. -eol.code.word.encountered.in.white.run=EOL code word encountered in White run. -error.attempting.to.launch.web.browser=Error attempting to launch web browser -error.expected.hex.character.and.not.char.thenextbyte.1=Error: expected hex character and not (char)theNextByte:{1} -error.expected.the.end.of.a.dictionary=Error: expected the end of a dictionary. -error.in.attribute.processing=Error in attribute processing -error.in.base64.code.reading.stream=Error in Base64 code reading stream. -error.parsing.cmap.beginbfchar.expected.cosstring.or.cosname.and.not.1=Error parsing CMap beginbfchar, expected {COSString or COSName} and not {1} -error.reading.objstm=Error reading ObjStm -error.reading.string=Error reading string -error.with.jp.marker=Error with JP Marker -expected.ftyp.marker=Expected FTYP Marker -expected.gt.for.tag.lt.1.gt=Expected > for tag: <{1}/> -expected.ihdr.marker=Expected IHDR Marker -expected.jp.marker=Expected JP Marker -expected.jp2h.marker=Expected JP2H Marker -extra.samples.are.not.supported=Extra samples are not supported. -failed.to.get.tsa.response.from.1=Failed to get TSA response from '{1}' -fdf.header.not.found=FDF header signature not found. -field.flattening.is.not.supported.in.append.mode=Field flattening is not supported in append mode. -field.names.cannot.contain.a.dot=Field names cannot contain a dot. -file.header.flags.bits.2.7.not.0=file header flags bits 2-7 not 0 -file.header.idstring.not.good.at.byte.1=file header idstring not good at byte {1} -file.is.not.a.valid.png=File is not a valid PNG. -file.position.0.cross.reference.entry.in.this.xref.subsection=File position 0 cross-reference entry in this xref subsection -first.scanline.must.be.1d.encoded=First scanline must be 1D encoded. -font.1.with.2.encoding.is.not.a.cjk.font=Font '{1}' with '{2}' encoding is not a CJK font. -font.1.with.2.is.not.recognized=Font '{1}' with '{2}' is not recognized. -font.and.size.must.be.set.before.writing.any.text=Font and size must be set before writing any text -font.size.too.small.1=Font size too small: {1} -fontfactoryimp.cannot.be.null=FontFactoryImp cannot be null. -freetext.flattening.is.not.supported.in.append.mode=FreeText flattening is not supported in append mode. -getcell.at.illegal.index.1.max.is.2=getCell at illegal index :{1} max is {2} -getcell.at.illegal.index.1=getCell at illegal index : {1} -gif.signature.nor.found=Gif signature nor found. -greaterthan.not.expected='>' not expected -illegal.capacity.1=Illegal Capacity: {1} -illegal.character.in.ascii85decode=Illegal character in ASCII85Decode. -illegal.character.in.asciihexdecode=Illegal character in ASCIIHexDecode. -illegal.length.in.ascii85decode=Illegal length in ASCII85Decode. -illegal.length.value=Illegal Length value. -illegal.load.1=Illegal Load: {1} -illegal.p.value=Illegal P value. -illegal.paragraph.embedding.level.1=illegal paragraph embedding level: {1} -illegal.r.value=Illegal R value. -illegal.type.value.at.1.2=illegal type value at {1}: {2} -illegal.v.value=Illegal V value. -illegal.value.for.predictor.in.tiff.file=Illegal value for Predictor in TIFF file. -improperly.padded.base64.input=Improperly padded Base64 input. -in.a.page.label.the.page.numbers.must.be.greater.or.equal.to.1=In a page label the page numbers must be greater or equal to 1. -in.codabar.start.stop.characters.are.only.allowed.at.the.extremes=In codabar, start/stop characters are only allowed at the extremes. -incomplete.palette=incomplete palette -inconsistent.mapping=Inconsistent mapping. -inconsistent.writers.are.you.mixing.two.documents=Inconsistent writers. Are you mixing two documents? -incorrect.segment.type.in.1=Incorrect segment type in {1} -insertion.of.illegal.element.1=Insertion of illegal Element: {1} -inserttable.point.has.null.value=insertTable - point has null-value -inserttable.table.has.null.value=insertTable - table has null-value -inserttable.wrong.columnposition.1.of.location.max.eq.2=insertTable -- wrong columnposition({1}) of location; max ={2} -insufficient.data=Insufficient data. -insufficient.length=Insufficient length. -internal.inconsistence=Internal inconsistence. -inthashtableiterator=IntHashtableIterator -invalid.additional.action.type.1=Invalid additional action type: {1} -invalid.ai.length.1=Invalid AI length: ({1}) -invalid.border.style=Invalid border style. -invalid.character.in.base64.data=Invalid character in Base64 data. -invalid.code.encountered.while.decoding.2d.group.3.compressed.data=Invalid code encountered while decoding 2D group 3 compressed data. -invalid.code.encountered.while.decoding.2d.group.4.compressed.data=Invalid code encountered while decoding 2D group 4 compressed data. -invalid.code.encountered=Invalid code encountered. -invalid.code.type=Invalid code type. -invalid.codeword.size=Invalid codeword size. -invalid.color.type=Invalid color type. -invalid.cross.reference.entry.in.this.xref.subsection=Invalid cross-reference entry in this xref subsection -invalid.end.tag.1=Invalid end tag - {1} -invalid.generation.number=Invalid generation number. -invalid.http.response.1=Invalid HTTP response: {1} -invalid.icc.profile=Invalid ICC profile -invalid.index.1=Invalid index: {1} -invalid.listtype.value=Invalid listType value. -invalid.magic.value.for.bmp.file=Invalid magic value for BMP file. -invalid.named.action=Invalid named action. -invalid.object.number=Invalid object number. -invalid.page.additional.action.type.1=Invalid page additional action type: {1} -invalid.page.number.1=Invalid page number: {1} -invalid.run.direction.1=Invalid run direction: {1} -invalid.status.1=Invalid status: {1} -invalid.tsa.1.response.code.2=Invalid TSA '{1}' response, code {2} -invalid.type.was.passed.in.state.1=Invalid type was passed in state: {1} -invalid.use.of.a.pattern.a.template.was.expected=Invalid use of a pattern. A template was expected. -irregular.columns.are.not.supported.in.composite.mode=Irregular columns are not supported in composite mode. -java.awt.image.fetch.aborted.or.errored=java.awt.Image fetch aborted or errored -java.awt.image.interrupted.waiting.for.pixels=java.awt.Image Interrupted waiting for pixels! -last.linebreak.must.be.at.1=last linebreak must be at {1} -layers.are.not.allowed=Layers are not allowed. -layout.out.of.bounds=Layout out of bounds. -line.iterator.out.of.bounds=line iterator out of bounds -linear.page.mode.can.only.be.called.with.a.single.parent=Linear page mode can only be called with a single parent. -lzw.flavour.not.supported=LZW flavour not supported. -macrosegmentid.must.be.gt.eq.0=macroSegmentId must be >=0 -macrosegmentid.must.be.lt.macrosemgentcount=macroSegmentId must be < macroSemgentCount -macrosemgentcount.must.be.gt.0=macroSemgentCount must be > 0 -mapping.code.should.be.1.or.two.bytes.and.not.1=Mapping code should be 1 or two bytes and not {1} -missing.end.tag=Missing end tag -missing.endcharmetrics.in.1=Missing EndCharMetrics in {1} -missing.endfontmetrics.in.1=Missing EndFontMetrics in {1} -missing.endkernpairs.in.1=Missing EndKernPairs in {1} -missing.startcharmetrics.in.1=Missing StartCharMetrics in {1} -missing.tag.s.for.ojpeg.compression=Missing tag(s) for OJPEG compression. -multicolumntext.has.no.columns=MultiColumnText has no columns -name.end.tag.out.of.place=Name end tag out of place. -nested.tags.are.not.allowed=Nested tags are not allowed. -no.compatible.encryption.found=No compatible encryption found -no.error.just.an.old.style.table=No error, just an old style table -no.font.is.defined=No font is defined. -no.glyphs.defined.for.type3.font=No glyphs defined for Type3 font -no.valid.column.line.found=No valid column line found. -no.valid.encryption.mode=No valid encryption mode -not.a.placeable.windows.metafile=Not a placeable windows metafile -not.a.valid.jpeg2000.file=Not a valid Jpeg2000 file -not.a.valid.pfm.file=Not a valid PFM file. -not.a.valid.pkcs.7.object.not.a.sequence=Not a valid PKCS#7 object - not a sequence -not.a.valid.pkcs.7.object.not.signed.data=Not a valid PKCS#7 object - not signed data -not.all.annotations.could.be.added.to.the.document.the.document.doesn.t.have.enough.pages=Not all annotations could be added to the document (the document doesn't have enough pages). -not.colorized.typed3.fonts.only.accept.mask.images=Not colorized Typed3 fonts only accept mask images. -null.outpustream=null OutpuStream -number.of.entries.in.this.xref.subsection.not.found=Number of entries in this xref subsection not found -object.number.of.the.first.object.in.this.xref.subsection.not.found=Object number of the first object in this xref subsection not found -ocsp.status.is.revoked=OCSP Status is revoked! -ocsp.status.is.unknown=OCSP Status is unknown! -only.bmp.can.be.wrapped.in.wmf=Only BMP can be wrapped in WMF. -only.bmp.png.wmf.gif.and.jpeg.images.are.supported.by.the.rtf.writer=Only BMP, PNG, WMF, GIF and JPEG images are supported by the RTF Writer -only.javascript.actions.are.allowed=Only JavaScript actions are allowed. -only.one.of.artbox.or.trimbox.can.exist.in.the.page=Only one of ArtBox or TrimBox can exist in the page. -only.pdflayer.is.accepted=Only PdfLayer is accepted. -only.rgb.gray.and.cmyk.are.supported.as.alternative.color.spaces=Only RGB, Gray and CMYK are supported as alternative color spaces. -open.actions.by.name.are.not.supported=Open actions by name are not supported. -operator.1.already.registered=Operator {1} already registered -page.1.invalid.for.segment.2.starting.at.3=page {1} invalid for segment {2} starting at {3} -page.attribute.missing=Page attribute missing. -page.not.found=Page not found. -page.reordering.requires.a.single.parent.in.the.page.tree.call.pdfwriter.setlinearmode.after.open=Page reordering requires a single parent in the page tree. Call PdfWriter.setLinearMode() after open. -page.reordering.requires.an.array.with.the.same.size.as.the.number.of.pages=Page reordering requires an array with the same size as the number of pages. -page.reordering.requires.no.page.repetition.page.1.is.repeated=Page reordering requires no page repetition. Page {1} is repeated. -page.reordering.requires.pages.between.1.and.1.found.2=Page reordering requires pages between 1 and {1}. Found {2}. -partial.form.flattening.is.not.supported.with.xfa.forms=Partial form flattening is not supported with XFA forms. -pdf.header.not.found=PDF header signature not found. -pdf.startxref.not.found=PDF startxref not found. -pdfpcells.can.t.have.a.rowspan.gt.1=PdfPCells can't have a rowspan > 1 -pdfreader.not.opened.with.owner.password=PdfReader not opened with owner password -pdfx.conformance.can.only.be.set.before.opening.the.document=PDFX conformance can only be set before opening the document. -planar.images.are.not.supported=Planar images are not supported. -png.filter.unknown=PNG filter unknown. -preclose.must.be.called.first=preClose() must be called first. -premature.end.in.1=Premature end in {1} -premature.end.of.file=Premature end of file. -premature.eof.while.reading.jpg=Premature EOF while reading JPG. -rebuild.failed.1.original.message.2=Rebuild failed: {1}; Original message: {2} -rectanglereadonly.this.rectangle.is.read.only=RectangleReadOnly: this Rectangle is read only. -reference.pointing.to.reference=Reference pointing to reference. -referring.to.widht.height.of.page.we.havent.seen.yet.1=referring to widht/height of page we havent seen yet? {1} -remove.not.supported=remove() not supported. -reserve.incorrect.column.size=reserve - incorrect column/size -resources.do.not.contain.extgstate.entry.unable.to.process.operator.1=Resources do not contain ExtGState entry. Unable to process operator {1} -root.element.is.not.bookmark.1=Root element is not Bookmark: {1} -root.element.is.not.destination=Root element is not Destination. -root.element.is.not.xfdf.1=Root element is not xfdf: {1} -rotation.must.be.a.multiple.of.90=Rotation must be a multiple of 90. -row.coordinate.of.location.must.be.gt.eq.0=row coordinate of location must be >= 0 -scanline.must.begin.with.eol.code.word=Scanline must begin with EOL code word. -separations.patterns.and.shadings.are.not.allowed.in.mk.dictionary=Separations, patterns and shadings are not allowed in MK dictionary. -setelement.position.already.taken=setElement - position already taken -start.marker.missing.in.1=Start marker missing in {1} -startxref.is.not.followed.by.a.number=startxref is not followed by a number. -startxref.not.found=startxref not found. -stdcf.not.found.encryption=/StdCF not found (encryption) -stream.could.not.be.compressed.filter.is.not.a.name.or.array=Stream could not be compressed: filter is not a name or array. -table.1.does.not.exist.in.2=Table '{1}' does not exist in {2} -tag.1.not.allowed=Tag {1} not allowed. -tagging.must.be.set.before.opening.the.document=Tagging must be set before opening the document. -text.cannot.be.null=Text cannot be null. -the.array.must.contain.string.or.pdfannotation=The array must contain String or PdfAnnotation. -the.byte.array.is.not.a.recognized.imageformat=The byte array is not a recognized imageformat. -the.ccitt.compression.type.must.be.ccittg4.ccittg3.1d.or.ccittg3.2d=The CCITT compression type must be CCITTG4, CCITTG3_1D or CCITTG3_2D -the.char.1.doesn.t.belong.in.this.type3.font=The char {1} doesn't belong in this Type3 font -the.char.1.is.not.defined.in.a.type3.font=The char {1} is not defined in a Type3 font -the.character.1.is.illegal.in.codabar=The character '{1}' is illegal in codabar. -the.character.1.is.illegal.in.code.39.extended=The character '{1}' is illegal in code 39 extended. -the.character.1.is.illegal.in.code.39=The character '{1}' is illegal in code 39. -the.cmap.1.does.not.exist.as.a.resource=The cmap {1} does not exist as a resource. -the.cmap.1.was.not.found=The Cmap {1} was not found. -the.compression.1.is.not.supported=The compression {1} is not supported. -the.document.has.been.closed.you.can.t.add.any.elements=The document has been closed. You can't add any Elements. -the.document.has.no.pages=The document has no pages. -the.document.is.not.open.yet.you.can.only.add.meta.information=The document is not open yet; you can only add Meta information. -the.document.is.not.open=The document is not open. -the.document.is.open.you.can.only.add.elements.with.content=The document is open; you can only add Elements with content. -the.document.must.be.open.to.import.rtf.documents=The document must be open to import RTF documents. -the.document.must.be.open.to.import.rtf.fragments=The document must be open to import RTF fragments. -the.document.was.reused=The document was reused. -the.export.and.the.display.array.must.have.the.same.size=The export and the display array must have the same size. -the.field.1.already.exists=The field {1} already exists. -the.field.1.does.not.exist=The field {1} does not exist. -the.field.1.is.not.a.signature.field=The field {1} is not a signature field. -the.file.does.not.contain.any.valid.image=The file does not contain any valid image. -the.filter.1.is.not.supported=The filter {1} is not supported. -the.font.index.for.1.must.be.between.0.and.2.it.was.3=The font index for {1} must be between 0 and {2}. It was {3}. -the.font.index.for.1.must.be.positive=The font index for {1} must be positive. -the.image.mask.is.not.a.mask.did.you.do.makemask=The image mask is not a mask. Did you do makeMask()? -the.image.must.have.absolute.positioning=The image must have absolute positioning. -the.key.1.didn.t.reserve.space.in.preclose=The key {1} didn't reserve space in preClose(). -the.key.1.is.too.big.is.2.reserved.3=The key {1} is too big. Is {2}, reserved {3} -the.layer.1.already.has.a.parent=The layer '{1}' already has a parent. -the.matrix.size.must.be.6=The matrix size must be 6. -the.name.1.is.too.long.2.characters=The name '{1}' is too long ({2} characters). -the.new.size.must.be.positive.and.lt.eq.of.the.current.size=The new size must be positive and <= of the current size -the.number.of.booleans.in.this.array.doesn.t.correspond.with.the.number.of.fields=The number of booleans in this array doesn't correspond with the number of fields. -the.number.of.columns.in.pdfptable.constructor.must.be.greater.than.zero=The number of columns in PdfPTable constructor must be greater than zero. -the.original.document.was.reused.read.it.again.from.file=The original document was reused. Read it again from file. -the.page.number.must.be.gt.eq.1=The page number must be >= 1. -the.parent.has.already.another.function=The parent has already another function. -the.photometric.1.is.not.supported=The photometric {1} is not supported. -the.resource.cjkencodings.properties.does.not.contain.the.encoding.1=The resource cjkencodings.properties does not contain the encoding {1} -the.smask.key.is.not.allowed.in.images=The /SMask key is not allowed in images. -the.spot.color.must.be.the.same.only.the.tint.can.vary=The spot color must be the same, only the tint can vary. -the.stack.is.empty=The stack is empty. -the.structure.has.kids=The structure has kids. -the.table.width.must.be.greater.than.zero=The table width must be greater than zero. -the.template.can.not.be.null=The template can not be null. -the.text.is.too.big=The text is too big. -the.text.length.must.be.even=The text length must be even. -the.two.barcodes.must.be.composed.externally=The two barcodes must be composed externally. -the.update.dictionary.has.less.keys.than.required=The update dictionary has less keys than required. -the.url.of.the.image.is.missing=The URL of the image is missing. -the.value.has.to.be.true.of.false.instead.of.1=The value has to be 'true' of 'false', instead of '{1}'. -the.width.cannot.be.set=The width cannot be set. -the.widths.array.in.pdfptable.constructor.can.not.be.null=The widths array in PdfPTable constructor can not be null. -the.widths.array.in.pdfptable.constructor.can.not.have.zero.length=The widths array in PdfPTable constructor can not have zero length. -the.writer.in.pdfcontentbyte.is.null=The writer in PdfContentByte is null. -there.are.illegal.characters.for.barcode.128.in.1=There are illegal characters for barcode 128 in '{1}'. -this.acrofields.instance.is.read.only=This AcroFields instance is read-only. -this.image.can.not.be.an.image.mask=This image can not be an image mask. -this.largeelement.has.already.been.added.to.the.document=This LargeElement has already been added to the Document. -this.page.cannot.be.replaced.new.content.was.already.added=This page cannot be replaced: new content was already added -this.pkcs.7.object.has.multiple.signerinfos.only.one.is.supported.at.this.time=This PKCS#7 object has multiple SignerInfos - only one is supported at this time -tiff.5.0.style.lzw.codes.are.not.supported=TIFF 5.0-style LZW codes are not supported. -tiff.fill.order.tag.must.be.either.1.or.2=TIFF_FILL_ORDER tag must be either 1 or 2. -tiles.are.not.supported=Tiles are not supported. -title.cannot.be.null=Title cannot be null. -token.obj.expected=Token 'obj' expected. -trailer.not.found=trailer not found. -transparency.is.not.allowed.ca.eq.1=Transparency is not allowed: /ca = {1} -transparency.length.must.be.equal.to.2.with.ccitt.images=Transparency length must be equal to 2 with CCITT images -transparency.length.must.be.equal.to.componentes.2=Transparency length must be equal to (componentes * 2) -trying.to.create.a.table.without.rows=Trying to create a table without rows. -tsa.1.failed.to.return.time.stamp.token.2=TSA '{1}' failed to return time stamp token: {2} -two.byte.arrays.are.needed.if.the.type1.font.is.embedded=Two byte arrays are needed if the Type1 font is embedded. -type3.font.used.with.the.wrong.pdfwriter=Type3 font used with the wrong PdfWriter -types.is.null=types is null -unbalanced.begin.end.marked.content.operators=Unbalanced begin/end marked content operators. -unbalanced.begin.end.text.operators=Unbalanced begin/end text operators. -unbalanced.layer.operators=Unbalanced layer operators. -unbalanced.marked.content.operators=Unbalanced marked content operators. -unbalanced.save.restore.state.operators=Unbalanced save/restore state operators. -unexpected.end.of.file=Unexpected end of file. -unexpected.eof=Unexpected EOF -unexpected.gt.gt=Unexpected '>>' -unexpected.close.bracket=Unexpected ']' -unknown.color.format.must.be.rgb.or.rrggbb=Unknown color format. Must be #RGB, #RRGGBB, #RGBA or #RRGGBBAA -unknown.encryption.type.r.eq.1=Unknown encryption type R = {1} -unknown.encryption.type.v.eq.1=Unknown encryption type V = {1} -unknown.filter.1=Unknown filter: {1} -unknown.hash.algorithm.1=Unknown Hash Algorithm {1} -unknown.key.algorithm.1=Unknown Key Algorithm {1} -unknown.object.at.k.1=Unknown object at /K {1} -unknown=unknown -unsupported.box.size.eq.eq.0=Unsupported box size == 0 -unsupported.in.this.context.use.pdfstamper.addannotation=Unsupported in this context. Use PdfStamper.addAnnotation() -use.pdfstamper.getundercontent.or.pdfstamper.getovercontent=Use PdfStamper.getUnderContent() or PdfStamper.getOverContent() -use.pdfstamper.setthumbnail=Use PdfStamper.setThumbnail(). -use.setpageaction.pdfname.actiontype.pdfaction.action.int.page=Use setPageAction(PdfName actionType, PdfAction action, int page) -userunit.should.be.a.value.between.1.and.75000=UserUnit should be a value between 1 and 75000. -verticaltext.go.with.simulate.eq.eq.false.and.text.eq.eq.null=VerticalText.go with simulate==false and text==null. -while.removing.wmf.placeable.header=while removing wmf placeable header -writelength.can.only.be.called.after.output.of.the.stream.body=writeLength() can only be called after output of the stream body. -writelength.can.only.be.called.in.a.contructed.pdfstream.inputstream.pdfwriter=writeLength() can only be called in a contructed PdfStream(InputStream,PdfWriter). -wrong.number.of.columns=Wrong number of columns. -xref.infinite.loop=An infinite loop was detected in the xref table. -xref.subsection.not.found=xref subsection not found -xstep.or.ystep.can.not.be.zero=XStep or YStep can not be ZERO. -you.can.only.add.a.writer.to.a.pdfdocument.once=You can only add a writer to a PdfDocument once. -you.can.only.add.cells.to.rows.no.objects.of.type.1=You can only add cells to rows, no objects of type {1} -you.can.only.add.objects.that.implement.the.element.interface=You can only add objects that implement the Element interface. -you.can.t.add.a.1.to.a.section=You can't add a {1} to a Section. -you.can.t.add.an.element.of.type.1.to.a.simplecell=You can't add an element of type {1} to a SimpleCell. -you.can.t.add.cells.to.a.table.directly.add.them.to.a.row.first=You can't add cells to a table directly, add them to a row first. -you.can.t.add.listitems.rows.or.cells.to.a.cell=You can't add listitems, rows or cells to a cell. -you.can.t.add.one.row.to.another.row=You can't add one row to another row. -you.can.t.have.1.pages.on.one.page.minimum.2.maximum.8=You can't have {1} pages on one page (minimum 2; maximum 8). -you.can.t.set.the.initial.leading.if.the.document.is.already.open=You can't set the initial leading if the document is already open. -you.can.t.split.this.document.at.page.1.there.is.no.such.page=You can't split this document at page {1}; there is no such page. -you.can.t.translate.a.negative.number.into.an.alphabetical.value=You can't translate a negative number into an alphabetical value. -you.have.to.consolidate.the.named.destinations.of.your.reader=You have to consolidate the named destinations of your reader. -you.have.to.define.a.boolean.array.for.this.collection.sort.dictionary=You have to define a boolean array for this collection sort dictionary. -you.have.used.the.wrong.constructor.for.this.fieldpositioningevents.class=You have used the wrong constructor for this FieldPositioningEvents class. -you.must.set.a.value.before.adding.a.prefix=You must set a value before adding a prefix. -you.need.a.single.boolean.for.this.collection.sort.dictionary=You need a single boolean for this collection sort dictionary. diff --git a/openpdf/src/main/java/com/lowagie/text/error_messages/nl.lng b/openpdf/src/main/java/com/lowagie/text/error_messages/nl.lng deleted file mode 100644 index 334959aad..000000000 --- a/openpdf/src/main/java/com/lowagie/text/error_messages/nl.lng +++ /dev/null @@ -1,407 +0,0 @@ -# Nederlandse vertaling van de foutboodschappen -1.2.does.not.contain.an.usable.cmap={1} {2} bevat geen bruikbare cmap. -1.2.is.not.a.ttf.font.file={1} {2} is geen TTF font file. -1.at.file.pointer.2={1} bij file pointer {2} -1.bit.samples.are.not.supported.for.horizontal.differencing.predictor={1}-bit samples worden niet ondersteund voor een horizontaal differencierende Predictor. -1.cannot.be.embedded.due.to.licensing.restrictions={1} kan niet ingebed worden omwille van licentie restricties. -1.component.s.is.not.supported=geen ondersteuning voor {1} component(en) -1.corrupted.jfif.marker={1} is een corrupte JFIF marker. -1.is.an.unknown.graphics.state.dictionary={1} is een onbekende graphics state dictionary -1.is.an.unknown.image.format={1} is een onbekend Image formaat. -1.is.not.a.true.type.file={1} is geen true type file. -1.is.not.a.ttf.otf.or.ttc.font.file={1} is geen TTF, OTF of TTC font file. -1.is.not.a.valid.jpeg.file={1} is geen geldig JPEG bestand. -1.is.not.a.valid.number.2={1} is geen geldig nummer - {2} -1.is.not.a.valid.page.size.format.2={1} is geen geldig pagina formaat: {2} -1.is.not.a.valid.placeable.windows.metafile={1} is geen geldige plaatsbaar WMF bestand. -1.is.not.a.valid.ttc.file={1} is geen geldige TTC file. -1.is.not.a.valid.ttf.file={1} is geen geldig TTF bestand. -1.is.not.a.valid.ttf.or.otf.file={1} is geen geldige TTF of OTF file. -1.is.not.an.acceptable.value.for.the.field.2={1} is geen geldige waarde voor het veld {2} -1.is.not.an.afm.or.pfm.font.file={1} is geen AFM of PFM font file. -1.must.have.8.bits.per.component={1} moet 8 bits per component bevatten. -1.near.line.2.column.3={1} in lijn {2}, kolom {3} -1.not.found.as.file.or.resource={1} niet gevonden als bron of bronbestand. -1.not.found.as.resource={1} niet gevonden als een bron(bestand). -1.unsupported.jpeg.marker.2={1}: niet ondersteunde JPEG marker: {2} -a.pattern.can.not.be.used.as.a.template.to.create.an.image=Een patroon kan niet gebruikt worden als template om een afbeelding te maken. -a.pdfx.conforming.document.cannot.be.encrypted=Een PDF/X document mag niet versleuteld worden. -a.string.1.was.passed.in.state.only.on.off.and.toggle.are.allowed=Een string '{1}' werd gebruikt als status. Alleen 'ON', 'OFF' en 'Toggle' zijn toegelaten. -a.tab.position.may.not.be.lower.than.0.yours.is.1=Een tab positie mag niet kleiner zijn dan 0; jouw tab positie is {1} -a.table.should.have.at.least.1.column=Een tabel moet uit ten minste 1 kolom bestaan. -a.tiling.or.shading.pattern.cannot.be.used.as.a.color.space.in.a.shading.pattern=Een tiling of shading pattern kan niet gebruikt worden als een color space in een shading pattern -a.title.is.not.a.layer=Een titel is geen layer -addcell.cell.has.null.value=addCell - cell bevat een null-waarde -addcell.error.in.reserve=addCell - fout in reserve -addcell.illegal.column.argument=addCell - ongeldig kolom argument -addcell.null.argument=addCell - argument null -addcell.only.cells.or.tables.allowed=addCell - alleen cellen en tabellen zijn toegelaten -addcell.point.has.null.value=addCell - point bevat een null-waarde -adding.a.cell.at.the.location.1.2.with.a.colspan.of.3.and.a.rowspan.of.4.is.illegal.beyond.boundaries.overlapping=Een cel toevoegen op positie ({1},{2}) met colspan {3} en rowspan {4} is niet mogelijk (overlapt of gaat buiten bereik). -ai.not.found.1=AI niet gevonden: ({1}) -ai.too.short.1=AI niet lang genoeg: ({1}) -all.fill.bits.preceding.eol.code.must.be.0=Alle fill bits voorafgaand aan EOL code moeten 0 zijn. -all.the.fonts.must.be.embedded.this.one.isn.t.1=Alle fonts moeten ingebed worden. Deze font is niet ingebed: {1} -already.attempted.a.read.on.this.jbig2.file=read() was al geprobeerd op dit Jbig2 bestand -an.appearance.was.requested.without.a.variable.text.field=Er werd een appearance gevraagd zonder variabel text field. -an.image.mask.cannot.contain.another.image.mask=Een image mask mag geen ander image mask bevatten. -an.uncolored.pattern.was.expected=Er werd een ongekleurd patroon verwacht. -an.uncolored.tile.pattern.can.not.have.another.pattern.or.shading.as.color=Een ongekleurd tile pattern kan geen ander pattern of shading als color gebruiken. -append.mode.does.not.support.changing.the.encryption.status=Append mode laat geen wijziging toe van de encryptie status. -append.mode.requires.a.document.without.errors.even.if.recovery.was.possible=Append mode vergt een document zonder fouten, zelfs als recovery mogelijk was. -authenticated.attribute.is.missing.the.digest=Er ontbreekt een geauthenticeerd attribuut in de digest. -b.type.before.end.of.paragraph.at.index.1=B type voor het einde van een paragraaf op index: {1} -bad.certificate.and.key=Verkeerd certificaat en sleutel. -bad.endianness.tag.not.0x4949.or.0x4d4d=Verkeerde endianness tag (niet 0x4949 of 0x4d4d). -bad.linebreak.1.at.index.2=slechte lijnafbreking: {1} op index: {2} -bad.magic.number.should.be.42=Verkeerd 'magic number', zou 42 moeten zijn. -bad.user.password=Verkeerd user password -badly.formated.directory.string=Slecht geformateerde directory string -badly.formed.ucc.string.1=Slecht gevormde UCC string: {1} -base64.input.not.properly.padded=Base64 input is niet correct 'gepad'. -bbox.must.be.a.4.element.array=BBox moet een array met 4 elementen zijn. -bits.per.component.must.be.1.2.4.or.8=Bits-per-component moet 1, 2, 4, of 8 zijn. -bits.per.sample.1.is.not.supported=Bits per sample {1} wordt niet ondersteund. -blend.mode.1.not.allowed=Blend mode {1} niet toegelaten. -bookmark.end.tag.out.of.place=Bookmark end tag op verkeerde plaats. -both.colors.must.be.of.the.same.type=Beide kleuren moeten van het zelfde type zijn. -buffersize.1=bufferlengte {1} -can.only.push.back.one.byte=Werkt enkel met ��n byte ineens. -can.t.add.1.to.multicolumntext.with.complex.columns={1} kan niet toegevoegd worden aan een MultiColumnText met complexe kolommen -can.t.decode.pkcs7signeddata.object=Kan het PKCS7SignedData object niet decoderen -can.t.find.page.size.1=Kan de pagina afmetingen niet vinden {1} -can.t.find.signing.certificate.with.serial.1=Kan het signing certificate met serienummer {1} niet vinden -cannot.change.destination.of.external.link=De destination van een external link kan niet gewijzigd worden -cannot.handle.box.sizes.higher.than.2.32=Een box size groter dan 2^32 is niet mogelijk -cf.not.found.encryption=/CF niet gevonden (encryption) -codabar.must.have.at.least.a.start.and.stop.character=Codabar moet ten minste een start en stop karakter bevatten. -codabar.must.have.one.of.abcd.as.start.stop.character=Codabar must have one of 'ABCD' as start/stop character. -colors.are.not.allowed.in.uncolored.tile.patterns=Kleuren zijn niet toegelaten in ongekleurde patronen. -colorspace.calrgb.is.not.allowed=Colorspace CalRGB is niet toegelaten. -colorspace.rgb.is.not.allowed=Colorspace RGB is niet toegelaten. -column.coordinate.of.location.must.be.gt.eq.0.and.lt.nr.of.columns=Kolom coordinaat moet groter dan of gelijk zijn aan 0 en kleiner dan het aantal kolommen -columntext.go.with.simulate.eq.eq.false.and.text.eq.eq.null=ColumnText.go met simulate==false en text==null. -components.must.be.1.3.or.4=Componenten moeten 1, 3, of 4 zijn. -compression.jpeg.is.only.supported.with.a.single.strip.this.image.has.1.strips=Compressie JPEG wordt enkel ondersteund voor ��n enkele strip. Jouw JPEG heeft {1} strips. -content.can.not.be.added.to.a.pdfimportedpage=Er kan geen extra content toegevoegd worden aan een PdfImportedPage. -content.was.already.written.to.the.output=Er werd al inhoud naar de output gestuurd. -corrupted.png.file=Corrupt PNG bestand. -could.not.find.web.browser=Kon geen webbrowser vinden. -count.of.referred.to.segments.had.bad.value.in.header.for.segment.1.starting.at.2=Een aantal referred-to segmenten heeft een ongeldige waarde in de header voor segment {1} beginnend bij {2} -defaultcryptfilter.not.found.encryption=/DefaultCryptFilter niet gevonden (encryption) -destination.end.tag.out.of.place=Bestemming end tag op verkeerde plaats. -dictionary.key.is.not.a.name=De sleutel voor de Dictionary is geen naam. -dimensions.of.a.cell.are.attributed.automagically.see.the.faq=De afmetingen van een Cell worden automatisch toegekend. Zie de FAQ. -dimensions.of.a.cell.can.t.be.calculated.see.the.faq=De afmetingen van een Cell kunnen niet berekend worden. Zie de FAQ. -dimensions.of.a.table.can.t.be.calculated.see.the.faq=Dimensies van een Table object kunnen niet berekend worden. Zie de FAQ. -directory.number.too.large=Directory nummer te groot. -document.already.pre.closed=Het Document is als gesloten (preclosed). -element.not.allowed=Element niet toegelaten. -encryption.can.only.be.added.before.opening.the.document=Encryptie kan enkel bepaald worden voor het document geopend wordt. -eol.code.word.encountered.in.black.run=EOL code woord gevonden in Black run. -eol.code.word.encountered.in.white.run=EOL code woord gevonden in White run. -error.attempting.to.launch.web.browser=Fout bij het opstarten van de webbrowser. -error.expected.hex.character.and.not.char.thenextbyte.1=Fout: hexademicaal karakter verwacht in plaats van (char)theNextByte:{1} -error.expected.the.end.of.a.dictionary=Fout: einde van een dictionary verwacht. -error.in.attribute.processing=Fout bij verwerking attribuut -error.in.base64.code.reading.stream=Fout in de Base64 code reading stream. -error.parsing.cmap.beginbfchar.expected.cosstring.or.cosname.and.not.1=Fout bij het parsen van CMap beginbfchar, {COSString or COSName} verwacht in plaats van {1} -error.reading.objstm=Fout tijdens het lezen van ObjStm -error.reading.string=Fout bij het lezen van een string -error.with.jp.marker=Foute JP Marker -expected.ftyp.marker=FTYP Marker verwacht -expected.gt.for.tag.lt.1.gt=Karakter > verwacht voor tag: <{1}/> -expected.ihdr.marker=IHDR Marker verwacht -expected.jp.marker=JP Marker verwacht -expected.jp2h.marker=JP2H Marker verwacht -extra.samples.are.not.supported=Extra samples worden niet ondersteund. -failed.to.get.tsa.response.from.1=Slaagde er niet in een TSA antwoord te krijgen van '{1}' -fdf.header.not.found=FDF header niet gevonden. -field.flattening.is.not.supported.in.append.mode=Field flattening is niet ondersteund in append mode. -field.names.cannot.contain.a.dot=De naam van een veld mag geen punt bevatten. -file.header.flags.bits.2.7.not.0=file header vlaggen bits 2 tot 7 zijn niet 0 -file.header.idstring.not.good.at.byte.1=file header idstring is niet correct op byte {1} -file.is.not.a.valid.png=Het bestand is geen geldige PNG afbeelding. -file.position.0.cross.reference.entry.in.this.xref.subsection=Bestands positie 0 voor cross-reference entry in deze xref subsectie -first.scanline.must.be.1d.encoded=Eerste scanline moet 1D geencodeerd zijn. -font.1.with.2.encoding.is.not.a.cjk.font=Font '{1}' met encoding '{2}' is geen CJK font. -font.1.with.2.is.not.recognized=Font '{1}' met '{2}' werd niet herkend. -font.and.size.must.be.set.before.writing.any.text=Font en size moeten bepaald zijn vooraleer je tekst schrijft. -font.size.too.small.1=Font size te klein: {1} -fontfactoryimp.cannot.be.null=FontFactoryImp kan niet null zijn. -freetext.flattening.is.not.supported.in.append.mode=FreeText flattening is niet ondersteund in append mode. -getcell.at.illegal.index.1.max.is.2=getCell op ongeldige index:{1} maximum: {2} -getcell.at.illegal.index.1=getCell op ongeldige index : {1} -gif.signature.nor.found=Gif signature niet gevonden. -greaterthan.not.expected='>' op een onverwachte plaats -illegal.capacity.1=Ongeldige capaciteit: {1} -illegal.character.in.ascii85decode=Ongeldig karakter in ASCII85Decode. -illegal.character.in.asciihexdecode=Ongeldig karakter in ASCIIHexDecode. -illegal.length.in.ascii85decode=Ongeldige lengte in ASCII85Decode. -illegal.length.value=Ongeldige waarde voor de lengte. -illegal.load.1=Ongeldige load: {1} -illegal.p.value=Ongeldige waarde voor P. -illegal.paragraph.embedding.level.1=ongeldig embedding niveau paragraaf: {1} -illegal.r.value=Ongeldige waarde voor R. -illegal.type.value.at.1.2=ongeldige waarde voor type op {1}: {2} -illegal.v.value=Ongeldige waarde voor V. -illegal.value.for.predictor.in.tiff.file=Ongeldige waarde voor Predictor in TIFF file. -improperly.padded.base64.input=Ongeldig 'gepadde' Base64 input. -in.a.page.label.the.page.numbers.must.be.greater.or.equal.to.1=In een page label moeten de pagina nummers groter dan of gelijk aan 1 zijn. -in.codabar.start.stop.characters.are.only.allowed.at.the.extremes=In codabar worden start/stop karakters enkel toegelaten bij begin en einde van de string. -incomplete.palette=onvolledig palet -inconsistent.mapping=Inconsistente mapping. -inconsistent.writers.are.you.mixing.two.documents=Inconsistente writers. Ben je twee documenten aan het verhaspelen? -incorrect.segment.type.in.1=Foutief segment type in {1} -insertion.of.illegal.element.1=Invoeging van een ongeldig Element: {1} -inserttable.point.has.null.value=insertTable - punt bevat een null-waarde -inserttable.table.has.null.value=insertTable - tabel bevat een null-waarde -inserttable.wrong.columnposition.1.of.location.max.eq.2=insertTable -- verkeerde komom positie ({1}); maximum ={2} -insufficient.data=Involdoende data. -insufficient.length=Onvoldoende lengte. -internal.inconsistence=Interne inconsistentie. -inthashtableiterator=IntHashtableIterator -invalid.additional.action.type.1=Ongeldig 'additional action' type: {1} -invalid.ai.length.1=Ongeldige AI lengte: ({1}) -invalid.border.style=Ongeldige border style. -invalid.character.in.base64.data=Ongeldig karakter in de Base64 data. -invalid.code.encountered.while.decoding.2d.group.3.compressed.data=Ongeldige code gevonden tijdens het decoderen van 2D group 3 gecomprimeerde data. -invalid.code.encountered.while.decoding.2d.group.4.compressed.data=Ongeldige code gevonden tijdens het decoderen van 2D group 4 gecomprimeerde data. -invalid.code.encountered=Ongeldige code gevonden. -invalid.code.type=Ongeldig code type. -invalid.codeword.size=Ongeldige codeword lengte. -invalid.color.type=Ongeldig kleurtype. -invalid.cross.reference.entry.in.this.xref.subsection=Ongeldige cross-reference entry in deze xref subsectie -invalid.end.tag.1=Ongeldige end tag - {1} -invalid.generation.number=Ongeldig generation nummer. -invalid.http.response.1=Ongeldig HTTP antwoord: {1} -invalid.icc.profile=Ongeldig ICC profiel. -invalid.index.1=Ongeldige index: {1} -invalid.listtype.value=Ongeldige waarde voor listType. -invalid.magic.value.for.bmp.file=Ongeldige 'magic value' voor een BMP bestand. -invalid.named.action=Ongeldige named action. -invalid.object.number=Ongeldig object nummer. -invalid.page.additional.action.type.1=Ongeldig 'page additional action' type: {1} -invalid.page.number.1=Ongeldig pagina nummer: {1} -invalid.run.direction.1=Ongeldige run direction: {1} -invalid.status.1=Ongeldige status: {1} -invalid.tsa.1.response.code.2=Ongeldig TSA '{1}' antwoord, code {2} -invalid.type.was.passed.in.state.1=Ongeldig type gebruikt als state: {1} -invalid.use.of.a.pattern.a.template.was.expected=Ongeldig gebruik van een patroon. Er werd een template verwacht. -irregular.columns.are.not.supported.in.composite.mode=Onregelmatige kolommen zijn niet toegelaten in composite mode. -java.awt.image.fetch.aborted.or.errored=Ophalen van java.awt.Image afgebroken of misgelopen. -java.awt.image.interrupted.waiting.for.pixels=java.awt.Image onderbroken; aan het wachten op pixels! -last.linebreak.must.be.at.1=laatste lijnafbreking moet op {1} -layers.are.not.allowed=Layers zijn niet toegelaten. -layout.out.of.bounds=Layout buiten het grensbereik. -line.iterator.out.of.bounds=lijn iterator buiten het grensbereik. -linear.page.mode.can.only.be.called.with.a.single.parent=Linear page mode kan enkel gebruikt worden met een enkele parent. -lzw.flavour.not.supported=LZW variant niet ondersteund. -macrosegmentid.must.be.gt.eq.0=macroSegmentId moet groter zijn dan 0 -macrosegmentid.must.be.lt.macrosemgentcount=macroSegmentId moet kleiner zijn dan macroSemgentCount -macrosemgentcount.must.be.gt.0=macroSemgentCount moet groter zijn dan 0 -mapping.code.should.be.1.or.two.bytes.and.not.1=Mapping code moet uit 1 of 2 bytes bestaan, en niet uit {1} -missing.end.tag=Ontbrekende end tag -missing.endcharmetrics.in.1=Ontbrekende EndCharMetrics in {1} -missing.endfontmetrics.in.1=Ontbrekende EndFontMetrics in {1} -missing.endkernpairs.in.1=Ontbrekende EndKernPairs in {1} -missing.startcharmetrics.in.1=Ontbrekende StartCharMetrics in {1} -missing.tag.s.for.ojpeg.compression=Ontbrekende tag(s) voor OJPEG compressie. -multicolumntext.has.no.columns=MultiColumnText heeft geen kolommen -name.end.tag.out.of.place=Naam end tag op verkeerde plaats. -nested.tags.are.not.allowed=Geneste tags zijn niet toegelaten. -no.compatible.encryption.found=Geen compatibele encryptie gevonden -no.error.just.an.old.style.table=Geen fout, enkel een tabel 'oude stijl' -no.font.is.defined=Er is geen enkele font gedefinieerd. -no.glyphs.defined.for.type3.font=Geen gliefen gedefinieerd voor Type3 font -no.valid.column.line.found=Geen geldige kolomlijn gevonden. -no.valid.encryption.mode=Geen geldige encryption mode -not.a.placeable.windows.metafile=Geen placeable windows metafile -not.a.valid.jpeg2000.file=Geen geldig Jpeg2000 bestand -not.a.valid.pfm.file=Geen geldig PFM bestand. -not.a.valid.pkcs.7.object.not.a.sequence=Geen geldig PKCS#7 object - geen sequentie -not.a.valid.pkcs.7.object.not.signed.data=Geen geldig PKCS#7 object - niet gesigneerde data -not.all.annotations.could.be.added.to.the.document.the.document.doesn.t.have.enough.pages=Niet alle annotaties konden toegevoegd worden (het document had niet genoeg pagina's). -not.colorized.typed3.fonts.only.accept.mask.images=Kleurloze Type 3 fonts accepteren enkel mask images. -null.outpustream=OutpuStream null -number.of.entries.in.this.xref.subsection.not.found=Het aantal entries in deze xref subsectie niet gevonden -object.number.of.the.first.object.in.this.xref.subsection.not.found=Object number van het eerste object in deze xref subsectie niet gevonden -ocsp.status.is.revoked=OCSP status is revoked! -ocsp.status.is.unknown=OCSP Status is onbekend! -only.bmp.can.be.wrapped.in.wmf=Alleen een BMP kan in een WMF gewrapt worden. -only.bmp.png.wmf.gif.and.jpeg.images.are.supported.by.the.rtf.writer=Alleen BMP, PNG, WMF, GIF en JPEG afbeeldingen worden ondersteund door RtfWriter2 -only.javascript.actions.are.allowed=Alleen JavaScript acties zijn toegelaten. -only.one.of.artbox.or.trimbox.can.exist.in.the.page=Alleen een enkele ArtBox of TrimBox kan bestaan voor een zelfde pagina. -only.pdflayer.is.accepted=Alleen PdfLayer is toegelaten. -only.rgb.gray.and.cmyk.are.supported.as.alternative.color.spaces=Alleen RGB, Gray en CMYK worden ondersteund als alternatieve color spaces. -open.actions.by.name.are.not.supported=Open actions by name worden niet ondersteund. -operator.1.already.registered=Operator {1} was al geregistreerd -page.1.invalid.for.segment.2.starting.at.3=page {1} ongeldig voor segment {2} beginnend bij {3} -page.attribute.missing=Ontbrekend pagina attribuut. -page.not.found=Pagina niet gevonden. -page.reordering.requires.a.single.parent.in.the.page.tree.call.pdfwriter.setlinearmode.after.open=Pagina herschikking heeft een enkele parent nodig in de page tree. Gebruik PdfWriter.setLinearMode() na het openen van het document. -page.reordering.requires.an.array.with.the.same.size.as.the.number.of.pages=Pagina herschikking heeft een array nodig met een zelfde aantal elementen als het aantal pagina's. -page.reordering.requires.no.page.repetition.page.1.is.repeated=Pagina herschikking laat geen herhaling van pagina's toe. Pagina {1} werd herhaald. -page.reordering.requires.pages.between.1.and.1.found.2=Pagina herschikking gaat voor pagina's tussen 1 en {1}. Jij vraagt naar pagina {2}. -partial.form.flattening.is.not.supported.with.xfa.forms=Gedeeltelijke form flattening is niet ondersteund voor XFA formulieren. -pdf.header.not.found=PDF header niet gevonden. -pdf.startxref.not.found=PDF startxref niet gevonden. -pdfpcells.can.t.have.a.rowspan.gt.1=PdfPCells kunnen geen rowspan groter dan 1 hebben -pdfreader.not.opened.with.owner.password=PdfReader werd niet geopend met het 'owner password' -pdfx.conformance.can.only.be.set.before.opening.the.document=PDFX conformantie kan enkel bepaald worden voor het document geopend wordt. -planar.images.are.not.supported=Planar images worden niet ondersteund. -png.filter.unknown=onbekende PNG filter. -preclose.must.be.called.first=preClose() moet eerst gebeuren. -premature.end.in.1=Vroegtijdig einde van het bestand in {1} -premature.end.of.file=Vroegtijdig einde van het bestand. -premature.eof.while.reading.jpg=Vroegtijdige EOF tijdens het lezen van het JPG bestand. -rebuild.failed.1.original.message.2=Rebuild ging fout: {1}; Oorspronkelijke foutboodschap: {2} -rectanglereadonly.this.rectangle.is.read.only=RectangleReadOnly: dit Rectangle object is alleen-lezen. -reference.pointing.to.reference=Referentie die naar een referentie verwijst. -referring.to.widht.height.of.page.we.havent.seen.yet.1=verwijzing naar een breedte/hoogte van een pagina die we nog niet gezien hebben? {1} -remove.not.supported=remove() niet ondersteund. -reserve.incorrect.column.size=reserve - ongeldige kolom/grootte -resources.do.not.contain.extgstate.entry.unable.to.process.operator.1=De resources bevatten geen ExtGState entry. Het is onmogelijk om de operator {1} te verwerken -root.element.is.not.bookmark.1=Het root element is geen Bookmark: {1} -root.element.is.not.destination=Het root element is geen bestemming. -root.element.is.not.xfdf.1=Het root element is geen xfdf: {1} -rotation.must.be.a.multiple.of.90=De rotatie moet een veelvoud van 90 zijn. -row.coordinate.of.location.must.be.gt.eq.0=rij coordinaat moet groter dan of gelijk aan 0 zijn -scanline.must.begin.with.eol.code.word=Scanline moet beginnen met het EOL code woord. -separations.patterns.and.shadings.are.not.allowed.in.mk.dictionary=Separations, patterns en shadings zijn niet toegelaten in de MK dictionary. -setelement.position.already.taken=setElement - positie al in gebruik -start.marker.missing.in.1=Start marker ontbreekt in {1} -startxref.is.not.followed.by.a.number=startxref wordt niet gevolgd door een nummer. -startxref.not.found=startxref niet gevonden. -stdcf.not.found.encryption=/StdCF niet gevonden (encryption) -stream.could.not.be.compressed.filter.is.not.a.name.or.array=Stream kon niet gecomprimeerd worden: de filter is geen naam of array. -table.1.does.not.exist.in.2=Tabel '{1}' bestaat niet in {2} -tag.1.not.allowed=Tag {1} niet toegelaten. -tagging.must.be.set.before.opening.the.document=Tagging moet bepaald worden voor het document geopend is. -text.cannot.be.null=Text mag niet null zijn. -the.array.must.contain.string.or.pdfannotation=De array moet een String of een PdfAnnotation bevatten. -the.byte.array.is.not.a.recognized.imageformat=De byte array bevat geen gekend afbeeldingsformaat. -the.ccitt.compression.type.must.be.ccittg4.ccittg3.1d.or.ccittg3.2d=Het CCITT compressie type moet CCITTG4, CCITTG3_1D of CCITTG3_2D zijn -the.char.1.doesn.t.belong.in.this.type3.font=Het karakter {1} hoort niet thuis in deze Type3 font -the.char.1.is.not.defined.in.a.type3.font=Het karakter {1} is niet gedefinieerd in de Type3 font -the.character.1.is.illegal.in.codabar=Het karakter '{1}' is ongeldig in codabar. -the.character.1.is.illegal.in.code.39.extended=Het karakter '{1}' is ongeldig in code 39 extended. -the.character.1.is.illegal.in.code.39=Het karakter '{1}' is ongeldig in code 39. -the.cmap.1.does.not.exist.as.a.resource=De cmap {1} bestaat niet als bron. -the.cmap.1.was.not.found=De Cmap {1} werd niet gevonden. -the.compression.1.is.not.supported=Compressie {1} wordt niet ondersteund. -the.document.has.been.closed.you.can.t.add.any.elements=Het document is afgesloten; je kan geen Element objecten meer toevoegen. -the.document.has.no.pages=Het document heeft geen pagina's. -the.document.is.not.open.yet.you.can.only.add.meta.information=Het document is nog niet open; je kan enkel metagegevens toevoegen. -the.document.is.not.open=Het document is niet open. -the.document.is.open.you.can.only.add.elements.with.content=Het document is open; je kan enkel Element objecten met inhoud plaatsen. -the.document.must.be.open.to.import.rtf.documents=Het document moet geopend zijn om RTF documenten te kunnen importeren. -the.document.must.be.open.to.import.rtf.fragments=Het document moet geopend zijn om RTF fragmenten te kunnen importeren. -the.document.was.reused=Het document werd herbruikt. -the.export.and.the.display.array.must.have.the.same.size=De export en display array moeten uit een zelfde aantal elementen bestaan. -the.field.1.already.exists=Het veld {1} bestaat al. -the.field.1.does.not.exist=Het veld {1} bestaat niet. -the.field.1.is.not.a.signature.field=Het veld {1} is geen signature veld. -the.file.does.not.contain.any.valid.image=Het bestand bevat geen geldige afbeelding. -the.filter.1.is.not.supported=De filter {1} wordt niet ondersteund. -the.font.index.for.1.must.be.between.0.and.2.it.was.3=De font index voor {1} moet tussen 0 en {2} liggen. Het was {3}. -the.font.index.for.1.must.be.positive=De font index voor {1} moet positief zijn. -the.image.mask.is.not.a.mask.did.you.do.makemask=De image mask is geen mask. Heb je makeMask() gebruikt? -the.image.must.have.absolute.positioning=Het image object moet een absolute positie hebben. -the.key.1.didn.t.reserve.space.in.preclose=De sleutel {1} reserveerde geen plaats in preClose(). -the.key.1.is.too.big.is.2.reserved.3=De sleutel {1} is te lang. Hij is {2}, terwijl er maar {3} gereserveerd werd -the.layer.1.already.has.a.parent=De layer '{1}' heeft al een parent. -the.matrix.size.must.be.6=De matrix moet uit 6 elementen bestaan. -the.name.1.is.too.long.2.characters=De naam '{1}' is te lang ({2} karakters). -the.new.size.must.be.positive.and.lt.eq.of.the.current.size=De nieuwe waarde moet positief zijn en kleiner dan of gelijk aan de huidige waarde -the.number.of.booleans.in.this.array.doesn.t.correspond.with.the.number.of.fields=Het aantal booleans in deze array stemt niet overeen met het aantal velden. -the.number.of.columns.in.pdfptable.constructor.must.be.greater.than.zero=Het aantal kolommen in de PdfPTable constructor moet groter zijn dan nul. -the.original.document.was.reused.read.it.again.from.file=Het originele document werd herbruikt. Lees het opnieuw in van het bestand. -the.page.number.must.be.gt.eq.1=Het paginanummer moet groter dan of gelijk zijn aan 1. -the.parent.has.already.another.function=De parent heeft al een andere functie. -the.photometric.1.is.not.supported=De photometric {1} wordt niet ondersteund. -the.resource.cjkencodings.properties.does.not.contain.the.encoding.1=Het bronbestand cjkencodings.properties bevat de encoding {1} niet -the.smask.key.is.not.allowed.in.images=De /SMask key is niet toegelaten in afbeeldingen. -the.spot.color.must.be.the.same.only.the.tint.can.vary=De spot color moet het zelfde zijn, alleen de tint mag varieren. -the.stack.is.empty=De stack is leeg. -the.structure.has.kids=De structuur heeft substructuren (kids). -the.table.width.must.be.greater.than.zero=De breedte van de tabel moet groter zijn dan nul. -the.template.can.not.be.null=De template mag niet null zijn. -the.text.is.too.big=De tekst is te lang. -the.text.length.must.be.even=de lengte van de tekst mag niet oneven zijn. -the.two.barcodes.must.be.composed.externally=De twee barcodes moet extern samengesteld worden. -the.update.dictionary.has.less.keys.than.required=De update dictionary heeft minder sleutels dan noodzakelijk is. -the.url.of.the.image.is.missing=De URL van de afbeelding ontbreekt. -the.value.has.to.be.true.of.false.instead.of.1=De waarde moet 'true' of 'false' zijn, in plaats van '{1}'. -the.width.cannot.be.set=De breedte kan niet gedefinieerd worden. -the.widths.array.in.pdfptable.constructor.can.not.be.null=De array met de breedtes in de PdfPTable constructor kan niet null zijn. -the.widths.array.in.pdfptable.constructor.can.not.have.zero.length=De array met de breedtes in de PdfPTable constructor moet minstens een element hebben. -the.writer.in.pdfcontentbyte.is.null=De writer in PdfContentByte is null. -there.are.illegal.characters.for.barcode.128.in.1=Er zitten ongeldige karakters voor barcode 128 in '{1}'. -this.acrofields.instance.is.read.only=Deze instantie van AcroFields is read only. -this.image.can.not.be.an.image.mask=Deze afbeelding kan geen image mask zijn. -this.largeelement.has.already.been.added.to.the.document=Dit LargeElement object werd al toegevoegd aan het Document. -this.page.cannot.be.replaced.new.content.was.already.added=Deze pagina kan niet vervangen worden: nieuwe inhoud werd al toegevoegd -this.pkcs.7.object.has.multiple.signerinfos.only.one.is.supported.at.this.time=Dit PKCS#7 object heeft meerdere SignerInfos - slechts een enkel is toegelaten -tiff.5.0.style.lzw.codes.are.not.supported=TIFF 5.0-achtige LZW codes worden niet ondersteund. -tiff.fill.order.tag.must.be.either.1.or.2=TIFF_FILL_ORDER tag moet ofwel 1, ofwel 2 zijn. -tiles.are.not.supported=Tiles worden niet ondersteund. -title.cannot.be.null=De titel kan niet null zijn. -token.obj.expected=Token 'obj' verwacht. -trailer.not.found=trailer niet gevonden. -transparency.is.not.allowed.ca.eq.1=Transparentie is niet toegelaten: /ca = {1} -transparency.length.must.be.equal.to.2.with.ccitt.images=De transparency lengte moet gelijk zijn aan 2 voor CCITT afbeeldingen. -transparency.length.must.be.equal.to.componentes.2=De transparentie lengte moet gelijk zijn aan (components * 2) -trying.to.create.a.table.without.rows=Je probeert een tabel zonder rijen te maken. -tsa.1.failed.to.return.time.stamp.token.2=TSA '{1}' slaagde er niet in een time stamp token terug te geven: {2} -two.byte.arrays.are.needed.if.the.type1.font.is.embedded=Er zijn twee byte arrays nodig als de Type1 font ingebed wordt. -type3.font.used.with.the.wrong.pdfwriter=Type3 font gebruikt met het verkeerde PdfWriter object -types.is.null=types is null -unbalanced.begin.end.marked.content.operators=Ongebalanceerde begin/einde operatoren voor marked content. -unbalanced.begin.end.text.operators=Ongebalanceerde begin/einde operatoren voor tekst. -unbalanced.layer.operators=Ongebalanceerde operatoren voor layers. -unbalanced.marked.content.operators=Ongebalanceerde marked content operatoren. -unbalanced.save.restore.state.operators=Ongebalanceerde save/restore state operatoren. -unexpected.end.of.file=Onverwacht einde van het bestand. -unexpected.eof=Onverwachte EOF -unexpected.gt.gt=Onverwachte '>>' -unexpected.close.bracket=Onverwachter ']' -unknown.color.format.must.be.rgb.or.rrggbb=Onbekend formaat voor kleur. Moet #RGB of #RRGGBB zijn -unknown.encryption.type.r.eq.1=Onbekend encryptie type R = {1} -unknown.encryption.type.v.eq.1=Onbekend encryptie type V = {1} -unknown.filter.1=Onbekende filter: {1} -unknown.hash.algorithm.1=Onbekend Hash Algoritme {1} -unknown.key.algorithm.1=Onbekend Key Algoritme {1} -unknown.object.at.k.1=Onbekend object voor /K {1} -unknown=onbekend -unsupported.box.size.eq.eq.0=Ongeldige box size == 0 -unsupported.in.this.context.use.pdfstamper.addannotation=Niet ondersteund in deze context. Gebruik PdfStamper.addAnnotation() -use.pdfstamper.getundercontent.or.pdfstamper.getovercontent=Gebruik PdfStamper.getUnderContent() of PdfStamper.getOverContent() -use.pdfstamper.setthumbnail=Gebruik PdfStamper.setThumbnail(). -use.setpageaction.pdfname.actiontype.pdfaction.action.int.page=Gebruik setPageAction(PdfName actionType, PdfAction action, int page) -userunit.should.be.a.value.between.1.and.75000=UserUnit moet een waarde zijn tussen 1 en 75000. -verticaltext.go.with.simulate.eq.eq.false.and.text.eq.eq.null=VerticalText.go met simulate==false en text==null. -while.removing.wmf.placeable.header=tijdens het verwijderen van een wmf positioneerbare header -writelength.can.only.be.called.after.output.of.the.stream.body=writeLength() kan alleen opgeroepen worden na output van de stream body. -writelength.can.only.be.called.in.a.contructed.pdfstream.inputstream.pdfwriter=writeLength() kan alleen opgeroepen worden in een aldus aangemaakte stream: PdfStream(InputStream,PdfWriter). -wrong.number.of.columns=Verkeerd aantal kolommen. -xref.infinite.loop=Er is een eindeloos lus gedetecteerd in de xref-tabel. -xref.subsection.not.found=xref subsectie niet gevonden -xstep.or.ystep.can.not.be.zero=XStep of YStep kan niet nul zijn. -you.can.only.add.a.writer.to.a.pdfdocument.once=Je kan een writer slecht een enkele keer toevoegen aan een PdfDocument. -you.can.only.add.cells.to.rows.no.objects.of.type.1=Je kan enkel cellen toevoegen aan rijen, geen objecten van type {1} -you.can.only.add.objects.that.implement.the.element.interface=Enkel objecten die de Element interface implementeren kunnen toegevoegd worden. -you.can.t.add.a.1.to.a.section=Je kan geen {1} toevoegen aan een Section. -you.can.t.add.an.element.of.type.1.to.a.simplecell=Je kan geen element van type {1} toevoegen aan een SimpleCell. -you.can.t.add.cells.to.a.table.directly.add.them.to.a.row.first=Je kan geen cellen toevoegen aan een tabel, zonder ze eerst aan een rij toe te voegen. -you.can.t.add.listitems.rows.or.cells.to.a.cell=Je kan geen lijst items, rijen of cellen toevoegen aan een cell. -you.can.t.add.one.row.to.another.row=Je kan rijen niet aan rijen toevoegen. -you.can.t.have.1.pages.on.one.page.minimum.2.maximum.8=Je kan geen {1} pagina's op ��n blad plaatsen (minimum 2; maximum 8). -you.can.t.set.the.initial.leading.if.the.document.is.already.open=Je kan geen initial leading bepalen als het document al open is. -you.can.t.split.this.document.at.page.1.there.is.no.such.page=Je kan dit document niet splitsen op pagina {1}; Die pagina bestaat niet. -you.can.t.translate.a.negative.number.into.an.alphabetical.value=Je kan een negatieve waarde niet omzetten naar een alfabetische waarde. -you.have.to.consolidate.the.named.destinations.of.your.reader=Je moet de named destinations van je reader object consolideren. -you.have.to.define.a.boolean.array.for.this.collection.sort.dictionary=Je moet een boolean array bepalen voor deze collection sort dictionary. -you.have.used.the.wrong.constructor.for.this.fieldpositioningevents.class=Je gebruikte de verkeerde constructor van de FieldPositioningEvents class. -you.must.set.a.value.before.adding.a.prefix=Je moet een waarde toevoegen vooraleer je een prefix toevoegt. -you.need.a.single.boolean.for.this.collection.sort.dictionary=Je hebt een enkele boolean nodig voor deze collection sort dictionary. diff --git a/openpdf/src/main/java/com/lowagie/text/error_messages/pt.lng b/openpdf/src/main/java/com/lowagie/text/error_messages/pt.lng deleted file mode 100644 index 56cfd7d2b..000000000 --- a/openpdf/src/main/java/com/lowagie/text/error_messages/pt.lng +++ /dev/null @@ -1,8 +0,0 @@ -# Portuguese - Portugal -1.at.file.pointer.2={1} na posição de ficheiro {2} -error.reading.string=Erro na leitura de string. -fdf.header.not.found=Início de FDF não encontrado. -greaterthan.not.expected='>' inesperado -pdf.header.not.found=Início de PDF não encontrado. -pdf.startxref.not.found=startxref de PDF não encontrado. -xref.infinite.loop=Um loop infinito foi detectado na tabela xref. diff --git a/openpdf/src/main/java/com/lowagie/text/pdf/PdfWriter.java b/openpdf/src/main/java/com/lowagie/text/pdf/PdfWriter.java index 790c4e6e6..011bd9140 100644 --- a/openpdf/src/main/java/com/lowagie/text/pdf/PdfWriter.java +++ b/openpdf/src/main/java/com/lowagie/text/pdf/PdfWriter.java @@ -95,10 +95,9 @@ /** * A DocWriter class for PDF. - *

- * When this PdfWriter is added - * to a certain PdfDocument, the PDF representation of every Element - * added to this Document will be written to the outputstream.

+ *

+ * When this PdfWriter is added to a certain PdfDocument, the PDF representation of every + * Element added to this Document will be written to the outputstream.

*/ public class PdfWriter extends DocWriter implements @@ -113,157 +112,40 @@ public class PdfWriter extends DocWriter implements /** * The highest generation number possible. - * @since iText 2.1.6 + * + * @since iText 2.1.6 */ public static final int GENERATION_MAX = 65535; - + // INNER CLASSES /** * This class generates the structure of a PDF document. - *

- * This class covers the third section of Chapter 5 in the 'Portable Document Format - * Reference Manual version 1.3' (page 55-60). It contains the body of a PDF document - * (section 5.14) and it can also generate a Cross-reference Table (section 5.15). + *

+ * This class covers the third section of Chapter 5 in the 'Portable Document Format Reference Manual version 1.3' + * (page 55-60). It contains the body of a PDF document (section 5.14) and it can also generate a Cross-reference + * Table (section 5.15). * - * @see PdfWriter - * @see PdfObject - * @see PdfIndirectObject + * @see PdfWriter + * @see PdfObject + * @see PdfIndirectObject */ - public static class PdfBody { - // inner classes - - /** - * PdfCrossReference is an entry in the PDF Cross-Reference table. - */ - - public static class PdfCrossReference implements Comparable { - - /** - * String template for cross-reference entry PDF representation. - * - * @see Formatter - */ - private static final String CROSS_REFERENCE_ENTRY_FORMAT = "%010d %05d %c \n"; - - // membervariables - private int type; - - /** Byte offset in the PDF file. */ - private long offset; - - private int refnum; - /** generation of the object. */ - private int generation; - - // constructors - /** - * Constructs a cross-reference element for a PdfIndirectObject. - * @param refnum the reference number - * @param offset byte offset of the object - * @param generation generation number of the object - */ - - public PdfCrossReference(int refnum, long offset, int generation) { - type = 0; - this.offset = offset; - this.refnum = refnum; - this.generation = generation; - } - - /** - * Constructs a cross-reference element for a PdfIndirectObject. - * @param refnum the reference number - * @param offset byte offset of the object - */ - - public PdfCrossReference(int refnum, long offset) { - type = 1; - this.offset = offset; - this.refnum = refnum; - this.generation = 0; - } - - public PdfCrossReference(int type, int refnum, long offset, int generation) { - this.type = type; - this.offset = offset; - this.refnum = refnum; - this.generation = generation; - } - - int getRefnum() { - return refnum; - } - - /** - * Writes PDF representation of cross-reference entry to passed output stream. - * - * @param os Output stream this entry to write to - * @throws IOException If any I/O error occurs - */ - public void toPdf(OutputStream os) throws IOException { - // TODO: are generation number and 'In use' keyword bound that way? - final char inUse = generation == GENERATION_MAX ? 'f' : 'n'; - os.write(getISOBytes(String.format(CROSS_REFERENCE_ENTRY_FORMAT, offset, generation, inUse))); - } - - /** - * Writes PDF syntax to the OutputStream - * @param midSize the mid size - * @param os the OutputStream - * @throws IOException on error - */ - public void toPdf(int midSize, OutputStream os) throws IOException { - os.write((byte)type); - while (--midSize >= 0) - os.write((byte)((offset >>> (8 * midSize)) & 0xff)); - os.write((byte)((generation >>> 8) & 0xff)); - os.write((byte)(generation & 0xff)); - } - - /** - * Compares current {@link PdfCrossReference entry} with passed {@code reference} by PDF object number. - */ - @Override - public int compareTo(final PdfCrossReference reference) { - return Integer.compare(refnum, reference.refnum); - } - - /** - * Checks if two entries are equal if their PDF object numbers are equal. - * - * @param obj Another cross-reference entry - * @return If null, not of type {@link PdfCrossReference} or object numbers are not equal, - * returns false; true otherwise - */ - @Override - public boolean equals(Object obj) { - if (!(obj instanceof PdfCrossReference)) { - return false; - } - - final PdfCrossReference other = (PdfCrossReference)obj; - return refnum == other.refnum; - } - - @Override - public int hashCode() { - return refnum; - } - } - private static final int OBJSINSTREAM = 200; // membervariables - /** array containing the cross-reference table of the normal objects. */ - private TreeSet xrefs; + /** + * array containing the cross-reference table of the normal objects. + */ + private final TreeSet xrefs; private int refnum; - /** the current byte position in the body. */ + /** + * the current byte position in the body. + */ private long position; - private PdfWriter writer; + private final PdfWriter writer; private ByteBuffer index; private ByteBuffer streamObjects; private int currentObjNum; @@ -273,6 +155,7 @@ public int hashCode() { /** * Constructs a new PdfBody. + * * @param writer */ PdfBody(PdfWriter writer) { @@ -290,8 +173,9 @@ void setRefnum(int refnum) { } private PdfWriter.PdfBody.PdfCrossReference addToObjStm(PdfObject obj, int nObj) throws IOException { - if (numObj >= OBJSINSTREAM) + if (numObj >= OBJSINSTREAM) { flushObjStm(); + } if (index == null) { index = new ByteBuffer(); streamObjects = new ByteBuffer(); @@ -310,8 +194,9 @@ private PdfWriter.PdfBody.PdfCrossReference addToObjStm(PdfObject obj, int nObj) } private void flushObjStm() throws IOException { - if (numObj == 0) + if (numObj == 0) { return; + } int first = index.size(); index.append(streamObjects); PdfStream stream = new PdfStream(index.toByteArray()); @@ -327,18 +212,15 @@ private void flushObjStm() throws IOException { /** * Adds a PdfObject to the body. - *

- * This methods creates a PdfIndirectObject with a - * certain number, containing the given PdfObject. - * It also adds a PdfCrossReference for this object - * to an ArrayList that will be used to build the - * Cross-reference Table. + *

+ * This methods creates a PdfIndirectObject with a certain number, containing the given + * PdfObject. It also adds a PdfCrossReference for this object to an + * ArrayList that will be used to build the Cross-reference Table. * - * @param object a PdfObject - * @return a PdfIndirectObject + * @param object a PdfObject + * @return a PdfIndirectObject * @throws IOException */ - PdfIndirectObject add(PdfObject object) throws IOException { return add(object, getIndirectReferenceNumber()); } @@ -349,9 +231,9 @@ PdfIndirectObject add(PdfObject object, boolean inObjStm) throws IOException { /** * Gets a PdfIndirectReference for an object that will be created in the future. + * * @return a PdfIndirectReference */ - PdfIndirectReference getPdfIndirectReference() { return new PdfIndirectReference(0, getIndirectReferenceNumber()); } @@ -363,21 +245,18 @@ int getIndirectReferenceNumber() { } /** - * Adds a PdfObject to the body given an already existing - * PdfIndirectReference. - *

+ * Adds a PdfObject to the body given an already existing PdfIndirectReference. + *

* This methods creates a PdfIndirectObject with the number given by * ref, containing the given PdfObject. - * It also adds a PdfCrossReference for this object - * to an ArrayList that will be used to build the - * Cross-reference Table. + * It also adds a PdfCrossReference for this object to an ArrayList that will be used + * to build the Cross-reference Table. * - * @param object a PdfObject - * @param ref a PdfIndirectReference - * @return a PdfIndirectObject + * @param object a PdfObject + * @param ref a PdfIndirectReference + * @return a PdfIndirectObject * @throws IOException */ - PdfIndirectObject add(PdfObject object, PdfIndirectReference ref) throws IOException { return add(object, ref.getNumber()); } @@ -399,8 +278,7 @@ PdfIndirectObject add(PdfObject object, int refNumber, boolean inObjStm) throws xrefs.add(pxref); } return indirect; - } - else { + } else { PdfIndirectObject indirect = new PdfIndirectObject(refNumber, object, writer); PdfCrossReference pxref = new PdfCrossReference(refNumber, position); if (!xrefs.add(pxref)) { @@ -416,9 +294,8 @@ PdfIndirectObject add(PdfObject object, int refNumber, boolean inObjStm) throws /** * Returns the offset of the Cross-Reference table. * - * @return an offset + * @return an offset */ - long offset() { return position; } @@ -426,15 +303,15 @@ long offset() { /** * Returns the total number of objects contained in the CrossReferenceTable of this Body. * - * @return a number of objects + * @return a number of objects */ - int size() { return Math.max((xrefs.last()).getRefnum() + 1, refnum); } /** * Returns the CrossReferenceTable of the Body. + * * @param os * @param root * @param info @@ -444,7 +321,8 @@ int size() { * @throws IOException */ - void writeCrossReferenceTable(OutputStream os, PdfIndirectReference root, PdfIndirectReference info, PdfIndirectReference encryption, PdfObject fileID, int prevxref) throws IOException { + void writeCrossReferenceTable(OutputStream os, PdfIndirectReference root, PdfIndirectReference info, + PdfIndirectReference encryption, PdfObject fileID, int prevxref) throws IOException { int refNumber = 0; // Old-style xref tables limit object offsets to 10 digits boolean useNewXrefFormat = writer.isFullCompression() || position > 9_999_999_999L; @@ -459,9 +337,9 @@ void writeCrossReferenceTable(OutputStream os, PdfIndirectReference root, PdfInd ArrayList sections = new ArrayList<>(); for (PdfCrossReference xref1 : xrefs) { entry = xref1; - if (first + len == entry.getRefnum()) + if (first + len == entry.getRefnum()) { ++len; - else { + } else { sections.add(first); sections.add(len); first = entry.getRefnum(); @@ -480,21 +358,21 @@ void writeCrossReferenceTable(OutputStream os, PdfIndirectReference root, PdfInd entry.toPdf(mid, buf); } PdfStream xr = new PdfStream(buf.toByteArray()); - buf = null; xr.flateCompress(writer.getCompressionLevel()); xr.putAll(trailer); xr.put(PdfName.W, new PdfArray(new int[]{1, mid, 2})); xr.put(PdfName.TYPE, PdfName.XREF); PdfArray idx = new PdfArray(); - for (Integer section : sections) idx.add(new PdfNumber(section)); + for (Integer section : sections) { + idx.add(new PdfNumber(section)); + } xr.put(PdfName.INDEX, idx); PdfEncryption enc = writer.crypto; writer.crypto = null; PdfIndirectObject indirect = new PdfIndirectObject(refNumber, xr, writer); indirect.writeTo(writer.getOs()); writer.crypto = enc; - } - else { + } else { os.write(getISOBytes("xref\n")); Iterator i = xrefs.iterator(); for (int k = 0; k < sections.size(); k += 2) { @@ -513,13 +391,140 @@ void writeCrossReferenceTable(OutputStream os, PdfIndirectReference root, PdfInd trailer.toPdf(writer, os); } } + + // inner classes + + /** + * PdfCrossReference is an entry in the PDF Cross-Reference table. + */ + public static class PdfCrossReference implements Comparable { + + /** + * String template for cross-reference entry PDF representation. + * + * @see Formatter + */ + private static final String CROSS_REFERENCE_ENTRY_FORMAT = "%010d %05d %c \n"; + + // membervariables + private final int type; + + /** + * Byte offset in the PDF file. + */ + private final long offset; + + private final int refnum; + /** + * generation of the object. + */ + private final int generation; + + // constructors + + /** + * Constructs a cross-reference element for a PdfIndirectObject. + * + * @param refnum the reference number + * @param offset byte offset of the object + * @param generation generation number of the object + */ + public PdfCrossReference(int refnum, long offset, int generation) { + type = 0; + this.offset = offset; + this.refnum = refnum; + this.generation = generation; + } + + /** + * Constructs a cross-reference element for a PdfIndirectObject. + * + * @param refnum the reference number + * @param offset byte offset of the object + */ + public PdfCrossReference(int refnum, long offset) { + type = 1; + this.offset = offset; + this.refnum = refnum; + this.generation = 0; + } + + public PdfCrossReference(int type, int refnum, long offset, int generation) { + this.type = type; + this.offset = offset; + this.refnum = refnum; + this.generation = generation; + } + + int getRefnum() { + return refnum; + } + + /** + * Writes PDF representation of cross-reference entry to passed output stream. + * + * @param os Output stream this entry to write to + * @throws IOException If any I/O error occurs + */ + public void toPdf(OutputStream os) throws IOException { + // TODO: are generation number and 'In use' keyword bound that way? + final char inUse = generation == GENERATION_MAX ? 'f' : 'n'; + os.write(getISOBytes(String.format(CROSS_REFERENCE_ENTRY_FORMAT, offset, generation, inUse))); + } + + /** + * Writes PDF syntax to the OutputStream + * + * @param midSize the mid size + * @param os the OutputStream + * @throws IOException on error + */ + public void toPdf(int midSize, OutputStream os) throws IOException { + os.write((byte) type); + int thisMidSize = midSize; + while (--thisMidSize >= 0) { + os.write((byte) ((offset >>> (8 * thisMidSize)) & 0xff)); + } + os.write((byte) ((generation >>> 8) & 0xff)); + os.write((byte) (generation & 0xff)); + } + + /** + * Compares current {@link PdfCrossReference entry} with passed {@code reference} by PDF object number. + */ + @Override + public int compareTo(final PdfCrossReference reference) { + return Integer.compare(refnum, reference.refnum); + } + + /** + * Checks if two entries are equal if their PDF object numbers are equal. + * + * @param obj Another cross-reference entry + * @return If null, not of type {@link PdfCrossReference} or object numbers are not equal, returns false; + * true otherwise + */ + @Override + public boolean equals(Object obj) { + if (!(obj instanceof PdfCrossReference other)) { + return false; + } + + return refnum == other.refnum; + } + + @Override + public int hashCode() { + return refnum; + } + } } /** * PdfTrailer is the PDF Trailer object. - *

- * This object is described in the 'Portable Document Format Reference Manual version 1.3' - * section 5.16 (page 59-60). + *

+ * This object is described in the 'Portable Document Format Reference Manual version 1.3' section 5.16 (page + * 59-60). */ static class PdfTrailer extends PdfDictionary { @@ -529,34 +534,40 @@ static class PdfTrailer extends PdfDictionary { /** * Constructs a PDF-Trailer. * - * @param size the number of entries in the PdfCrossReferenceTable - * @param root an indirect reference to the root of the PDF document - * @param info an indirect reference to the info object of the PDF document + * @param size the number of entries in the PdfCrossReferenceTable + * @param root an indirect reference to the root of the PDF document + * @param info an indirect reference to the info object of the PDF document * @param encryption * @param fileID * @param prevxref */ - PdfTrailer(int size, PdfIndirectReference root, PdfIndirectReference info, PdfIndirectReference encryption, PdfObject fileID, int prevxref) { + PdfTrailer(int size, PdfIndirectReference root, PdfIndirectReference info, PdfIndirectReference encryption, + PdfObject fileID, int prevxref) { put(PdfName.SIZE, new PdfNumber(size)); put(PdfName.ROOT, root); if (info != null) { put(PdfName.INFO, info); } - if (encryption != null) + if (encryption != null) { put(PdfName.ENCRYPT, encryption); - if (fileID != null) + } + if (fileID != null) { put(PdfName.ID, fileID); - if (prevxref > 0) + } + if (prevxref > 0) { put(PdfName.PREV, new PdfNumber(prevxref)); + } } /** * Returns the PDF representation of this PdfObject. + * * @param writer * @param os * @throws IOException */ + @Override public void toPdf(PdfWriter writer, OutputStream os) throws IOException { os.write(getISOBytes("trailer\n")); super.toPdf(null, os); @@ -576,12 +587,12 @@ protected PdfWriter() { /** * Constructs a PdfWriter. - *

+ *

* Remark: a PdfWriter can only be constructed by calling the method * getInstance(Document document, OutputStream os). * - * @param document The PdfDocument that has to be written - * @param os The OutputStream the writer has to write to. + * @param document The PdfDocument that has to be written + * @param os The OutputStream the writer has to write to. */ protected PdfWriter(PdfDocument document, OutputStream os) { @@ -594,15 +605,14 @@ protected PdfWriter(PdfDocument document, OutputStream os) { /** * Use this method to get an instance of the PdfWriter. * - * @param document The Document that has to be written - * @param os The OutputStream the writer has to write to. - * @return a new PdfWriter - * - * @throws DocumentException on error + * @param document The Document that has to be written + * @param os The OutputStream the writer has to write to. + * @return a new PdfWriter + * @throws DocumentException on error */ public static PdfWriter getInstance(Document document, OutputStream os) - throws DocumentException { + throws DocumentException { PdfDocument pdf = new PdfDocument(); pdf.setTextRenderingOptions(document.getTextRenderingOptions()); document.addDocListener(pdf); @@ -614,15 +624,15 @@ public static PdfWriter getInstance(Document document, OutputStream os) /** * Use this method to get an instance of the PdfWriter. * - * @return a new PdfWriter * @param document The Document that has to be written - * @param os The OutputStream the writer has to write to. + * @param os The OutputStream the writer has to write to. * @param listener A DocListener to pass to the PdfDocument. + * @return a new PdfWriter * @throws DocumentException on error */ public static PdfWriter getInstance(Document document, OutputStream os, DocListener listener) - throws DocumentException { + throws DocumentException { PdfDocument pdf = new PdfDocument(); pdf.setTextRenderingOptions(document.getTextRenderingOptions()); pdf.addDocListener(listener); @@ -634,11 +644,14 @@ public static PdfWriter getInstance(Document document, OutputStream os, DocListe // the PdfDocument instance - /** the pdfdocument object. */ + /** + * the pdfdocument object. + */ protected PdfDocument pdf; /** * Gets the PdfDocument associated with this writer. + * * @return the PdfDocument */ @@ -647,8 +660,9 @@ PdfDocument getPdfDocument() { } /** - * Use this method to get the info dictionary if you want to - * change it directly (add keys and values to the info dictionary). + * Use this method to get the info dictionary if you want to change it directly (add keys and values to the info + * dictionary). + * * @return the info dictionary */ public PdfDictionary getInfo() { @@ -657,9 +671,9 @@ public PdfDictionary getInfo() { /** * Use this method to get the current vertical page position. - * @param ensureNewLine Tells whether a new line shall be enforced. This may cause side effects - * for elements that do not terminate the lines they've started because those lines will get - * terminated. + * + * @param ensureNewLine Tells whether a new line shall be enforced. This may cause side effects for elements that do + * not terminate the lines they've started because those lines will get terminated. * @return The current vertical page position. */ public float getVerticalPosition(boolean ensureNewLine) { @@ -667,64 +681,71 @@ public float getVerticalPosition(boolean ensureNewLine) { } /** - * Sets the initial leading for the PDF document. - * This has to be done before the document is opened. - * @param leading the initial leading - * @since 2.1.6 - * @throws DocumentException if you try setting the leading after the document was opened. + * Sets the initial leading for the PDF document. This has to be done before the document is opened. + * + * @param leading the initial leading + * @throws DocumentException if you try setting the leading after the document was opened. + * @since 2.1.6 */ public void setInitialLeading(float leading) throws DocumentException { - if (open) - throw new DocumentException(MessageLocalization.getComposedMessage("you.can.t.set.the.initial.leading.if.the.document.is.already.open")); + if (open) { + throw new DocumentException(MessageLocalization.getComposedMessage( + "you.can.t.set.the.initial.leading.if.the.document.is.already.open")); + } pdf.setLeading(leading); } - + // the PdfDirectContentByte instances -/* - * You should see Direct Content as a canvas on which you can draw - * graphics and text. One canvas goes on top of the page (getDirectContent), - * the other goes underneath (getDirectContentUnder). - * You can always the same object throughout your document, - * even if you have moved to a new page. Whatever you add on - * the canvas will be displayed on top or under the current page. - */ + /* + * You should see Direct Content as a canvas on which you can draw + * graphics and text. One canvas goes on top of the page (getDirectContent), + * the other goes underneath (getDirectContentUnder). + * You can always the same object throughout your document, + * even if you have moved to a new page. Whatever you add on + * the canvas will be displayed on top or under the current page. + */ - /** The direct content in this document. */ + /** + * The direct content in this document. + */ protected PdfContentByte directContent; - /** The direct content under in this document. */ + /** + * The direct content under in this document. + */ protected PdfContentByte directContentUnder; /** - * Use this method to get the direct content for this document. - * There is only one direct content, multiple calls to this method - * will allways retrieve the same object. + * Use this method to get the direct content for this document. There is only one direct content, multiple calls to + * this method will allways retrieve the same object. + * * @return the direct content */ public PdfContentByte getDirectContent() { - if (!open) + if (!open) { throw new RuntimeException(MessageLocalization.getComposedMessage("the.document.is.not.open")); + } return directContent; } /** - * Use this method to get the direct content under for this document. - * There is only one direct content, multiple calls to this method - * will always retrieve the same object. + * Use this method to get the direct content under for this document. There is only one direct content, multiple + * calls to this method will always retrieve the same object. + * * @return the direct content */ public PdfContentByte getDirectContentUnder() { - if (!open) + if (!open) { throw new RuntimeException(MessageLocalization.getComposedMessage("the.document.is.not.open")); + } return directContentUnder; } /** - * Resets all the direct contents to empty. - * This happens when a new page is started. + * Resets all the direct contents to empty. This happens when a new page is started. */ void resetContent() { directContent.reset(); @@ -733,19 +754,22 @@ void resetContent() { // PDF body -/* - * A PDF file has 4 parts: a header, a body, a cross-reference table, and a trailer. - * The body contains all the PDF objects that make up the PDF document. - * Each element gets a reference (a set of numbers) and the byte position of - * every object is stored in the cross-reference table. - * Use these methods only if you know what you're doing. - */ + /* + * A PDF file has 4 parts: a header, a body, a cross-reference table, and a trailer. + * The body contains all the PDF objects that make up the PDF document. + * Each element gets a reference (a set of numbers) and the byte position of + * every object is stored in the cross-reference table. + * Use these methods only if you know what you're doing. + */ - /** body of the PDF document */ + /** + * body of the PDF document + */ protected PdfBody body; /** * Adds the local destinations to the body of the document. + * * @param dest the HashMap containing the destinations * @throws IOException on error */ @@ -756,98 +780,95 @@ void addLocalDestinations(TreeMap dest) throws IOException { String name = (String) entry.getKey(); Object[] obj = (Object[]) entry.getValue(); PdfDestination destination = (PdfDestination) obj[2]; - if (obj[1] == null) + if (obj[1] == null) { obj[1] = getPdfIndirectReference(); - if (destination == null) + } + if (destination == null) { addToBody(new PdfString("invalid_" + name), (PdfIndirectReference) obj[1]); - else + } else { addToBody(destination, (PdfIndirectReference) obj[1]); + } } } /** - * Use this method to add a PDF object to the PDF body. - * Use this method only if you know what you're doing! + * Use this method to add a PDF object to the PDF body. Use this method only if you know what you're doing! + * * @param object the PDF object to add * @return a PdfIndirectObject * @throws IOException thrown when an I/O operation fails */ public PdfIndirectObject addToBody(PdfObject object) throws IOException { - PdfIndirectObject iobj = body.add(object); - return iobj; + return body.add(object); } /** - * Use this method to add a PDF object to the PDF body. - * Use this method only if you know what you're doing! - * @param object the PDF object to add + * Use this method to add a PDF object to the PDF body. Use this method only if you know what you're doing! + * + * @param object the PDF object to add * @param inObjStm a boolean * @return a PdfIndirectObject * @throws IOException thrown when an I/O operation fails */ public PdfIndirectObject addToBody(PdfObject object, boolean inObjStm) throws IOException { - PdfIndirectObject iobj = body.add(object, inObjStm); - return iobj; + return body.add(object, inObjStm); } /** - * Use this method to add a PDF object to the PDF body. - * Use this method only if you know what you're doing! + * Use this method to add a PDF object to the PDF body. Use this method only if you know what you're doing! + * * @param object the object to add - * @param ref the IndirectReference of that object + * @param ref the IndirectReference of that object * @return a PdfIndirectObject * @throws IOException thrown when an I/O operation fails */ public PdfIndirectObject addToBody(PdfObject object, PdfIndirectReference ref) throws IOException { - PdfIndirectObject iobj = body.add(object, ref); - return iobj; + return body.add(object, ref); } /** - * Use this method to add a PDF object to the PDF body. - * Use this method only if you know what you're doing! - * @param object the object to add - * @param ref the indirect reference + * Use this method to add a PDF object to the PDF body. Use this method only if you know what you're doing! + * + * @param object the object to add + * @param ref the indirect reference * @param inObjStm a boolean * @return a PdfIndirectObject * @throws IOException thrown when an I/O operation fails */ - public PdfIndirectObject addToBody(PdfObject object, PdfIndirectReference ref, boolean inObjStm) throws IOException { - PdfIndirectObject iobj = body.add(object, ref, inObjStm); - return iobj; + public PdfIndirectObject addToBody(PdfObject object, PdfIndirectReference ref, boolean inObjStm) + throws IOException { + return body.add(object, ref, inObjStm); } /** - * Use this method to add a PDF object to the PDF body. - * Use this method only if you know what you're doing! - * @param object the object to add + * Use this method to add a PDF object to the PDF body. Use this method only if you know what you're doing! + * + * @param object the object to add * @param refNumber the reference number * @return a PdfIndirectObject * @throws IOException thrown when an I/O operation fails */ public PdfIndirectObject addToBody(PdfObject object, int refNumber) throws IOException { - PdfIndirectObject iobj = body.add(object, refNumber); - return iobj; + return body.add(object, refNumber); } /** - * Use this method to add a PDF object to the PDF body. - * Use this method only if you know what you're doing! - * @param object the object to add + * Use this method to add a PDF object to the PDF body. Use this method only if you know what you're doing! + * + * @param object the object to add * @param refNumber the reference number - * @param inObjStm a boolean + * @param inObjStm a boolean * @return a PdfIndirectObject * @throws IOException thrown when an I/O operation fails */ public PdfIndirectObject addToBody(PdfObject object, int refNumber, boolean inObjStm) throws IOException { - PdfIndirectObject iobj = body.add(object, refNumber, inObjStm); - return iobj; + return body.add(object, refNumber, inObjStm); } /** - * Use this to get an PdfIndirectReference for an object that - * will be created in the future. - * Use this method only if you know what you're doing! + * Use this to get an PdfIndirectReference for an object that will be created in the future. Use this + * method only if you know what you're doing! + * * @return the PdfIndirectReference */ @@ -861,39 +882,38 @@ int getIndirectReferenceNumber() { /** * Returns the outputStreamCounter. + * * @return the outputStreamCounter */ OutputStreamCounter getOs() { return os; } - // PDF Catalog -/* - * The Catalog is also called the root object of the document. - * Whereas the Cross-Reference maps the objects number with the - * byte offset so that the viewer can find the objects, the - * Catalog tells the viewer the numbers of the objects needed - * to render the document. - */ + /* + * The Catalog is also called the root object of the document. + * Whereas the Cross-Reference maps the objects number with the + * byte offset so that the viewer can find the objects, the + * Catalog tells the viewer the numbers of the objects needed + * to render the document. + */ - protected PdfDictionary getCatalog(PdfIndirectReference rootObj) - { + protected PdfDictionary getCatalog(PdfIndirectReference rootObj) { PdfDictionary catalog = pdf.getCatalog(rootObj); // [F12] tagged PDF if (tagged) { try { getStructureTreeRoot().buildTree(); - } - catch (Exception e) { + } catch (Exception e) { throw new ExceptionConverter(e); } catalog.put(PdfName.STRUCTTREEROOT, structureTreeRoot.getReference()); PdfDictionary mi = new PdfDictionary(); mi.put(PdfName.MARKED, PdfBoolean.PDFTRUE); - if (userProperties) + if (userProperties) { mi.put(PdfName.USERPROPERTIES, PdfBoolean.PDFTRUE); + } catalog.put(PdfName.MARKINFO, mi); } // [F13] OCG @@ -904,56 +924,65 @@ protected PdfDictionary getCatalog(PdfIndirectReference rootObj) return catalog; } - /** Holds value of property extraCatalog this is used for Output Intents. */ + /** + * Holds value of property extraCatalog this is used for Output Intents. + */ protected PdfDictionary extraCatalog; /** * Sets extra keys to the catalog. + * * @return the catalog to change */ public PdfDictionary getExtraCatalog() { - if (extraCatalog == null) + if (extraCatalog == null) { extraCatalog = new PdfDictionary(); + } return this.extraCatalog; } // PdfPages -/* - * The page root keeps the complete page tree of the document. - * There's an entry in the Catalog that refers to the root - * of the page tree, the page tree contains the references - * to pages and other page trees. - */ + /* + * The page root keeps the complete page tree of the document. + * There's an entry in the Catalog that refers to the root + * of the page tree, the page tree contains the references + * to pages and other page trees. + */ - /** The root of the page tree. */ + /** + * The root of the page tree. + */ protected PdfPages root = new PdfPages(this); - /** The PdfIndirectReference to the pages. */ + /** + * The PdfIndirectReference to the pages. + */ protected ArrayList pageReferences = new ArrayList<>(); - /** The current page number. */ + /** + * The current page number. + */ protected int currentPageNumber = 1; /** * The value of the Tabs entry in the page dictionary. - * @since 2.1.5 + * + * @since 2.1.5 */ protected PdfName tabs = null; /** - * Use this method to make sure the page tree has a linear structure - * (every leave is attached directly to the root). + * Use this method to make sure the page tree has a linear structure (every leave is attached directly to the root). * Use this method to allow page reordering with method reorderPages. */ - public void setLinearPageMode() { + public void setLinearPageMode() { root.setLinearMode(null); } /** - * Use this method to reorder the pages in the document. - * A null argument value only returns the number of pages to process. - * It is advisable to issue a Document.newPage() before using this method. + * Use this method to reorder the pages in the document. A null argument value only returns the number + * of pages to process. It is advisable to issue a Document.newPage() before using this method. + * + * @param order an array with the new page sequence. It must have the same size as the number of pages. * @return the total number of pages - * @param order an array with the new page sequence. It must have the - * same size as the number of pages. * @throws DocumentException if all the pages are not present in the array */ public int reorderPages(int[] order) throws DocumentException { @@ -961,18 +990,19 @@ public int reorderPages(int[] order) throws DocumentException { } /** - * Use this method to get a reference to a page existing or not. - * If the page does not exist yet the reference will be created - * in advance. If on closing the document, a page number greater - * than the total number of pages was requested, an exception - * is thrown. + * Use this method to get a reference to a page existing or not. If the page does not exist yet the reference will + * be created in advance. If on closing the document, a page number greater than the total number of pages was + * requested, an exception is thrown. + * * @param page the page number. The first page is 1 * @return the reference to the page */ public PdfIndirectReference getPageReference(int page) { --page; - if (page < 0) - throw new IndexOutOfBoundsException(MessageLocalization.getComposedMessage("the.page.number.must.be.gt.eq.1")); + if (page < 0) { + throw new IndexOutOfBoundsException( + MessageLocalization.getComposedMessage("the.page.number.must.be.gt.eq.1")); + } PdfIndirectReference ref; if (page < pageReferences.size()) { ref = pageReferences.get(page); @@ -980,11 +1010,11 @@ public PdfIndirectReference getPageReference(int page) { ref = body.getPdfIndirectReference(); pageReferences.set(page, ref); } - } - else { + } else { int empty = page - pageReferences.size(); - for (int k = 0; k < empty; ++k) + for (int k = 0; k < empty; ++k) { pageReferences.add(null); + } ref = body.getPdfIndirectReference(); pageReferences.add(ref); } @@ -992,9 +1022,9 @@ public PdfIndirectReference getPageReference(int page) { } /** - * Gets the pagenumber of this document. - * This number can be different from the real pagenumber, - * if you have (re)set the page number previously. + * Gets the pagenumber of this document. This number can be different from the real pagenumber, if you have (re)set + * the page number previously. + * * @return a page number */ @@ -1012,10 +1042,10 @@ public int getCurrentPageNumber() { /** * Sets the value for the Tabs entry in the page tree. - * @param tabs Can be PdfName.R, PdfName.C or PdfName.S. - * Since the Adobe Extensions Level 3, it can also be PdfName.A - * or PdfName.W - * @since 2.1.5 + * + * @param tabs Can be PdfName.R, PdfName.C or PdfName.S. Since the Adobe Extensions Level 3, it can also be + * PdfName.A or PdfName.W + * @since 2.1.5 */ public void setTabs(PdfName tabs) { this.tabs = tabs; @@ -1023,8 +1053,9 @@ public void setTabs(PdfName tabs) { /** * Returns the value to be used for the Tabs entry in the page tree. - * @since 2.1.5 + * * @return a PdfName of the value of the Tabs entry in the page dictionnary + * @since 2.1.5 */ public PdfName getTabs() { return tabs; @@ -1032,13 +1063,12 @@ public PdfName getTabs() { /** * Adds some PdfContents to this Writer. - *

- * The document has to be open before you can begin to add content - * to the body of the document. + *

+ * The document has to be open before you can begin to add content to the body of the document. * - * @return a PdfIndirectReference - * @param page the PdfPage to add + * @param page the PdfPage to add * @param contents the PdfContents of the page + * @return a PdfIndirectReference * @throws PdfException on error */ @@ -1049,8 +1079,7 @@ PdfIndirectReference add(PdfPage page, PdfContents contents) throws PdfException PdfIndirectObject object; try { object = addToBody(contents); - } - catch(IOException ioe) { + } catch (IOException ioe) { throw new ExceptionConverter(ioe); } page.add(object.getIndirectReference()); @@ -1058,8 +1087,7 @@ PdfIndirectReference add(PdfPage page, PdfContents contents) throws PdfException if (group != null) { page.put(PdfName.GROUP, group); group = null; - } - else if (rgbTransparencyBlending) { + } else if (rgbTransparencyBlending) { PdfDictionary pp = new PdfDictionary(); pp.put(PdfName.TYPE, PdfName.GROUP); pp.put(PdfName.S, PdfName.TRANSPARENCY); @@ -1073,26 +1101,32 @@ else if (rgbTransparencyBlending) { // page events -/* - * Page events are specific for iText, not for PDF. - * Upon specific events (for instance when a page starts - * or ends), the corresponding method in the page event - * implementation that is added to the writer is invoked. - */ + /* + * Page events are specific for iText, not for PDF. + * Upon specific events (for instance when a page starts + * or ends), the corresponding method in the page event + * implementation that is added to the writer is invoked. + */ - /** The PdfPageEvent for this document. */ + /** + * The PdfPageEvent for this document. + */ private PdfPageEvent pageEvent; /** * Sets the PdfPageEvent for this document. + * * @param event the PdfPageEvent for this document */ public void setPageEvent(PdfPageEvent event) { - if (event == null) this.pageEvent = null; - else if (this.pageEvent == null) this.pageEvent = event; - else if (this.pageEvent instanceof PdfPageEventForwarder) ((PdfPageEventForwarder)this.pageEvent).addPageEvent(event); - else { + if (event == null) { + this.pageEvent = null; + } else if (this.pageEvent == null) { + this.pageEvent = event; + } else if (this.pageEvent instanceof PdfPageEventForwarder) { + ((PdfPageEventForwarder) this.pageEvent).addPageEvent(event); + } else { PdfPageEventForwarder forward = new PdfPageEventForwarder(); forward.addPageEvent(this.pageEvent); forward.addPageEvent(event); @@ -1101,10 +1135,9 @@ public void setPageEvent(PdfPageEvent event) { } /** - * Gets the PdfPageEvent for this document or null - * if none is set. - * @return the PdfPageEvent for this document or null - * if none is set + * Gets the PdfPageEvent for this document or null if none is set. + * + * @return the PdfPageEvent for this document or null if none is set */ public PdfPageEvent getPageEvent() { @@ -1113,17 +1146,20 @@ public PdfPageEvent getPageEvent() { // Open and Close methods + method that create the PDF - /** A number referring to the previous Cross-Reference Table. */ + /** + * A number referring to the previous Cross-Reference Table. + */ protected int prevxref = 0; /** * Signals that the Document has been opened and that * Elements can be added. - *

- * When this method is called, the PDF-document header is - * written to the outputstream. + *

+ * When this method is called, the PDF-document header is written to the outputstream. + * * @see com.lowagie.text.DocWriter#open() */ + @Override public void open() { super.open(); try { @@ -1131,15 +1167,15 @@ public void open() { body = new PdfBody(this); if (pdfxConformance.isPdfX32002()) { PdfDictionary sec = new PdfDictionary(); - sec.put(PdfName.GAMMA, new PdfArray(new float[]{2.2f,2.2f,2.2f})); - sec.put(PdfName.MATRIX, new PdfArray(new float[]{0.4124f,0.2126f,0.0193f,0.3576f,0.7152f,0.1192f,0.1805f,0.0722f,0.9505f})); - sec.put(PdfName.WHITEPOINT, new PdfArray(new float[]{0.9505f,1f,1.089f})); + sec.put(PdfName.GAMMA, new PdfArray(new float[]{2.2f, 2.2f, 2.2f})); + sec.put(PdfName.MATRIX, new PdfArray( + new float[]{0.4124f, 0.2126f, 0.0193f, 0.3576f, 0.7152f, 0.1192f, 0.1805f, 0.0722f, 0.9505f})); + sec.put(PdfName.WHITEPOINT, new PdfArray(new float[]{0.9505f, 1f, 1.089f})); PdfArray arr = new PdfArray(PdfName.CALRGB); arr.add(sec); setDefaultColorspace(PdfName.DEFAULTRGB, addToBody(arr).getIndirectReference()); } - } - catch(IOException ioe) { + } catch (IOException ioe) { throw new ExceptionConverter(ioe); } } @@ -1147,25 +1183,29 @@ public void open() { /** * Signals that the Document was closed and that no other * Elements will be added. - *

- * The pages-tree is built and written to the outputstream. - * A Catalog is constructed, as well as an Info-object, - * the reference table is composed and everything is written - * to the outputstream embedded in a Trailer. + *

+ * The pages-tree is built and written to the outputstream. A Catalog is constructed, as well as an Info-object, the + * reference table is composed and everything is written to the outputstream embedded in a Trailer. + * * @see com.lowagie.text.DocWriter#close() */ @Override public void close() { if (open) { - + if (pdf != null && pdf.isOpen()) { + throw new IllegalStateException(MessageLocalization + .getComposedMessage("you.should.call.document.close.instead")); + } if ((currentPageNumber - 1) != pageReferences.size()) - // 2019-04-26: If you get this error, it could be that you are using OpenPDF or - // another library such as flying-saucer's ITextRenderer in a non-threadsafe way. - // ITextRenderer is not thread safe. So if you get this problem here, create a new - // instance, rather than re-using it. - // See: https://github.com/LibrePDF/OpenPDF/issues/164 + // 2019-04-26: If you get this error, it could be that you are using OpenPDF or + // another library such as flying-saucer's ITextRenderer in a non-threadsafe way. + // ITextRenderer is not thread safe. So if you get this problem here, create a new + // instance, rather than re-using it. + // See: https://github.com/LibrePDF/OpenPDF/issues/164 + { throw new RuntimeException("The page " + pageReferences.size() + - " was requested but the document has only " + (currentPageNumber - 1) + " pages."); + " was requested but the document has only " + (currentPageNumber - 1) + " pages."); + } try { addSharedObjectsToBody(); @@ -1204,7 +1244,7 @@ public void close() { // [F1] encryption PdfIndirectReference encryption = null; - PdfObject fileID = null; + PdfObject fileID; body.flushObjStm(); if (crypto != null) { PdfIndirectObject encryptionObject = addToBody(crypto.getEncryptionDictionary(), false); @@ -1220,14 +1260,13 @@ public void close() { // write the cross-reference table of the body body.writeCrossReferenceTable(os, indirectCatalog.getIndirectReference(), - infoObj.getIndirectReference(), encryption, fileID, prevxref); + infoObj.getIndirectReference(), encryption, fileID, prevxref); os.write(getISOBytes("startxref\n")); os.write(getISOBytes(String.valueOf(body.offset()))); os.write(getISOBytes("\n%%EOF\n")); super.close(); - } - catch(IOException ioe) { + } catch (IOException ioe) { throw new ExceptionConverter(ioe); } } @@ -1241,8 +1280,9 @@ protected void addSharedObjectsToBody() throws IOException { // [F4] add the form XObjects for (Object[] objs : formXObjects.values()) { PdfTemplate template = (PdfTemplate) objs[1]; - if (template != null && template.getIndirectReference() instanceof PRIndirectReference) + if (template != null && template.getIndirectReference() instanceof PRIndirectReference) { continue; + } if (template != null && template.getType() == PdfTemplate.TYPE_TEMPLATE) { addToBody(template.getFormXObject(compressionLevel), template.getIndirectReference()); } @@ -1279,8 +1319,7 @@ protected void addSharedObjectsToBody() throws IOException { for (Map.Entry entry : documentProperties.entrySet()) { Object prop = entry.getKey(); PdfObject[] obj = entry.getValue(); - if (prop instanceof PdfLayerMembership) { - PdfLayerMembership layer = (PdfLayerMembership) prop; + if (prop instanceof PdfLayerMembership layer) { addToBody(layer.getPdfObject(), layer.getRef()); } else if ((prop instanceof PdfDictionary) && !(prop instanceof PdfLayer)) { addToBody((PdfDictionary) prop, (PdfIndirectReference) obj[1]); @@ -1296,21 +1335,21 @@ protected void addSharedObjectsToBody() throws IOException { // [C1] Outlines (bookmarks) - /** - * Use this method to get the root outline - * and construct bookmarks. - * @return the root outline - */ + /** + * Use this method to get the root outline and construct bookmarks. + * + * @return the root outline + */ - public PdfOutline getRootOutline() { - return directContent.getRootOutline(); - } + public PdfOutline getRootOutline() { + return directContent.getRootOutline(); + } - protected List newBookmarks; + protected List newBookmarks; /** - * Sets the bookmarks. The list structure is defined in - * {@link SimpleBookmark}. + * Sets the bookmarks. The list structure is defined in {@link SimpleBookmark}. + * * @param outlines the bookmarks or null to remove any */ public void setOutlines(List outlines) { @@ -1318,71 +1357,104 @@ public void setOutlines(List outlines) { } protected void writeOutlines(PdfDictionary catalog, boolean namedAsNames) throws IOException { - if (newBookmarks == null || newBookmarks.isEmpty()) + if (newBookmarks == null || newBookmarks.isEmpty()) { return; + } PdfDictionary top = new PdfDictionary(); PdfIndirectReference topRef = getPdfIndirectReference(); Object[] kids = SimpleBookmark.iterateOutlines(this, topRef, newBookmarks, namedAsNames); - top.put(PdfName.FIRST, (PdfIndirectReference)kids[0]); - top.put(PdfName.LAST, (PdfIndirectReference)kids[1]); + top.put(PdfName.FIRST, (PdfIndirectReference) kids[0]); + top.put(PdfName.LAST, (PdfIndirectReference) kids[1]); top.put(PdfName.COUNT, new PdfNumber((Integer) kids[2])); addToBody(top, topRef); catalog.put(PdfName.OUTLINES, topRef); } // [C2] PdfVersion interface - /** possible PDF version (header) */ - public static final char VERSION_1_2 = '2'; - /** possible PDF version (header) */ - public static final char VERSION_1_3 = '3'; - /** possible PDF version (header) */ - public static final char VERSION_1_4 = '4'; - /** possible PDF version (header) */ - public static final char VERSION_1_5 = '5'; - /** possible PDF version (header) */ - public static final char VERSION_1_6 = '6'; - /** possible PDF version (header) */ - public static final char VERSION_1_7 = '7'; - - /** possible PDF version (catalog) */ - public static final PdfName PDF_VERSION_1_2 = new PdfName("1.2"); - /** possible PDF version (catalog) */ - public static final PdfName PDF_VERSION_1_3 = new PdfName("1.3"); - /** possible PDF version (catalog) */ - public static final PdfName PDF_VERSION_1_4 = new PdfName("1.4"); - /** possible PDF version (catalog) */ - public static final PdfName PDF_VERSION_1_5 = new PdfName("1.5"); - /** possible PDF version (catalog) */ - public static final PdfName PDF_VERSION_1_6 = new PdfName("1.6"); - /** possible PDF version (catalog) */ - public static final PdfName PDF_VERSION_1_7 = new PdfName("1.7"); - - /** Stores the version information for the header and the catalog. */ + /** + * possible PDF version (header) + */ + public static final char VERSION_1_2 = '2'; + /** + * possible PDF version (header) + */ + public static final char VERSION_1_3 = '3'; + /** + * possible PDF version (header) + */ + public static final char VERSION_1_4 = '4'; + /** + * possible PDF version (header) + */ + public static final char VERSION_1_5 = '5'; + /** + * possible PDF version (header) + */ + public static final char VERSION_1_6 = '6'; + /** + * possible PDF version (header) + */ + public static final char VERSION_1_7 = '7'; + + /** + * possible PDF version (catalog) + */ + public static final PdfName PDF_VERSION_1_2 = new PdfName("1.2"); + /** + * possible PDF version (catalog) + */ + public static final PdfName PDF_VERSION_1_3 = new PdfName("1.3"); + /** + * possible PDF version (catalog) + */ + public static final PdfName PDF_VERSION_1_4 = new PdfName("1.4"); + /** + * possible PDF version (catalog) + */ + public static final PdfName PDF_VERSION_1_5 = new PdfName("1.5"); + /** + * possible PDF version (catalog) + */ + public static final PdfName PDF_VERSION_1_6 = new PdfName("1.6"); + /** + * possible PDF version (catalog) + */ + public static final PdfName PDF_VERSION_1_7 = new PdfName("1.7"); + + /** + * Stores the version information for the header and the catalog. + */ protected PdfVersionImp pdf_version = new PdfVersionImp(); - /** @see com.lowagie.text.pdf.interfaces.PdfVersion#setPdfVersion(char) */ + /** + * @see com.lowagie.text.pdf.interfaces.PdfVersion#setPdfVersion(char) + */ public void setPdfVersion(char version) { pdf_version.setPdfVersion(version); } - /** @see com.lowagie.text.pdf.interfaces.PdfVersion#setAtLeastPdfVersion(char) */ + /** + * @see com.lowagie.text.pdf.interfaces.PdfVersion#setAtLeastPdfVersion(char) + */ public void setAtLeastPdfVersion(char version) { pdf_version.setAtLeastPdfVersion(version); } - /** @see com.lowagie.text.pdf.interfaces.PdfVersion#setPdfVersion(com.lowagie.text.pdf.PdfName) */ + /** + * @see com.lowagie.text.pdf.interfaces.PdfVersion#setPdfVersion(com.lowagie.text.pdf.PdfName) + */ public void setPdfVersion(PdfName version) { pdf_version.setPdfVersion(version); } /** * @see com.lowagie.text.pdf.interfaces.PdfVersion#addDeveloperExtension(com.lowagie.text.pdf.PdfDeveloperExtension) - * @since 2.1.6 + * @since 2.1.6 */ public void addDeveloperExtension(PdfDeveloperExtension de) { pdf_version.addDeveloperExtension(de); } - + /** * Returns the version information. */ @@ -1394,72 +1466,127 @@ PdfVersionImp getPdfVersion() { // page layout (section 13.1.1 of "iText in Action") - /** A viewer preference */ + /** + * A viewer preference + */ public static final int PageLayoutSinglePage = 1; - /** A viewer preference */ + /** + * A viewer preference + */ public static final int PageLayoutOneColumn = 2; - /** A viewer preference */ + /** + * A viewer preference + */ public static final int PageLayoutTwoColumnLeft = 4; - /** A viewer preference */ + /** + * A viewer preference + */ public static final int PageLayoutTwoColumnRight = 8; - /** A viewer preference */ + /** + * A viewer preference + */ public static final int PageLayoutTwoPageLeft = 16; - /** A viewer preference */ + /** + * A viewer preference + */ public static final int PageLayoutTwoPageRight = 32; // page mode (section 13.1.2 of "iText in Action") - /** A viewer preference */ + /** + * A viewer preference + */ public static final int PageModeUseNone = 64; - /** A viewer preference */ + /** + * A viewer preference + */ public static final int PageModeUseOutlines = 128; - /** A viewer preference */ + /** + * A viewer preference + */ public static final int PageModeUseThumbs = 256; - /** A viewer preference */ + /** + * A viewer preference + */ public static final int PageModeFullScreen = 512; - /** A viewer preference */ + /** + * A viewer preference + */ public static final int PageModeUseOC = 1024; - /** A viewer preference */ + /** + * A viewer preference + */ public static final int PageModeUseAttachments = 2048; // values for setting viewer preferences in iText versions older than 2.x - /** A viewer preference */ + /** + * A viewer preference + */ public static final int HideToolbar = 1 << 12; - /** A viewer preference */ + /** + * A viewer preference + */ public static final int HideMenubar = 1 << 13; - /** A viewer preference */ + /** + * A viewer preference + */ public static final int HideWindowUI = 1 << 14; - /** A viewer preference */ + /** + * A viewer preference + */ public static final int FitWindow = 1 << 15; - /** A viewer preference */ + /** + * A viewer preference + */ public static final int CenterWindow = 1 << 16; - /** A viewer preference */ + /** + * A viewer preference + */ public static final int DisplayDocTitle = 1 << 17; - /** A viewer preference */ + /** + * A viewer preference + */ public static final int NonFullScreenPageModeUseNone = 1 << 18; - /** A viewer preference */ + /** + * A viewer preference + */ public static final int NonFullScreenPageModeUseOutlines = 1 << 19; - /** A viewer preference */ + /** + * A viewer preference + */ public static final int NonFullScreenPageModeUseThumbs = 1 << 20; - /** A viewer preference */ + /** + * A viewer preference + */ public static final int NonFullScreenPageModeUseOC = 1 << 21; - /** A viewer preference */ + /** + * A viewer preference + */ public static final int DirectionL2R = 1 << 22; - /** A viewer preference */ + /** + * A viewer preference + */ public static final int DirectionR2L = 1 << 23; - /** A viewer preference */ + /** + * A viewer preference + */ public static final int PrintScalingNone = 1 << 24; - /** @see com.lowagie.text.pdf.interfaces.PdfViewerPreferences#setViewerPreferences(int) */ + /** + * @see com.lowagie.text.pdf.interfaces.PdfViewerPreferences#setViewerPreferences(int) + */ public void setViewerPreferences(int preferences) { pdf.setViewerPreferences(preferences); } - /** @see com.lowagie.text.pdf.interfaces.PdfViewerPreferences#addViewerPreference(com.lowagie.text.pdf.PdfName, com.lowagie.text.pdf.PdfObject) */ + /** + * @see com.lowagie.text.pdf.interfaces.PdfViewerPreferences#addViewerPreference(com.lowagie.text.pdf.PdfName, + * com.lowagie.text.pdf.PdfObject) + */ public void addViewerPreference(PdfName key, PdfObject value) { pdf.addViewerPreference(key, value); } @@ -1468,6 +1595,7 @@ public void addViewerPreference(PdfName key, PdfObject value) { /** * Use this method to add page labels + * * @param pageLabels the page labels */ public void setPageLabels(PdfPageLabels pageLabels) { @@ -1477,15 +1605,14 @@ public void setPageLabels(PdfPageLabels pageLabels) { // [C5] named objects: named destinations, javascript, embedded files /** - * Adds named destinations in bulk. - * Valid keys and values of the map can be found in the map - * that is created by SimpleNamedDestination. - * @param map a map with strings as keys for the names, - * and structured strings as values for the destinations - * @param page_offset number of pages that has to be added to - * the page numbers in the destinations (useful if you - * use this method in combination with PdfCopy). - * @since iText 5.0 + * Adds named destinations in bulk. Valid keys and values of the map can be found in the map that is created by + * SimpleNamedDestination. + * + * @param map a map with strings as keys for the names, and structured strings as values for the + * destinations + * @param page_offset number of pages that has to be added to the page numbers in the destinations (useful if you + * use this method in combination with PdfCopy). + * @since iText 5.0 */ public void addNamedDestinations(Map map, int page_offset) { Map.Entry entry; @@ -1500,153 +1627,181 @@ public void addNamedDestinations(Map map, int page_offset) { addNamedDestination(entry.getKey(), page + page_offset, destination); } } - + /** * Adds one named destination. - * @param name the name for the destination - * @param page the page number where you want to jump to - * @param dest an explicit destination - * @since iText 5.0 + * + * @param name the name for the destination + * @param page the page number where you want to jump to + * @param dest an explicit destination + * @since iText 5.0 */ public void addNamedDestination(String name, int page, PdfDestination dest) { dest.addPage(getPageReference(page)); pdf.localDestination(name, dest); } - - /** - * Use this method to add a JavaScript action at the document level. - * When the document opens, all this JavaScript runs. - * @param js The JavaScript action - */ - public void addJavaScript(PdfAction js) { - pdf.addJavaScript(js); - } - - /** - * Use this method to add a JavaScript action at the document level. - * When the document opens, all this JavaScript runs. - * @param code the JavaScript code - * @param unicode select JavaScript unicode. Note that the internal - * Acrobat JavaScript engine does not support unicode, - * so this may or may not work for you - */ - public void addJavaScript(String code, boolean unicode) { - addJavaScript(PdfAction.javaScript(code, this, unicode)); - } - - /** - * Use this method to adds a JavaScript action at the document level. - * When the document opens, all this JavaScript runs. - * @param code the JavaScript code - */ - public void addJavaScript(String code) { - addJavaScript(code, false); - } - /** - * Use this method to add a JavaScript action at the document level. - * When the document opens, all this JavaScript runs. - * @param name The name of the JS Action in the name tree - * @param js The JavaScript action - */ - public void addJavaScript(String name, PdfAction js) { - pdf.addJavaScript(name, js); - } - - /** - * Use this method to add a JavaScript action at the document level. - * When the document opens, all this JavaScript runs. - * @param name The name of the JS Action in the name tree - * @param code the JavaScript code - * @param unicode select JavaScript unicode. Note that the internal - * Acrobat JavaScript engine does not support unicode, - * so this may or may not work for you - */ - public void addJavaScript(String name, String code, boolean unicode) { - addJavaScript(name, PdfAction.javaScript(code, this, unicode)); - } - - /** - * Use this method to adds a JavaScript action at the document level. - * When the document opens, all this JavaScript runs. - * @param name The name of the JS Action in the name tree - * @param code the JavaScript code - */ - public void addJavaScript(String name, String code) { - addJavaScript(name, code, false); - } - - /** - * Use this method to add a file attachment at the document level. - * @param description the file description - * @param fileStore an array with the file. If it's null - * the file will be read from the disk - * @param file the path to the file. It will only be used if - * fileStore is not null - * @param fileDisplay the actual file name stored in the pdf - * @throws IOException on error - */ - public void addFileAttachment(String description, byte[] fileStore, String file, String fileDisplay) throws IOException { - addFileAttachment(description, PdfFileSpecification.fileEmbedded(this, file, fileDisplay, fileStore)); - } - - /** - * Use this method to add a file attachment at the document level. - * @param description the file description - * @param fs the file specification - * @throws IOException thrown when an I/O operation fails - */ - public void addFileAttachment(String description, PdfFileSpecification fs) throws IOException { - pdf.addFileAttachment(description, fs); - } - - /** - * Use this method to add a file attachment at the document level. - * @param fs the file specification - * @throws IOException thrown when an I/O operation fails - */ - public void addFileAttachment(PdfFileSpecification fs) throws IOException { - addFileAttachment(null, fs); - } + + /** + * Use this method to add a JavaScript action at the document level. When the document opens, all this JavaScript + * runs. + * + * @param js The JavaScript action + */ + public void addJavaScript(PdfAction js) { + pdf.addJavaScript(js); + } + + /** + * Use this method to add a JavaScript action at the document level. When the document opens, all this JavaScript + * runs. + * + * @param code the JavaScript code + * @param unicode select JavaScript unicode. Note that the internal Acrobat JavaScript engine does not support + * unicode, so this may or may not work for you + */ + public void addJavaScript(String code, boolean unicode) { + addJavaScript(PdfAction.javaScript(code, this, unicode)); + } + + /** + * Use this method to adds a JavaScript action at the document level. When the document opens, all this JavaScript + * runs. + * + * @param code the JavaScript code + */ + public void addJavaScript(String code) { + addJavaScript(code, false); + } + + /** + * Use this method to add a JavaScript action at the document level. When the document opens, all this JavaScript + * runs. + * + * @param name The name of the JS Action in the name tree + * @param js The JavaScript action + */ + public void addJavaScript(String name, PdfAction js) { + pdf.addJavaScript(name, js); + } + + /** + * Use this method to add a JavaScript action at the document level. When the document opens, all this JavaScript + * runs. + * + * @param name The name of the JS Action in the name tree + * @param code the JavaScript code + * @param unicode select JavaScript unicode. Note that the internal Acrobat JavaScript engine does not support + * unicode, so this may or may not work for you + */ + public void addJavaScript(String name, String code, boolean unicode) { + addJavaScript(name, PdfAction.javaScript(code, this, unicode)); + } + + /** + * Use this method to adds a JavaScript action at the document level. When the document opens, all this JavaScript + * runs. + * + * @param name The name of the JS Action in the name tree + * @param code the JavaScript code + */ + public void addJavaScript(String name, String code) { + addJavaScript(name, code, false); + } + + /** + * Use this method to add a file attachment at the document level. + * + * @param description the file description + * @param fileStore an array with the file. If it's null the file will be read from the disk + * @param file the path to the file. It will only be used if + * fileStore is not null + * @param fileDisplay the actual file name stored in the pdf + * @throws IOException on error + */ + public void addFileAttachment(String description, byte[] fileStore, String file, String fileDisplay) + throws IOException { + addFileAttachment(description, PdfFileSpecification.fileEmbedded(this, file, fileDisplay, fileStore)); + } + + /** + * Use this method to add a file attachment at the document level. + * + * @param description the file description + * @param fs the file specification + * @throws IOException thrown when an I/O operation fails + */ + public void addFileAttachment(String description, PdfFileSpecification fs) throws IOException { + pdf.addFileAttachment(description, fs); + } + + /** + * Use this method to add a file attachment at the document level. + * + * @param fs the file specification + * @throws IOException thrown when an I/O operation fails + */ + public void addFileAttachment(PdfFileSpecification fs) throws IOException { + addFileAttachment(null, fs); + } // [C6] Actions (open and additional) - /** action value */ - public static final PdfName DOCUMENT_CLOSE = PdfName.WC; - /** action value */ - public static final PdfName WILL_SAVE = PdfName.WS; - /** action value */ - public static final PdfName DID_SAVE = PdfName.DS; - /** action value */ - public static final PdfName WILL_PRINT = PdfName.WP; - /** action value */ - public static final PdfName DID_PRINT = PdfName.DP; - - /** @see com.lowagie.text.pdf.interfaces.PdfDocumentActions#setOpenAction(java.lang.String) */ + /** + * action value + */ + public static final PdfName DOCUMENT_CLOSE = PdfName.WC; + /** + * action value + */ + public static final PdfName WILL_SAVE = PdfName.WS; + /** + * action value + */ + public static final PdfName DID_SAVE = PdfName.DS; + /** + * action value + */ + public static final PdfName WILL_PRINT = PdfName.WP; + /** + * action value + */ + public static final PdfName DID_PRINT = PdfName.DP; + + /** + * @see com.lowagie.text.pdf.interfaces.PdfDocumentActions#setOpenAction(java.lang.String) + */ public void setOpenAction(String name) { - pdf.setOpenAction(name); - } + pdf.setOpenAction(name); + } - /** @see com.lowagie.text.pdf.interfaces.PdfDocumentActions#setOpenAction(com.lowagie.text.pdf.PdfAction) */ + /** + * @see com.lowagie.text.pdf.interfaces.PdfDocumentActions#setOpenAction(com.lowagie.text.pdf.PdfAction) + */ public void setOpenAction(PdfAction action) { - pdf.setOpenAction(action); - } + pdf.setOpenAction(action); + } - /** @see com.lowagie.text.pdf.interfaces.PdfDocumentActions#setAdditionalAction(com.lowagie.text.pdf.PdfName, com.lowagie.text.pdf.PdfAction) */ + /** + * @see com.lowagie.text.pdf.interfaces.PdfDocumentActions#setAdditionalAction(com.lowagie.text.pdf.PdfName, + * com.lowagie.text.pdf.PdfAction) + */ public void setAdditionalAction(PdfName actionType, PdfAction action) throws DocumentException { - if (!(actionType.equals(DOCUMENT_CLOSE) || - actionType.equals(WILL_SAVE) || - actionType.equals(DID_SAVE) || - actionType.equals(WILL_PRINT) || - actionType.equals(DID_PRINT))) { - throw new DocumentException(MessageLocalization.getComposedMessage("invalid.additional.action.type.1", actionType.toString())); - } - pdf.addAdditionalAction(actionType, action); - } + if (!(actionType.equals(DOCUMENT_CLOSE) || + actionType.equals(WILL_SAVE) || + actionType.equals(DID_SAVE) || + actionType.equals(WILL_PRINT) || + actionType.equals(DID_PRINT))) { + throw new DocumentException( + MessageLocalization.getComposedMessage("invalid.additional.action.type.1", actionType.toString())); + } + pdf.addAdditionalAction(actionType, action); + } // [C7] portable collections /** * Use this method to add the Collection dictionary. + * * @param collection a dictionary of type PdfCollection */ public void setCollection(PdfCollection collection) { @@ -1656,17 +1811,25 @@ public void setCollection(PdfCollection collection) { // [C8] AcroForm - /** signature value */ + /** + * signature value + */ public static final int SIGNATURE_EXISTS = 1; - /** signature value */ + /** + * signature value + */ public static final int SIGNATURE_APPEND_ONLY = 2; - /** @see com.lowagie.text.pdf.interfaces.PdfAnnotations#getAcroForm() */ + /** + * @see com.lowagie.text.pdf.interfaces.PdfAnnotations#getAcroForm() + */ public PdfAcroForm getAcroForm() { return pdf.getAcroForm(); } - /** @see com.lowagie.text.pdf.interfaces.PdfAnnotations#addAnnotation(com.lowagie.text.pdf.PdfAnnotation) */ + /** + * @see com.lowagie.text.pdf.interfaces.PdfAnnotations#addAnnotation(com.lowagie.text.pdf.PdfAnnotation) + */ public void addAnnotation(PdfAnnotation annot) { pdf.addAnnotation(annot); } @@ -1675,23 +1838,30 @@ void addAnnotation(PdfAnnotation annot, int page) { addAnnotation(annot); } - /** @see com.lowagie.text.pdf.interfaces.PdfAnnotations#addCalculationOrder(com.lowagie.text.pdf.PdfFormField) */ + /** + * @see com.lowagie.text.pdf.interfaces.PdfAnnotations#addCalculationOrder(com.lowagie.text.pdf.PdfFormField) + */ public void addCalculationOrder(PdfFormField annot) { pdf.addCalculationOrder(annot); } - /** @see com.lowagie.text.pdf.interfaces.PdfAnnotations#setSigFlags(int) */ + /** + * @see com.lowagie.text.pdf.interfaces.PdfAnnotations#setSigFlags(int) + */ public void setSigFlags(int f) { pdf.setSigFlags(f); } // [C9] Metadata - /** XMP Metadata for the document. */ + /** + * XMP Metadata for the document. + */ protected byte[] xmpMetadata = null; /** * Use this method to set the XMP Metadata. + * * @param xmpMetadata The xmpMetadata to set. */ public void setXmpMetadata(byte[] xmpMetadata) { @@ -1700,6 +1870,7 @@ public void setXmpMetadata(byte[] xmpMetadata) { /** * Use this method to set the XMP Metadata for each page. + * * @param xmpMetadata The xmpMetadata to set. */ public void setPageXmpMetadata(byte[] xmpMetadata) { @@ -1707,8 +1878,7 @@ public void setPageXmpMetadata(byte[] xmpMetadata) { } /** - * Use this method to creates XMP Metadata based - * on the metadata in the PdfDocument. + * Use this method to creates XMP Metadata based on the metadata in the PdfDocument. */ public void createXmpMetadata() { setXmpMetadata(createXmpMetadataBytes()); @@ -1722,77 +1892,107 @@ private byte[] createXmpMetadataBytes() { try { XmpWriter xmp = new XmpWriter(baos, pdf.getInfo(), pdfxConformance.getPDFXConformance()); xmp.close(); - } - catch (IOException ioe) { + } catch (IOException ioe) { ioe.printStackTrace(); } return baos.toByteArray(); } // [C10] PDFX Conformance - /** A PDF/X level. */ + /** + * A PDF/X level. + */ public static final int PDFXNONE = 0; - /** A PDF/X level. */ + /** + * A PDF/X level. + */ public static final int PDFX1A2001 = 1; - /** A PDF/X level. */ + /** + * A PDF/X level. + */ public static final int PDFX32002 = 2; - /** PDFA-1A level. */ + /** + * PDFA-1A level. + */ public static final int PDFA1A = 3; - /** PDFA-1B level. */ + /** + * PDFA-1B level. + */ public static final int PDFA1B = 4; - /** Stores the PDF/X level. */ - private PdfXConformanceImp pdfxConformance = new PdfXConformanceImp(); + /** + * Stores the PDF/X level. + */ + private final PdfXConformanceImp pdfxConformance = new PdfXConformanceImp(); - /** @see com.lowagie.text.pdf.interfaces.PdfXConformance#setPDFXConformance(int) */ + /** + * @see com.lowagie.text.pdf.interfaces.PdfXConformance#setPDFXConformance(int) + */ public void setPDFXConformance(int pdfx) { - if (pdfxConformance.getPDFXConformance() == pdfx) + if (pdfxConformance.getPDFXConformance() == pdfx) { return; - if (pdf.isOpen()) - throw new PdfXConformanceException(MessageLocalization.getComposedMessage("pdfx.conformance.can.only.be.set.before.opening.the.document")); - if (crypto != null) - throw new PdfXConformanceException(MessageLocalization.getComposedMessage("a.pdfx.conforming.document.cannot.be.encrypted")); - if (pdfx == PDFA1A || pdfx == PDFA1B) + } + if (pdf.isOpen()) { + throw new PdfXConformanceException( + MessageLocalization.getComposedMessage( + "pdfx.conformance.can.only.be.set.before.opening.the.document")); + } + if (crypto != null) { + throw new PdfXConformanceException( + MessageLocalization.getComposedMessage("a.pdfx.conforming.document.cannot.be.encrypted")); + } + if (pdfx == PDFA1A || pdfx == PDFA1B) { setPdfVersion(VERSION_1_4); - else if (pdfx != PDFXNONE) + } else if (pdfx != PDFXNONE) { setPdfVersion(VERSION_1_3); + } pdfxConformance.setPDFXConformance(pdfx); } - /** @see com.lowagie.text.pdf.interfaces.PdfXConformance#getPDFXConformance() */ + /** + * @see com.lowagie.text.pdf.interfaces.PdfXConformance#getPDFXConformance() + */ public int getPDFXConformance() { return pdfxConformance.getPDFXConformance(); } - /** @see com.lowagie.text.pdf.interfaces.PdfXConformance#isPdfX() */ + /** + * @see com.lowagie.text.pdf.interfaces.PdfXConformance#isPdfX() + */ public boolean isPdfX() { return pdfxConformance.isPdfX(); } // [C11] Output intents + /** - * Sets the values of the output intent dictionary. Null values are allowed to - * suppress any key. + * Sets the values of the output intent dictionary. Null values are allowed to suppress any key. * * @param outputConditionIdentifier a value * @param outputCondition a value, "PDFA/A" to force GTS_PDFA1, otherwise cued by pdfxConformance. * @param registryName a value * @param info a value * @param colorProfile a value - * @since 2.1.5 * @throws IOException on error + * @since 2.1.5 */ - public void setOutputIntents(String outputConditionIdentifier, String outputCondition, String registryName, String info, ICC_Profile colorProfile) throws IOException { + public void setOutputIntents(String outputConditionIdentifier, String outputCondition, String registryName, + String info, ICC_Profile colorProfile) throws IOException { getExtraCatalog(); PdfDictionary out = new PdfDictionary(PdfName.OUTPUTINTENT); - if (outputCondition != null) + if (outputCondition != null) { out.put(PdfName.OUTPUTCONDITION, new PdfString(outputCondition, PdfObject.TEXT_UNICODE)); - if (outputConditionIdentifier != null) - out.put(PdfName.OUTPUTCONDITIONIDENTIFIER, new PdfString(outputConditionIdentifier, PdfObject.TEXT_UNICODE)); - if (registryName != null) + } + if (outputConditionIdentifier != null) { + out.put(PdfName.OUTPUTCONDITIONIDENTIFIER, + new PdfString(outputConditionIdentifier, PdfObject.TEXT_UNICODE)); + } + if (registryName != null) { out.put(PdfName.REGISTRYNAME, new PdfString(registryName, PdfObject.TEXT_UNICODE)); - if (info != null) + } + if (info != null) { out.put(PdfName.INFO, new PdfString(info, PdfObject.TEXT_UNICODE)); + } if (colorProfile != null) { PdfStream stream = new PdfICCBased(colorProfile, compressionLevel); out.put(PdfName.DESTOUTPUTPROFILE, addToBody(stream).getIndirectReference()); @@ -1801,8 +2001,7 @@ public void setOutputIntents(String outputConditionIdentifier, String outputCond PdfName intentSubtype; if (pdfxConformance.isPdfA1() || "PDFA/1".equals(outputCondition)) { intentSubtype = PdfName.GTS_PDFA1; - } - else { + } else { intentSubtype = PdfName.GTS_PDFX; } @@ -1811,64 +2010,70 @@ public void setOutputIntents(String outputConditionIdentifier, String outputCond extraCatalog.put(PdfName.OUTPUTINTENTS, new PdfArray(out)); } - /** - * Sets the values of the output intent dictionary. Null values are allowed to - * suppress any key. - * + /** + * Sets the values of the output intent dictionary. Null values are allowed to suppress any key. + *

* Prefer the ICC_Profile-based version of this method. + * * @param outputConditionIdentifier a value * @param outputCondition a value, "PDFA/A" to force GTS_PDFA1, otherwise cued by pdfxConformance. * @param registryName a value * @param info a value * @param destOutputProfile a value - * @since 1.x - * * @throws IOException on error + * @since 1.x */ - public void setOutputIntents(String outputConditionIdentifier, String outputCondition, String registryName, String info, byte[] destOutputProfile) throws IOException { + public void setOutputIntents(String outputConditionIdentifier, String outputCondition, String registryName, + String info, byte[] destOutputProfile) throws IOException { ICC_Profile colorProfile = (destOutputProfile == null) ? null : ICC_Profile.getInstance(destOutputProfile); setOutputIntents(outputConditionIdentifier, outputCondition, registryName, info, colorProfile); } /** - * Use this method to copy the output intent dictionary - * from another document to this one. - * @param reader the other document + * Use this method to copy the output intent dictionary from another document to this one. + * + * @param reader the other document * @param checkExistence true to just check for the existence of a valid output intent - * dictionary, false to insert the dictionary if it exists - * @throws IOException on error + * dictionary, false to insert the dictionary if it exists * @return true if the output intent dictionary exists, false * otherwise + * @throws IOException on error */ public boolean setOutputIntents(PdfReader reader, boolean checkExistence) throws IOException { PdfDictionary catalog = reader.getCatalog(); PdfArray outs = catalog.getAsArray(PdfName.OUTPUTINTENTS); - if (outs == null) + if (outs == null) { return false; - if (outs.isEmpty()) + } + if (outs.isEmpty()) { return false; + } PdfDictionary out = outs.getAsDict(0); PdfObject obj = PdfReader.getPdfObject(out.get(PdfName.S)); - if (!PdfName.GTS_PDFX.equals(obj)) + if (!PdfName.GTS_PDFX.equals(obj)) { return false; - if (checkExistence) + } + if (checkExistence) { return true; - PRStream stream = (PRStream)PdfReader.getPdfObject(out.get(PdfName.DESTOUTPUTPROFILE)); + } + PRStream stream = (PRStream) PdfReader.getPdfObject(out.get(PdfName.DESTOUTPUTPROFILE)); byte[] destProfile = null; if (stream != null) { destProfile = PdfReader.getStreamBytes(stream); } - setOutputIntents(getNameString(out, PdfName.OUTPUTCONDITIONIDENTIFIER), getNameString(out, PdfName.OUTPUTCONDITION), + setOutputIntents(getNameString(out, PdfName.OUTPUTCONDITIONIDENTIFIER), + getNameString(out, PdfName.OUTPUTCONDITION), getNameString(out, PdfName.REGISTRYNAME), getNameString(out, PdfName.INFO), destProfile); return true; } private static String getNameString(PdfDictionary dic, PdfName key) { PdfObject obj = PdfReader.getPdfObject(dic.get(key)); - if (obj == null || !obj.isString()) + if (obj == null || !obj.isString()) { return null; - return ((PdfString)obj).toUnicodeString(); + } + return ((PdfString) obj).toUnicodeString(); } // PDF Objects that have an impact on the PDF body @@ -1877,101 +2082,137 @@ private static String getNameString(PdfDictionary dic, PdfName key) { // types of encryption - /** No encryption */ + /** + * No encryption + */ public static final int ENCRYPTION_NONE = -1; - /** Type of encryption */ + /** + * Type of encryption + */ public static final int STANDARD_ENCRYPTION_40 = 0; - /** Type of encryption */ + /** + * Type of encryption + */ public static final int STANDARD_ENCRYPTION_128 = 1; - /** Type of encryption */ + /** + * Type of encryption + */ public static final int ENCRYPTION_AES_128 = 2; // ENCRYPTION_* = 3 reserved for implementation of the // meanwhile deprecated proprietary AES256 variant by Adobe - /** Type of encryption */ + /** + * Type of encryption + */ public static final int ENCRYPTION_AES_256_V3 = 4; - /** Mask to separate the encryption type from the encryption mode. */ + /** + * Mask to separate the encryption type from the encryption mode. + */ static final int ENCRYPTION_MASK = 7; - /** Add this to the mode to keep the metadata in clear text */ + /** + * Add this to the mode to keep the metadata in clear text + */ public static final int DO_NOT_ENCRYPT_METADATA = 8; /** * Add this to the mode to keep encrypt only the embedded files. + * * @since 2.1.3 */ public static final int EMBEDDED_FILES_ONLY = 24; // permissions - /** The operation permitted when the document is opened with the user password + /** + * The operation permitted when the document is opened with the user password * * @since 2.0.7 */ public static final int ALLOW_PRINTING = 4 + 2048; - /** The operation permitted when the document is opened with the user password + /** + * The operation permitted when the document is opened with the user password * * @since 2.0.7 */ public static final int ALLOW_MODIFY_CONTENTS = 8; - /** The operation permitted when the document is opened with the user password + /** + * The operation permitted when the document is opened with the user password * * @since 2.0.7 */ public static final int ALLOW_COPY = 16; - /** The operation permitted when the document is opened with the user password + /** + * The operation permitted when the document is opened with the user password * * @since 2.0.7 */ public static final int ALLOW_MODIFY_ANNOTATIONS = 32; - /** The operation permitted when the document is opened with the user password + /** + * The operation permitted when the document is opened with the user password * * @since 2.0.7 */ public static final int ALLOW_FILL_IN = 256; - /** The operation permitted when the document is opened with the user password + /** + * The operation permitted when the document is opened with the user password * * @since 2.0.7 */ public static final int ALLOW_SCREENREADERS = 512; - /** The operation permitted when the document is opened with the user password + /** + * The operation permitted when the document is opened with the user password * * @since 2.0.7 */ public static final int ALLOW_ASSEMBLY = 1024; - /** The operation permitted when the document is opened with the user password + /** + * The operation permitted when the document is opened with the user password * * @since 2.0.7 */ public static final int ALLOW_DEGRADED_PRINTING = 4; - /** Contains the business logic for cryptography. */ + /** + * Contains the business logic for cryptography. + */ protected PdfEncryption crypto; + PdfEncryption getEncryption() { return crypto; } - /** @see com.lowagie.text.pdf.interfaces.PdfEncryptionSettings#setEncryption(byte[], byte[], int, int) */ - public void setEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionType) throws DocumentException { - if (pdf.isOpen()) - throw new DocumentException(MessageLocalization.getComposedMessage("encryption.can.only.be.added.before.opening.the.document")); + /** + * @see com.lowagie.text.pdf.interfaces.PdfEncryptionSettings#setEncryption(byte[], byte[], int, int) + */ + public void setEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionType) + throws DocumentException { + if (pdf.isOpen()) { + throw new DocumentException( + MessageLocalization.getComposedMessage("encryption.can.only.be.added.before.opening.the.document")); + } crypto = new PdfEncryption(); crypto.setCryptoMode(encryptionType, 0); crypto.setupAllKeys(userPassword, ownerPassword, permissions); } - /** @see com.lowagie.text.pdf.interfaces.PdfEncryptionSettings#setEncryption(java.security.cert.Certificate[], int[], int) */ + /** + * @see com.lowagie.text.pdf.interfaces.PdfEncryptionSettings#setEncryption(java.security.cert.Certificate[], int[], + * int) + */ public void setEncryption(Certificate[] certs, int[] permissions, int encryptionType) throws DocumentException { - if (pdf.isOpen()) - throw new DocumentException(MessageLocalization.getComposedMessage("encryption.can.only.be.added.before.opening.the.document")); + if (pdf.isOpen()) { + throw new DocumentException( + MessageLocalization.getComposedMessage("encryption.can.only.be.added.before.opening.the.document")); + } crypto = new PdfEncryption(); if (certs != null) { - for (int i=0; i < certs.length; i++) { + for (int i = 0; i < certs.length; i++) { crypto.addRecipient(certs[i], permissions[i]); } } @@ -1979,14 +2220,16 @@ public void setEncryption(Certificate[] certs, int[] permissions, int encryption crypto.getEncryptionDictionary(); } - // [F2] compression - /** Holds value of property fullCompression. */ + /** + * Holds value of property fullCompression. + */ protected boolean fullCompression = false; /** * Use this method to find out if 1.5 compression is on. + * * @return the 1.5 compression status */ public boolean isFullCompression() { @@ -1994,9 +2237,8 @@ public boolean isFullCompression() { } /** - * Use this method to set the document's compression to the - * PDF 1.5 mode with object streams and xref streams. - * It can be set at any time but once set it can't be unset. + * Use this method to set the document's compression to the PDF 1.5 mode with object streams and xref streams. It + * can be set at any time but once set it can't be unset. *

* If set before opening the document it will also set the pdf version to 1.5. */ @@ -2007,12 +2249,14 @@ public void setFullCompression() { /** * The compression level of the content streams. + * * @since 2.1.3 */ protected int compressionLevel = PdfStream.DEFAULT_COMPRESSION; /** * Returns the compression level used for streams written by this writer. + * * @return the compression level (0 = best speed, 9 = best compression, -1 is default) * @since 2.1.3 */ @@ -2022,35 +2266,41 @@ public int getCompressionLevel() { /** * Sets the compression level to be used for streams written by this writer. + * * @param compressionLevel a value between 0 (best speed) and 9 (best compression) * @since 2.1.3 */ public void setCompressionLevel(int compressionLevel) { - if (compressionLevel < PdfStream.NO_COMPRESSION || compressionLevel > PdfStream.BEST_COMPRESSION) + if (compressionLevel < PdfStream.NO_COMPRESSION || compressionLevel > PdfStream.BEST_COMPRESSION) { this.compressionLevel = PdfStream.DEFAULT_COMPRESSION; - else + } else { this.compressionLevel = compressionLevel; + } } // [F3] adding fonts - /** The fonts of this document */ + /** + * The fonts of this document + */ protected LinkedHashMap documentFonts = new LinkedHashMap<>(); - /** The font number counter for the fonts in the document. */ + /** + * The font number counter for the fonts in the document. + */ protected int fontNumber = 1; /** - * Adds a BaseFont to the document but not to the page resources. - * It is used for templates. + * Adds a BaseFont to the document but not to the page resources. It is used for templates. + * * @param bf the BaseFont to add - * @return an Object[] where position 0 is a PdfName - * and position 1 is an PdfIndirectReference + * @return an Object[] where position 0 is a PdfName and position 1 is an + * PdfIndirectReference */ FontDetails addSimple(BaseFont bf) { if (bf.getFontType() == BaseFont.FONT_TYPE_DOCUMENT) { - return new FontDetails(new PdfName("F" + (fontNumber++)), ((DocumentFont)bf).getIndirectReference(), bf); + return new FontDetails(new PdfName("F" + (fontNumber++)), ((DocumentFont) bf).getIndirectReference(), bf); } FontDetails ret = documentFonts.get(bf); if (ret == null) { @@ -2063,23 +2313,28 @@ FontDetails addSimple(BaseFont bf) { void eliminateFontSubset(PdfDictionary fonts) { for (FontDetails ft : documentFonts.values()) { - if (fonts.get(ft.getFontName()) != null) + if (fonts.get(ft.getFontName()) != null) { ft.setSubset(false); + } } } // [F4] adding (and releasing) form XObjects - /** The form XObjects in this document. The key is the xref and the value - is Object[]{PdfName, template}.*/ + /** + * The form XObjects in this document. The key is the xref and the value is Object[]{PdfName, template}. + */ protected LinkedHashMap formXObjects = new LinkedHashMap<>(); - /** The name counter for the form XObjects name. */ + /** + * The name counter for the form XObjects name. + */ protected int formXObjectsCounter = 1; /** * Adds a template to the document but not to the page resources. - * @param template the template to add + * + * @param template the template to add * @param forcedName the template name, rather than a generated one. Can be null * @return the PdfName for this template */ @@ -2087,18 +2342,18 @@ void eliminateFontSubset(PdfDictionary fonts) { PdfName addDirectTemplateSimple(PdfTemplate template, PdfName forcedName) { PdfIndirectReference ref = template.getIndirectReference(); Object[] obj = formXObjects.get(ref); - PdfName name = null; + PdfName name; try { if (obj == null) { if (forcedName == null) { name = new PdfName("Xf" + formXObjectsCounter); ++formXObjectsCounter; - } - else + } else { name = forcedName; + } if (template.getType() == PdfTemplate.TYPE_IMPORTED) { // If we got here from PdfCopy we'll have to fill importedPages - PdfImportedPage ip = (PdfImportedPage)template; + PdfImportedPage ip = (PdfImportedPage) template; PdfReader r = ip.getPdfReaderInstance().getReader(); if (!importedPages.containsKey(r)) { importedPages.put(r, ip.getPdfReaderInstance()); @@ -2106,32 +2361,32 @@ PdfName addDirectTemplateSimple(PdfTemplate template, PdfName forcedName) { template = null; } formXObjects.put(ref, new Object[]{name, template}); + } else { + name = (PdfName) obj[0]; } - else - name = (PdfName)obj[0]; - } - catch (Exception e) { + } catch (Exception e) { throw new ExceptionConverter(e); } return name; } /** - * Use this method to releases the memory used by a template. - * This method writes the template to the output. - * The template can still be added to any content - * but changes to the template itself won't have any effect. + * Use this method to releases the memory used by a template. This method writes the template to the output. The + * template can still be added to any content but changes to the template itself won't have any effect. + * * @param tp the template to release * @throws IOException on error */ public void releaseTemplate(PdfTemplate tp) throws IOException { PdfIndirectReference ref = tp.getIndirectReference(); Object[] objs = formXObjects.get(ref); - if (objs == null || objs[1] == null) + if (objs == null || objs[1] == null) { return; - PdfTemplate template = (PdfTemplate)objs[1]; - if (template.getIndirectReference() instanceof PRIndirectReference) + } + PdfTemplate template = (PdfTemplate) objs[1]; + if (template.getIndirectReference() instanceof PRIndirectReference) { return; + } if (template.getType() == PdfTemplate.TYPE_TEMPLATE) { addToBody(template.getFormXObject(compressionLevel), template.getIndirectReference()); objs[1] = null; @@ -2143,11 +2398,10 @@ public void releaseTemplate(PdfTemplate tp) throws IOException { protected HashMap importedPages = new HashMap<>(); /** - * Use this method to get a page from other PDF document. - * The page can be used as any other PdfTemplate. - * Note that calling this method more than once with the same parameters - * will retrieve the same object. - * @param reader the PDF document where the page is + * Use this method to get a page from other PDF document. The page can be used as any other PdfTemplate. Note that + * calling this method more than once with the same parameters will retrieve the same object. + * + * @param reader the PDF document where the page is * @param pageNumber the page number. The first page is 1 * @return the template representing the imported page */ @@ -2161,34 +2415,31 @@ public PdfImportedPage getImportedPage(PdfReader reader, int pageNumber) { } /** - * Use this method to writes the reader to the document - * and free the memory used by it. - * The main use is when concatenating multiple documents - * to keep the memory usage restricted to the current - * appending document. + * Use this method to writes the reader to the document and free the memory used by it. The main use is when + * concatenating multiple documents to keep the memory usage restricted to the current appending document. + * * @param reader the PdfReader to free * @throws IOException on error */ public void freeReader(PdfReader reader) throws IOException { currentPdfReaderInstance = importedPages.get(reader); - if (currentPdfReaderInstance == null) + if (currentPdfReaderInstance == null) { return; + } currentPdfReaderInstance.writeAllPages(); currentPdfReaderInstance = null; importedPages.remove(reader); } /** - * Use this method to gets the current document size. - * This size only includes the data already written - * to the output stream, it does not include templates or fonts. - * It is useful if used with freeReader() - * when concatenating many documents and an idea of - * the current size is needed. + * Use this method to gets the current document size. This size only includes the data already written to the output + * stream, it does not include templates or fonts. It is useful if used with freeReader() when + * concatenating many documents and an idea of the current size is needed. + * * @return the approximate size without fonts or templates */ public long getCurrentDocumentSize() { - return body.offset() + (long)body.size() * 20L + 0x48; + return body.offset() + (long) body.size() * 20L + 0x48; } protected PdfReaderInstance currentPdfReaderInstance; @@ -2209,10 +2460,14 @@ RandomAccessFileOrArray getReaderFile(PdfReader reader) { // [F6] spot colors - /** The colors of this document */ + /** + * The colors of this document + */ protected HashMap documentColors = new HashMap<>(); - /** The color number counter for the colors in the document. */ + /** + * The color number counter for the colors in the document. + */ protected int colorNumber = 1; PdfName getColorspaceName() { @@ -2221,9 +2476,10 @@ PdfName getColorspaceName() { /** * Adds a SpotColor to the document but not to the page resources. + * * @param spc the SpotColor to add - * @return an Object[] where position 0 is a PdfName - * and position 1 is an PdfIndirectReference + * @return an Object[] where position 0 is a PdfName and position 1 is an + * PdfIndirectReference */ ColorDetails addSimple(PdfSpotColor spc) { ColorDetails ret = documentColors.get(spc); @@ -2236,16 +2492,20 @@ ColorDetails addSimple(PdfSpotColor spc) { // [F7] document patterns - /** The patterns of this document */ + /** + * The patterns of this document + */ protected HashMap documentPatterns = new HashMap<>(); - /** The pattern number counter for the colors in the document. */ + /** + * The pattern number counter for the colors in the document. + */ protected int patternNumber = 1; PdfName addSimplePattern(PdfPatternPainter painter) { PdfName name = documentPatterns.get(painter); try { - if ( name == null ) { + if (name == null) { name = new PdfName("P" + patternNumber); ++patternNumber; documentPatterns.put(painter, name); @@ -2287,7 +2547,8 @@ void addSimpleShading(PdfShading shading) { PdfObject[] addSimpleExtGState(PdfDictionary gstate) { if (!documentExtGState.containsKey(gstate)) { PdfXConformanceImp.checkPDFXConformance(this, PdfXConformanceImp.PDFXKEY_GSTATE, gstate); - documentExtGState.put(gstate, new PdfObject[]{new PdfName("GS" + (documentExtGState.size() + 1)), getPdfIndirectReference()}); + documentExtGState.put(gstate, + new PdfObject[]{new PdfName("GS" + (documentExtGState.size() + 1)), getPdfIndirectReference()}); } return documentExtGState.get(gstate); } @@ -2298,8 +2559,9 @@ PdfObject[] addSimpleExtGState(PdfDictionary gstate) { PdfObject[] addSimpleProperty(Object prop, PdfIndirectReference refi) { if (!documentProperties.containsKey(prop)) { - if (prop instanceof PdfOCG) + if (prop instanceof PdfOCG) { PdfXConformanceImp.checkPDFXConformance(this, PdfXConformanceImp.PDFXKEY_LAYER, null); + } documentProperties.put(prop, new PdfObject[]{new PdfName("Pr" + (documentProperties.size() + 1)), refi}); } return documentProperties.get(prop); @@ -2318,13 +2580,16 @@ boolean propertyExists(Object prop) { * Mark this document for tagging. It must be called before open. */ public void setTagged() { - if (open) - throw new IllegalArgumentException(MessageLocalization.getComposedMessage("tagging.must.be.set.before.opening.the.document")); + if (open) { + throw new IllegalArgumentException( + MessageLocalization.getComposedMessage("tagging.must.be.set.before.opening.the.document")); + } tagged = true; } /** * Check if the document is marked for tagging. + * * @return true if the document is marked for tagging */ public boolean isTagged() { @@ -2333,34 +2598,45 @@ public boolean isTagged() { /** * Gets the structure tree root. If the document is not marked for tagging it will return null. + * * @return the structure tree root */ public PdfStructureTreeRoot getStructureTreeRoot() { - if (tagged && structureTreeRoot == null) + if (tagged && structureTreeRoot == null) { structureTreeRoot = new PdfStructureTreeRoot(this); + } return structureTreeRoot; } // [F13] Optional Content Groups - /** A hashSet containing all the PdfLayer objects. */ + /** + * A hashSet containing all the PdfLayer objects. + */ protected Set documentOCG = new HashSet<>(); - /** An array list used to define the order of an OCG tree. */ + /** + * An array list used to define the order of an OCG tree. + */ protected List documentOCGorder = new ArrayList<>(); - /** The OCProperties in a catalog dictionary. */ + /** + * The OCProperties in a catalog dictionary. + */ protected PdfOCProperties OCProperties; - /** The RBGroups array in an OCG dictionary */ + /** + * The RBGroups array in an OCG dictionary + */ protected PdfArray OCGRadioGroup = new PdfArray(); /** * The locked array in an OCG dictionary - * @since 2.1.2 + * + * @since 2.1.2 */ protected PdfArray OCGLocked = new PdfArray(); /** - * Use this method to get the Optional Content Properties Dictionary. - * Each call fills the dictionary with the current layer state. - * It's advisable to only call this method right before close - * and do any modifications at that time. + * Use this method to get the Optional Content Properties Dictionary. Each call fills the dictionary with the + * current layer state. It's advisable to only call this method right before close and do any modifications at that + * time. + * * @return the Optional Content Properties Dictionary */ public PdfOCProperties getOCProperties() { @@ -2369,52 +2645,58 @@ public PdfOCProperties getOCProperties() { } /** - * Use this method to set a collection of optional content groups - * whose states are intended to follow a "radio button" paradigm. - * That is, the state of at most one optional content group - * in the array should be ON at a time: if one group is turned - * ON, all others must be turned OFF. + * Use this method to set a collection of optional content groups whose states are intended to follow a "radio + * button" paradigm. That is, the state of at most one optional content group in the array should be ON at a time: + * if one group is turned ON, all others must be turned OFF. + * * @param group the radio group */ public void addOCGRadioGroup(List group) { PdfArray ar = new PdfArray(); for (PdfLayer layer : group) { - if (layer.getTitle() == null) + if (layer.getTitle() == null) { ar.add(layer.getRef()); + } } - if (ar.size() == 0) + if (ar.isEmpty()) { return; + } OCGRadioGroup.add(ar); } /** - * Use this method to lock an optional content group. - * The state of a locked group cannot be changed through the user interface - * of a viewer application. Producers can use this entry to prevent the visibility - * of content that depends on these groups from being changed by users. - * @param layer the layer that needs to be added to the array of locked OCGs - * @since 2.1.2 + * Use this method to lock an optional content group. The state of a locked group cannot be changed through the user + * interface of a viewer application. Producers can use this entry to prevent the visibility of content that depends + * on these groups from being changed by users. + * + * @param layer the layer that needs to be added to the array of locked OCGs + * @since 2.1.2 */ public void lockLayer(PdfLayer layer) { OCGLocked.add(layer.getRef()); } private static void getOCGOrder(PdfArray order, PdfLayer layer) { - if (!layer.isOnPanel()) + if (!layer.isOnPanel()) { return; - if (layer.getTitle() == null) + } + if (layer.getTitle() == null) { order.add(layer.getRef()); + } ArrayList children = layer.getChildren(); - if (children == null) + if (children == null) { return; + } PdfArray kids = new PdfArray(); - if (layer.getTitle() != null) + if (layer.getTitle() != null) { kids.add(new PdfString(layer.getTitle(), PdfObject.TEXT_UNICODE)); + } for (PdfLayer child : children) { getOCGOrder(kids, child); } - if (kids.size() > 0) + if (!kids.isEmpty()) { order.add(kids); + } } private void addASEvent(PdfName event, PdfName category) { @@ -2422,13 +2704,15 @@ private void addASEvent(PdfName event, PdfName category) { for (PdfOCG o : documentOCG) { PdfLayer layer = (PdfLayer) o; PdfDictionary usage = layer.getAsDict(PdfName.USAGE); - if (usage != null && usage.get(category) != null) + if (usage != null && usage.get(category) != null) { arr.add(layer.getRef()); + } } - if (arr.size() == 0) + if (arr.isEmpty()) { return; - PdfDictionary d = (PdfDictionary)OCProperties.get(PdfName.D); - PdfArray arras = (PdfArray)d.get(PdfName.AS); + } + PdfDictionary d = (PdfDictionary) OCProperties.get(PdfName.D); + PdfArray arras = (PdfArray) d.get(PdfName.AS); if (arras == null) { arras = new PdfArray(); d.put(PdfName.AS, arras); @@ -2441,12 +2725,13 @@ private void addASEvent(PdfName event, PdfName category) { } /** - * @since 2.1.2 * @param erase true to erase, false otherwise + * @since 2.1.2 */ protected void fillOCProperties(boolean erase) { - if (OCProperties == null) + if (OCProperties == null) { OCProperties = new PdfOCProperties(); + } if (erase) { OCProperties.remove(PdfName.OCGS); OCProperties.remove(PdfName.D); @@ -2459,12 +2744,13 @@ protected void fillOCProperties(boolean erase) { } OCProperties.put(PdfName.OCGS, gr); } - if (OCProperties.get(PdfName.D) != null) + if (OCProperties.get(PdfName.D) != null) { return; + } List docOrder = documentOCGorder.stream() - .filter(pdfOCG -> ((PdfLayer)pdfOCG).getParent() == null) - .collect(Collectors.toList()); + .filter(pdfOCG -> ((PdfLayer) pdfOCG).getParent() == null) + .collect(Collectors.toList()); PdfArray order = new PdfArray(); for (PdfOCG o1 : docOrder) { @@ -2477,15 +2763,19 @@ protected void fillOCProperties(boolean erase) { PdfArray gr = new PdfArray(); for (PdfOCG o : documentOCG) { PdfLayer layer = (PdfLayer) o; - if (!layer.isOn()) + if (!layer.isOn()) { gr.add(layer.getRef()); + } } - if (gr.size() > 0) + if (!gr.isEmpty()) { d.put(PdfName.OFF, gr); - if (OCGRadioGroup != null && OCGRadioGroup.size() > 0) + } + if (OCGRadioGroup != null && !OCGRadioGroup.isEmpty()) { d.put(PdfName.RBGROUPS, OCGRadioGroup); - if (OCGLocked != null && OCGLocked.size() > 0) + } + if (OCGLocked != null && !OCGLocked.isEmpty()) { d.put(PdfName.LOCKED, OCGLocked); + } addASEvent(PdfName.VIEW, PdfName.ZOOM); addASEvent(PdfName.VIEW, PdfName.VIEW); addASEvent(PdfName.PRINT, PdfName.PRINT); @@ -2495,20 +2785,18 @@ protected void fillOCProperties(boolean erase) { void registerLayer(PdfOCG layer) { PdfXConformanceImp.checkPDFXConformance(this, PdfXConformanceImp.PDFXKEY_LAYER, null); - if (layer instanceof PdfLayer) { - PdfLayer la = (PdfLayer)layer; + if (layer instanceof PdfLayer la) { if (la.getTitle() == null) { if (!documentOCG.contains(layer)) { documentOCG.add(layer); documentOCGorder.add(layer); } - } - else { + } else { documentOCGorder.add(layer); } - } - else + } else { throw new IllegalArgumentException(MessageLocalization.getComposedMessage("only.pdflayer.is.accepted")); + } } // User methods to change aspects of the page @@ -2517,6 +2805,7 @@ void registerLayer(PdfOCG layer) { /** * Use this method to get the size of the media box. + * * @return a Rectangle */ public Rectangle getPageSize() { @@ -2524,9 +2813,9 @@ public Rectangle getPageSize() { } /** - * Use this method to set the crop box. - * The crop box should not be rotated even if the page is rotated. - * This change only takes effect in the next page. + * Use this method to set the crop box. The crop box should not be rotated even if the page is rotated. This change + * only takes effect in the next page. + * * @param crop the crop box */ public void setCropBoxSize(Rectangle crop) { @@ -2534,18 +2823,18 @@ public void setCropBoxSize(Rectangle crop) { } /** - * Use this method to set the page box sizes. - * Allowed names are: "crop", "trim", "art" and "bleed". + * Use this method to set the page box sizes. Allowed names are: "crop", "trim", "art" and "bleed". + * * @param boxName the box size - * @param size the size + * @param size the size */ public void setBoxSize(String boxName, Rectangle size) { pdf.setBoxSize(boxName, size); } /** - * Use this method to get the size of a trim, art, crop or bleed box, - * or null if not defined. + * Use this method to get the size of a trim, art, crop or bleed box, or null if not defined. + * * @param boxName crop, trim, art or bleed * @return the Rectangle */ @@ -2556,20 +2845,21 @@ public Rectangle getBoxSize(String boxName) { // [U2] take care of empty pages /** - * Use this method to make sure a page is added, - * even if it's empty. If you use setPageEmpty(false), - * invoking newPage() after a blank page will add a newPage. - * setPageEmpty(true) won't have any effect. + * Use this method to make sure a page is added, even if it's empty. If you use setPageEmpty(false), invoking + * newPage() after a blank page will add a newPage. setPageEmpty(true) won't have any effect. + * * @param pageEmpty the state */ public void setPageEmpty(boolean pageEmpty) { - if (pageEmpty) + if (pageEmpty) { return; + } pdf.setPageEmpty(pageEmpty); } /** * Checks if a newPage() will actually generate a new page. + * * @return true if a new page will be generated, false otherwise * @since 2.1.8 */ @@ -2579,34 +2869,49 @@ public boolean isPageEmpty() { // [U3] page actions (open and close) - /** action value */ + /** + * action value + */ public static final PdfName PAGE_OPEN = PdfName.O; - /** action value */ + /** + * action value + */ public static final PdfName PAGE_CLOSE = PdfName.C; - /** @see com.lowagie.text.pdf.interfaces.PdfPageActions#setPageAction(com.lowagie.text.pdf.PdfName, com.lowagie.text.pdf.PdfAction) */ + /** + * @see com.lowagie.text.pdf.interfaces.PdfPageActions#setPageAction(com.lowagie.text.pdf.PdfName, + * com.lowagie.text.pdf.PdfAction) + */ public void setPageAction(PdfName actionType, PdfAction action) throws DocumentException { - if (!actionType.equals(PAGE_OPEN) && !actionType.equals(PAGE_CLOSE)) - throw new DocumentException(MessageLocalization.getComposedMessage("invalid.page.additional.action.type.1", actionType.toString())); - pdf.setPageAction(actionType, action); - } + if (!actionType.equals(PAGE_OPEN) && !actionType.equals(PAGE_CLOSE)) { + throw new DocumentException( + MessageLocalization.getComposedMessage("invalid.page.additional.action.type.1", + actionType.toString())); + } + pdf.setPageAction(actionType, action); + } - /** @see com.lowagie.text.pdf.interfaces.PdfPageActions#setDuration(int) */ + /** + * @see com.lowagie.text.pdf.interfaces.PdfPageActions#setDuration(int) + */ public void setDuration(int seconds) { - pdf.setDuration(seconds); - } + pdf.setDuration(seconds); + } - /** @see com.lowagie.text.pdf.interfaces.PdfPageActions#setTransition(com.lowagie.text.pdf.PdfTransition) */ + /** + * @see com.lowagie.text.pdf.interfaces.PdfPageActions#setTransition(com.lowagie.text.pdf.PdfTransition) + */ public void setTransition(PdfTransition transition) { - pdf.setTransition(transition); - } + pdf.setTransition(transition); + } // [U4] Thumbnail image /** * Use this method to set the thumbnail image for the current page. + * * @param image the image - * @throws PdfException on error + * @throws PdfException on error * @throws DocumentException or error */ public void setThumbnail(Image image) throws DocumentException { @@ -2616,14 +2921,14 @@ public void setThumbnail(Image image) throws DocumentException { // [U5] Transparency groups /** - * A group attributes dictionary specifying the attributes - * of the page's page group for use in the transparent + * A group attributes dictionary specifying the attributes of the page's page group for use in the transparent * imaging model */ protected PdfDictionary group; /** * Use this method to get the group dictionary. + * * @return Value of property group. */ public PdfDictionary getGroup() { @@ -2632,6 +2937,7 @@ public PdfDictionary getGroup() { /** * Use this method to set the group dictionary. + * * @param group New value of property group. */ public void setGroup(PdfDictionary group) { @@ -2640,20 +2946,24 @@ public void setGroup(PdfDictionary group) { // [U6] space char ratio - /** The default space-char ratio. */ + /** + * The default space-char ratio. + */ public static final float SPACE_CHAR_RATIO_DEFAULT = 2.5f; - /** Disable the inter-character spacing. */ + /** + * Disable the inter-character spacing. + */ public static final float NO_SPACE_CHAR_RATIO = 10000000f; /** - * The ratio between the extra word spacing and the extra character spacing. - * Extra word spacing will grow ratio times more than extra character spacing. + * The ratio between the extra word spacing and the extra character spacing. Extra word spacing will grow + * ratio times more than extra character spacing. */ private float spaceCharRatio = SPACE_CHAR_RATIO_DEFAULT; /** - * Use this method to gets the space/character extra spacing ratio - * for fully justified text. + * Use this method to gets the space/character extra spacing ratio for fully justified text. + * * @return the space/character extra spacing ratio */ public float getSpaceCharRatio() { @@ -2661,51 +2971,54 @@ public float getSpaceCharRatio() { } /** - * Use this method to set the ratio between the extra word spacing and - * the extra character spacing when the text is fully justified. - * Extra word spacing will grow spaceCharRatio times more - * than extra character spacing. If the ratio is PdfWriter.NO_SPACE_CHAR_RATIO - * then the extra character spacing will be zero. + * Use this method to set the ratio between the extra word spacing and the extra character spacing when the text is + * fully justified. Extra word spacing will grow spaceCharRatio times more than extra character + * spacing. If the ratio is PdfWriter.NO_SPACE_CHAR_RATIO then the extra character spacing will be + * zero. + * * @param spaceCharRatio the ratio between the extra word spacing and the extra character spacing */ public void setSpaceCharRatio(float spaceCharRatio) { - if (spaceCharRatio < 0.001f) - this.spaceCharRatio = 0.001f; - else - this.spaceCharRatio = spaceCharRatio; + this.spaceCharRatio = Math.max(spaceCharRatio, 0.001f); } // [U7] run direction (doesn't actually do anything) - /** Use the default run direction. */ + /** + * Use the default run direction. + */ public static final int RUN_DIRECTION_DEFAULT = 0; - /** Do not use bidirectional reordering. */ + /** + * Do not use bidirectional reordering. + */ public static final int RUN_DIRECTION_NO_BIDI = 1; - /** Use bidirectional reordering with left-to-right - * preferential run direction. + /** + * Use bidirectional reordering with left-to-right preferential run direction. */ public static final int RUN_DIRECTION_LTR = 2; - /** Use bidirectional reordering with right-to-left - * preferential run direction. + /** + * Use bidirectional reordering with right-to-left preferential run direction. */ public static final int RUN_DIRECTION_RTL = 3; protected int runDirection = RUN_DIRECTION_NO_BIDI; /** - * Use this method to set the run direction. - * This is only used as a placeholder as it does not affect anything. + * Use this method to set the run direction. This is only used as a placeholder as it does not affect anything. + * * @param runDirection the run direction */ public void setRunDirection(int runDirection) { - if (runDirection < RUN_DIRECTION_NO_BIDI || runDirection > RUN_DIRECTION_RTL) + if (runDirection < RUN_DIRECTION_NO_BIDI || runDirection > RUN_DIRECTION_RTL) { throw new RuntimeException(MessageLocalization.getComposedMessage("invalid.run.direction.1", runDirection)); + } this.runDirection = runDirection; } /** * Use this method to set the run direction. + * * @return the run direction */ public int getRunDirection() { @@ -2714,40 +3027,45 @@ public int getRunDirection() { // [U8] user units - protected float userunit = 0f; + protected float userunit = 0f; + /** - * Use this method to get the user unit. - * A user unit is a value that defines the default user space unit. - * The minimum UserUnit is 1 (1 unit = 1/72 inch). - * The maximum UserUnit is 75,000. - * Note that this userunit only works starting with PDF1.6! + * Use this method to get the user unit. A user unit is a value that defines the default user space unit. The + * minimum UserUnit is 1 (1 unit = 1/72 inch). The maximum UserUnit is 75,000. Note that this userunit only works + * starting with PDF1.6! + * * @return Returns the userunit. */ public float getUserunit() { return userunit; } + /** - * Use this method to set the user unit. - * A UserUnit is a value that defines the default user space unit. - * The minimum UserUnit is 1 (1 unit = 1/72 inch). - * The maximum UserUnit is 75,000. - * Note that this userunit only works starting with PDF1.6! + * Use this method to set the user unit. A UserUnit is a value that defines the default user space unit. The minimum + * UserUnit is 1 (1 unit = 1/72 inch). The maximum UserUnit is 75,000. Note that this userunit only works starting + * with PDF1.6! + * * @param userunit The userunit to set. * @throws DocumentException on error */ - public void setUserunit(float userunit) throws DocumentException { - if (userunit < 1f || userunit > 75000f) throw new DocumentException(MessageLocalization.getComposedMessage("userunit.should.be.a.value.between.1.and.75000")); - this.userunit = userunit; - setAtLeastPdfVersion(VERSION_1_6); - } + public void setUserunit(float userunit) throws DocumentException { + if (userunit < 1f || userunit > 75000f) { + throw new DocumentException( + MessageLocalization.getComposedMessage("userunit.should.be.a.value.between.1.and.75000")); + } + this.userunit = userunit; + setAtLeastPdfVersion(VERSION_1_6); + } // Miscellaneous topics // [M1] Color settings protected PdfDictionary defaultColorspace = new PdfDictionary(); + /** * Use this method to get the default colorspaces. + * * @return the default colorspaces */ public PdfDictionary getDefaultColorspace() { @@ -2755,19 +3073,19 @@ public PdfDictionary getDefaultColorspace() { } /** - * Use this method to sets the default colorspace that will be applied - * to all the document. The colorspace is only applied if another colorspace - * with the same name is not present in the content. + * Use this method to sets the default colorspace that will be applied to all the document. The colorspace is only + * applied if another colorspace with the same name is not present in the content. *

- * The colorspace is applied immediately when creating templates and - * at the page end for the main document content. - * @param key the name of the colorspace. It can be PdfName.DEFAULTGRAY, PdfName.DEFAULTRGB - * or PdfName.DEFAULTCMYK - * @param cs the colorspace. A null or PdfNull removes any colorspace with the same name + * The colorspace is applied immediately when creating templates and at the page end for the main document content. + * + * @param key the name of the colorspace. It can be PdfName.DEFAULTGRAY, + * PdfName.DEFAULTRGB or PdfName.DEFAULTCMYK + * @param cs the colorspace. A null or PdfNull removes any colorspace with the same name */ public void setDefaultColorspace(PdfName key, PdfObject cs) { - if (cs == null || cs.isNull()) + if (cs == null || cs.isNull()) { defaultColorspace.remove(key); + } defaultColorspace.put(key, cs); } @@ -2780,13 +3098,16 @@ public void setDefaultColorspace(PdfName key, PdfObject cs) { ColorDetails addSimplePatternColorspace(Color color) { int type = ExtendedColor.getType(color); - if (type == ExtendedColor.TYPE_PATTERN || type == ExtendedColor.TYPE_SHADING) - throw new RuntimeException(MessageLocalization.getComposedMessage("an.uncolored.tile.pattern.can.not.have.another.pattern.or.shading.as.color")); + if (type == ExtendedColor.TYPE_PATTERN || type == ExtendedColor.TYPE_SHADING) { + throw new RuntimeException(MessageLocalization.getComposedMessage( + "an.uncolored.tile.pattern.can.not.have.another.pattern.or.shading.as.color")); + } try { switch (type) { case ExtendedColor.TYPE_RGB: if (patternColorspaceRGB == null) { - patternColorspaceRGB = new ColorDetails(getColorspaceName(), body.getPdfIndirectReference(), null); + patternColorspaceRGB = new ColorDetails(getColorspaceName(), body.getPdfIndirectReference(), + null); PdfArray array = new PdfArray(PdfName.PATTERN); array.add(PdfName.DEVICERGB); addToBody(array, patternColorspaceRGB.getIndirectReference()); @@ -2794,7 +3115,8 @@ ColorDetails addSimplePatternColorspace(Color color) { return patternColorspaceRGB; case ExtendedColor.TYPE_CMYK: if (patternColorspaceCMYK == null) { - patternColorspaceCMYK = new ColorDetails(getColorspaceName(), body.getPdfIndirectReference(), null); + patternColorspaceCMYK = new ColorDetails(getColorspaceName(), body.getPdfIndirectReference(), + null); PdfArray array = new PdfArray(PdfName.PATTERN); array.add(PdfName.DEVICECMYK); addToBody(array, patternColorspaceCMYK.getIndirectReference()); @@ -2802,14 +3124,15 @@ ColorDetails addSimplePatternColorspace(Color color) { return patternColorspaceCMYK; case ExtendedColor.TYPE_GRAY: if (patternColorspaceGRAY == null) { - patternColorspaceGRAY = new ColorDetails(getColorspaceName(), body.getPdfIndirectReference(), null); + patternColorspaceGRAY = new ColorDetails(getColorspaceName(), body.getPdfIndirectReference(), + null); PdfArray array = new PdfArray(PdfName.PATTERN); array.add(PdfName.DEVICEGRAY); addToBody(array, patternColorspaceGRAY.getIndirectReference()); } return patternColorspaceGRAY; case ExtendedColor.TYPE_SEPARATION: { - ColorDetails details = addSimple(((SpotColor)color).getPdfSpotColor()); + ColorDetails details = addSimple(((SpotColor) color).getPdfSpotColor()); ColorDetails patternDetails = documentSpotPatterns.get(details); if (patternDetails == null) { patternDetails = new ColorDetails(getColorspaceName(), body.getPdfIndirectReference(), null); @@ -2823,8 +3146,7 @@ ColorDetails addSimplePatternColorspace(Color color) { default: throw new RuntimeException(MessageLocalization.getComposedMessage("invalid.color.type")); } - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e.getMessage()); } } @@ -2833,6 +3155,7 @@ ColorDetails addSimplePatternColorspace(Color color) { /** * Use this method to get the strictImageSequence status. + * * @return value of property strictImageSequence */ public boolean isStrictImageSequence() { @@ -2840,10 +3163,9 @@ public boolean isStrictImageSequence() { } /** - * Use this method to set the image sequence, so that it follows - * the text in strict order (or not). - * @param strictImageSequence new value of property strictImageSequence + * Use this method to set the image sequence, so that it follows the text in strict order (or not). * + * @param strictImageSequence new value of property strictImageSequence */ public void setStrictImageSequence(boolean strictImageSequence) { pdf.setStrictImageSequence(strictImageSequence); @@ -2851,26 +3173,30 @@ public void setStrictImageSequence(boolean strictImageSequence) { /** * Use this method to clear text wrapping around images (if applicable). + * * @throws DocumentException on error */ public void clearTextWrap() throws DocumentException { pdf.clearTextWrap(); } - /** Dictionary, containing all the images of the PDF document */ + /** + * Dictionary, containing all the images of the PDF document + */ protected PdfDictionary imageDictionary = new PdfDictionary(); - /** This is the list with all the images in the document. */ - private HashMap images = new HashMap<>(); + /** + * This is the list with all the images in the document. + */ + private final HashMap images = new HashMap<>(); /** - * Use this method to adds an image to the document - * but not to the page resources. It is used with - * templates and Document.add(Image). - * Use this method only if you know what you're doing! + * Use this method to adds an image to the document but not to the page resources. It is used with templates and + * Document.add(Image). Use this method only if you know what you're doing! + * * @param image the Image to add * @return the name of the image added - * @throws PdfException on error + * @throws PdfException on error * @throws DocumentException on error */ public PdfName addDirectImageSimple(Image image) throws DocumentException { @@ -2878,14 +3204,14 @@ public PdfName addDirectImageSimple(Image image) throws DocumentException { } /** - * Adds an image to the document but not to the page resources. - * It is used with templates and Document.add(Image). - * Use this method only if you know what you're doing! - * @param image the Image to add - * @param fixedRef the reference to used. It may be null, - * a PdfIndirectReference or a PRIndirectReference. + * Adds an image to the document but not to the page resources. It is used with templates and + * Document.add(Image). Use this method only if you know what you're doing! + * + * @param image the Image to add + * @param fixedRef the reference to used. It may be null, a PdfIndirectReference or a + * PRIndirectReference. * @return the name of the image added - * @throws PdfException on error + * @throws PdfException on error * @throws DocumentException on error */ public PdfName addDirectImageSimple(Image image, PdfIndirectReference fixedRef) throws DocumentException { @@ -2898,17 +3224,15 @@ public PdfName addDirectImageSimple(Image image, PdfIndirectReference fixedRef) else { if (image.isImgTemplate()) { name = new PdfName("img" + images.size()); - if(image instanceof ImgWMF){ + if (image instanceof ImgWMF) { try { - ImgWMF wmf = (ImgWMF)image; + ImgWMF wmf = (ImgWMF) image; wmf.readWMF(PdfTemplate.createTemplate(this, 0, 0)); - } - catch (Exception e) { + } catch (Exception e) { throw new DocumentException(e); } } - } - else { + } else { PdfIndirectReference dref = image.getDirectReference(); if (dref != null) { PdfName rname = new PdfName("img" + images.size()); @@ -2939,13 +3263,14 @@ public PdfName addDirectImageSimple(Image image, PdfIndirectReference fixedRef) iccArray.add(iccRef); PdfArray colorspace = i.getAsArray(PdfName.COLORSPACE); if (colorspace != null) { - if (colorspace.size() > 1 && PdfName.INDEXED.equals(colorspace.getPdfObject(0))) + if (colorspace.size() > 1 && PdfName.INDEXED.equals(colorspace.getPdfObject(0))) { colorspace.set(1, iccArray); - else + } else { i.put(PdfName.COLORSPACE, iccArray); - } - else + } + } else { i.put(PdfName.COLORSPACE, iccArray); + } } add(i, fixedRef); name = i.name(); @@ -2964,19 +3289,19 @@ public PdfName addDirectImageSimple(Image image, PdfIndirectReference fixedRef) */ PdfIndirectReference add(PdfImage pdfImage, PdfIndirectReference fixedRef) throws PdfException { - if (! imageDictionary.contains(pdfImage.name())) { + if (!imageDictionary.contains(pdfImage.name())) { PdfXConformanceImp.checkPDFXConformance(this, PdfXConformanceImp.PDFXKEY_IMAGE, pdfImage); - if (fixedRef instanceof PRIndirectReference) { - PRIndirectReference r2 = (PRIndirectReference)fixedRef; - fixedRef = new PdfIndirectReference(0, getNewObjectNumber(r2.getReader(), r2.getNumber(), r2.getGeneration())); + if (fixedRef instanceof PRIndirectReference r2) { + fixedRef = new PdfIndirectReference(0, + getNewObjectNumber(r2.getReader(), r2.getNumber(), r2.getGeneration())); } try { - if (fixedRef == null) + if (fixedRef == null) { fixedRef = addToBody(pdfImage).getIndirectReference(); - else + } else { addToBody(pdfImage, fixedRef); - } - catch(IOException ioe) { + } + } catch (IOException ioe) { throw new ExceptionConverter(ioe); } imageDictionary.put(pdfImage.name(), fixedRef); @@ -3000,8 +3325,7 @@ protected PdfIndirectReference add(PdfICCBased icc) { PdfIndirectObject object; try { object = addToBody(icc); - } - catch(IOException ioe) { + } catch (IOException ioe) { throw new ExceptionConverter(ioe); } return object.getIndirectReference(); @@ -3009,18 +3333,23 @@ protected PdfIndirectReference add(PdfICCBased icc) { /** * A HashSet with Stream objects containing JBIG2 Globals + * * @since 2.1.5 */ protected HashMap JBIG2Globals = new HashMap<>(); + /** - * Gets an indirect reference to a JBIG2 Globals stream. - * Adds the stream if it hasn't already been added to the writer. - * @param content a byte array that may already been added to the writer inside a stream object. + * Gets an indirect reference to a JBIG2 Globals stream. Adds the stream if it hasn't already been added to the + * writer. + * + * @param content a byte array that may already been added to the writer inside a stream object. * @return the PdfIndirectReference - * @since 2.1.5 + * @since 2.1.5 */ protected PdfIndirectReference getReferenceJBIG2Globals(byte[] content) { - if (content == null) return null; + if (content == null) { + return null; + } PdfStream stream; for (PdfStream pdfStream : JBIG2Globals.keySet()) { stream = pdfStream; @@ -3044,9 +3373,9 @@ protected PdfIndirectReference getReferenceJBIG2Globals(byte[] content) { /** * Checks if a Table fits the current page of the PdfDocument. * - * @param table the table that has to be checked - * @param margin a certain margin - * @return true if the Table fits the page, false otherwise. + * @param table the table that has to be checked + * @param margin a certain margin + * @return true if the Table fits the page, false otherwise. */ public boolean fitsPage(Table table, float margin) { @@ -3056,8 +3385,8 @@ public boolean fitsPage(Table table, float margin) { /** * Checks if a Table fits the current page of the PdfDocument. * - * @param table the table that has to be checked - * @return true if the Table fits the page, false otherwise. + * @param table the table that has to be checked + * @return true if the Table fits the page, false otherwise. */ public boolean fitsPage(Table table) { @@ -3071,6 +3400,7 @@ public boolean fitsPage(Table table) { /** * Gets the flag indicating the presence of structure elements that contain user properties attributes. + * * @return the user properties flag */ public boolean isUserProperties() { @@ -3079,6 +3409,7 @@ public boolean isUserProperties() { /** * Sets the flag indicating the presence of structure elements that contain user properties attributes. + * * @param userProperties the user properties flag */ public void setUserProperties(boolean userProperties) { @@ -3092,6 +3423,7 @@ public void setUserProperties(boolean userProperties) { /** * Gets the transparency blending colorspace. + * * @return true if the transparency blending colorspace is RGB, false * if it is the default blending colorspace * @since 2.1.0 @@ -3101,13 +3433,14 @@ public boolean isRgbTransparencyBlending() { } /** - * Sets the transparency blending colorspace to RGB. The default blending colorspace is - * CMYK and will result in faded colors in the screen and in printing. Calling this method - * will return the RGB colors to what is expected. The RGB blending will be applied to all subsequent pages - * until other value is set. - * Note that this is a generic solution that may not work in all cases. - * @param rgbTransparencyBlending true to set the transparency blending colorspace to RGB, false - * to use the default blending colorspace + * Sets the transparency blending colorspace to RGB. The default blending colorspace is CMYK and will result in + * faded colors in the screen and in printing. Calling this method will return the RGB colors to what is expected. + * The RGB blending will be applied to all subsequent pages until other value is set. Note that this is a generic + * solution that may not work in all cases. + * + * @param rgbTransparencyBlending true to set the transparency blending colorspace to RGB, + * false + * to use the default blending colorspace * @since 2.1.0 */ public void setRgbTransparencyBlending(boolean rgbTransparencyBlending) { diff --git a/openpdf/src/main/resources/com/lowagie/text/error_messages/en.lng b/openpdf/src/main/resources/com/lowagie/text/error_messages/en.lng index 656740708..1a98455eb 100644 --- a/openpdf/src/main/resources/com/lowagie/text/error_messages/en.lng +++ b/openpdf/src/main/resources/com/lowagie/text/error_messages/en.lng @@ -368,7 +368,7 @@ unexpected.end.of.file=Unexpected end of file. unexpected.eof=Unexpected EOF unexpected.gt.gt=Unexpected '>>' unexpected.close.bracket=Unexpected ']' -unknown.color.format.must.be.rgb.or.rrggbb=Unknown color format. Must be #RGB or #RRGGBB +unknown.color.format.must.be.rgb.or.rrggbb=Unknown color format. Must be #RGB, #RRGGBB, #RGBA or #RRGGBBAA unknown.encryption.type.r.eq.1=Unknown encryption type R = {1} unknown.encryption.type.v.eq.1=Unknown encryption type V = {1} unknown.filter.1=Unknown filter: {1} @@ -387,6 +387,7 @@ while.removing.wmf.placeable.header=while removing wmf placeable header writelength.can.only.be.called.after.output.of.the.stream.body=writeLength() can only be called after output of the stream body. writelength.can.only.be.called.in.a.contructed.pdfstream.inputstream.pdfwriter=writeLength() can only be called in a contructed PdfStream(InputStream,PdfWriter). wrong.number.of.columns=Wrong number of columns. +xref.infinite.loop=An infinite loop was detected in the xref table. xref.subsection.not.found=xref subsection not found xstep.or.ystep.can.not.be.zero=XStep or YStep can not be ZERO. you.can.only.add.a.writer.to.a.pdfdocument.once=You can only add a writer to a PdfDocument once. @@ -405,4 +406,5 @@ you.have.to.consolidate.the.named.destinations.of.your.reader=You have to consol you.have.to.define.a.boolean.array.for.this.collection.sort.dictionary=You have to define a boolean array for this collection sort dictionary. you.have.used.the.wrong.constructor.for.this.fieldpositioningevents.class=You have used the wrong constructor for this FieldPositioningEvents class. you.must.set.a.value.before.adding.a.prefix=You must set a value before adding a prefix. -you.need.a.single.boolean.for.this.collection.sort.dictionary=You need a single boolean for this collection sort dictionary. \ No newline at end of file +you.need.a.single.boolean.for.this.collection.sort.dictionary=You need a single boolean for this collection sort dictionary. +you.should.call.document.close.instead=Please call Document.close() instead. The PdfWriter will then be closed automatically. diff --git a/openpdf/src/main/resources/com/lowagie/text/error_messages/nl.lng b/openpdf/src/main/resources/com/lowagie/text/error_messages/nl.lng index b4734eb90..fa20942e0 100644 --- a/openpdf/src/main/resources/com/lowagie/text/error_messages/nl.lng +++ b/openpdf/src/main/resources/com/lowagie/text/error_messages/nl.lng @@ -66,7 +66,7 @@ blend.mode.1.not.allowed=Blend mode {1} niet toegelaten. bookmark.end.tag.out.of.place=Bookmark end tag op verkeerde plaats. both.colors.must.be.of.the.same.type=Beide kleuren moeten van het zelfde type zijn. buffersize.1=bufferlengte {1} -can.only.push.back.one.byte=Werkt enkel met één byte ineens. +can.only.push.back.one.byte=Werkt enkel met ��n byte ineens. can.t.add.1.to.multicolumntext.with.complex.columns={1} kan niet toegevoegd worden aan een MultiColumnText met complexe kolommen can.t.decode.pkcs7signeddata.object=Kan het PKCS7SignedData object niet decoderen can.t.find.page.size.1=Kan de pagina afmetingen niet vinden {1} @@ -82,7 +82,7 @@ colorspace.rgb.is.not.allowed=Colorspace RGB is niet toegelaten. column.coordinate.of.location.must.be.gt.eq.0.and.lt.nr.of.columns=Kolom coordinaat moet groter dan of gelijk zijn aan 0 en kleiner dan het aantal kolommen columntext.go.with.simulate.eq.eq.false.and.text.eq.eq.null=ColumnText.go met simulate==false en text==null. components.must.be.1.3.or.4=Componenten moeten 1, 3, of 4 zijn. -compression.jpeg.is.only.supported.with.a.single.strip.this.image.has.1.strips=Compressie JPEG wordt enkel ondersteund voor één enkele strip. Jouw JPEG heeft {1} strips. +compression.jpeg.is.only.supported.with.a.single.strip.this.image.has.1.strips=Compressie JPEG wordt enkel ondersteund voor ��n enkele strip. Jouw JPEG heeft {1} strips. content.can.not.be.added.to.a.pdfimportedpage=Er kan geen extra content toegevoegd worden aan een PdfImportedPage. content.was.already.written.to.the.output=Er werd al inhoud naar de output gestuurd. corrupted.png.file=Corrupt PNG bestand. @@ -387,6 +387,7 @@ while.removing.wmf.placeable.header=tijdens het verwijderen van een wmf position writelength.can.only.be.called.after.output.of.the.stream.body=writeLength() kan alleen opgeroepen worden na output van de stream body. writelength.can.only.be.called.in.a.contructed.pdfstream.inputstream.pdfwriter=writeLength() kan alleen opgeroepen worden in een aldus aangemaakte stream: PdfStream(InputStream,PdfWriter). wrong.number.of.columns=Verkeerd aantal kolommen. +xref.infinite.loop=Er is een eindeloos lus gedetecteerd in de xref-tabel. xref.subsection.not.found=xref subsectie niet gevonden xstep.or.ystep.can.not.be.zero=XStep of YStep kan niet nul zijn. you.can.only.add.a.writer.to.a.pdfdocument.once=Je kan een writer slecht een enkele keer toevoegen aan een PdfDocument. @@ -397,7 +398,7 @@ you.can.t.add.an.element.of.type.1.to.a.simplecell=Je kan geen element van type you.can.t.add.cells.to.a.table.directly.add.them.to.a.row.first=Je kan geen cellen toevoegen aan een tabel, zonder ze eerst aan een rij toe te voegen. you.can.t.add.listitems.rows.or.cells.to.a.cell=Je kan geen lijst items, rijen of cellen toevoegen aan een cell. you.can.t.add.one.row.to.another.row=Je kan rijen niet aan rijen toevoegen. -you.can.t.have.1.pages.on.one.page.minimum.2.maximum.8=Je kan geen {1} pagina's op één blad plaatsen (minimum 2; maximum 8). +you.can.t.have.1.pages.on.one.page.minimum.2.maximum.8=Je kan geen {1} pagina's op ��n blad plaatsen (minimum 2; maximum 8). you.can.t.set.the.initial.leading.if.the.document.is.already.open=Je kan geen initial leading bepalen als het document al open is. you.can.t.split.this.document.at.page.1.there.is.no.such.page=Je kan dit document niet splitsen op pagina {1}; Die pagina bestaat niet. you.can.t.translate.a.negative.number.into.an.alphabetical.value=Je kan een negatieve waarde niet omzetten naar een alfabetische waarde. diff --git a/openpdf/src/main/resources/com/lowagie/text/error_messages/pt.lng b/openpdf/src/main/resources/com/lowagie/text/error_messages/pt.lng index 1e6b3cf66..7d6709c4b 100644 --- a/openpdf/src/main/resources/com/lowagie/text/error_messages/pt.lng +++ b/openpdf/src/main/resources/com/lowagie/text/error_messages/pt.lng @@ -5,3 +5,4 @@ fdf.header.not.found=Início de FDF não encontrado. greaterthan.not.expected='>' inesperado pdf.header.not.found=Início de PDF não encontrado. pdf.startxref.not.found=startxref de PDF não encontrado. +xref.infinite.loop=Um loop infinito foi detectado na tabela xref. diff --git a/openpdf/src/test/java/com/lowagie/text/pdf/PdfWriterTest.java b/openpdf/src/test/java/com/lowagie/text/pdf/PdfWriterTest.java new file mode 100644 index 000000000..8c4a09b21 --- /dev/null +++ b/openpdf/src/test/java/com/lowagie/text/pdf/PdfWriterTest.java @@ -0,0 +1,42 @@ +package com.lowagie.text.pdf; + +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; +import static org.assertj.core.api.Assertions.assertThatNoException; + +import com.lowagie.text.Document; +import com.lowagie.text.PageSize; +import com.lowagie.text.Phrase; +import java.io.ByteArrayOutputStream; +import org.junit.jupiter.api.Test; + +class PdfWriterTest { + + // Test case to check that a PdfWriter may not be closed before the including document is closed + @Test + void testCloseBeforeDocumentClose() { + try (Document document = new Document(PageSize.A4)) { + // given + PdfWriter writer = PdfWriter.getInstance(document, new ByteArrayOutputStream()); + document.open(); + document.add(new Phrase("Hello World")); + // then + assertThatIllegalStateException().isThrownBy(writer::close) + .withMessage("Please call Document.close() instead. The PdfWriter will then be closed automatically."); + } + } + + @Test + void testCloseAfterDocumentClose() { + try (Document document = new Document(PageSize.A4)) { + // given + PdfWriter writer = PdfWriter.getInstance(document, new ByteArrayOutputStream()); + document.open(); + document.add(new Phrase("Hello World")); + document.close(); + // then + assertThatNoException().isThrownBy(writer::close); + } + } + + +}