gnujpdf reformat

This commit is contained in:
Jindra Petřík
2021-02-20 10:01:49 +01:00
parent 7eb151055b
commit df913281dc
24 changed files with 3587 additions and 3574 deletions

View File

@@ -24,170 +24,176 @@ package gnu.jpdf;
import java.io.*;
/**
* <p>This class stores details of the author, the PDF generator etc.
* The values are accessible via the PDFDocument class.</p>
* <p>
* This class stores details of the author, the PDF generator etc. The values
* are accessible via the PDFDocument class.</p>
*
* @author Peter T. Mount
* @author Eric Z. Beard, ericzbeard@hotmail.com
* @version $Revision: 1.2 $, $Date: 2007/08/26 18:56:35 $
*
*/
public class PDFInfo extends PDFObject
{
private String author;
private String creator;
private String title;
private String subject;
private String keywords;
public class PDFInfo extends PDFObject {
/**
* This constructs a minimal info object
*/
public PDFInfo() {
super(null);
}
/**
* @param title Title of this document
*/
public PDFInfo(String title) {
this();
this.title = title;
}
private String author;
private String creator;
private String title;
private String subject;
private String keywords;
/**
* This constructs a minimal info object
*/
public PDFInfo() {
super(null);
}
/**
* Get the value of author.
* @return value of author.
*/
public String getAuthor() {
return author;
}
/**
* Set the value of author.
* @param v Value to assign to author.
*/
public void setAuthor(String v) {
this.author = v;
}
/**
* @param title Title of this document
*/
public PDFInfo(String title) {
this();
this.title = title;
}
/**
* PDF has two values, a Creator and a Producer. The creator field is
* available for calling code. The producer is fixed by this library.
* Get the value of creator.
* @return value of creator.
*/
public String getCreator() {
return creator;
}
/**
* Set the value of creator.
* @param v Value to assign to creator.
*/
public void setCreator(String v) {
this.creator = v;
}
/**
* Get the value of title.
* @return value of title.
*/
public String getTitle() {
return title;
}
/**
* Set the value of title.
* @param v Value to assign to title.
*/
public void setTitle(String v) {
this.title = v;
}
/**
* Get the value of subject.
* @return value of subject.
*/
public String getSubject() {
return subject;
}
/**
* Set the value of subject.
* @param v Value to assign to subject.
*/
public void setSubject(String v) {
this.subject = v;
}
/**
* Get the value of keywords.
* @return value of keywords.
*/
public String getKeywords() {
return keywords;
}
/**
* Set the value of keywords.
* @param v Value to assign to keywords.
*/
public void setKeywords(String v) {
this.keywords = v;
}
/**
* @param os OutputStream to send the object to
* @exception IOException on error
*/
public void write(OutputStream os) throws IOException {
// Write the object header
writeStart(os);
// now the objects body
if(author!=null) {
os.write("/Author (".getBytes());
os.write(PDFStringHelper.makePDFString(author).getBytes());
os.write(")\n".getBytes());
/**
* Get the value of author.
*
* @return value of author.
*/
public String getAuthor() {
return author;
}
if(creator!=null) {
os.write("/Creator (".getBytes());
os.write(PDFStringHelper.makePDFString(creator).getBytes());
os.write(")\n".getBytes());
/**
* Set the value of author.
*
* @param v Value to assign to author.
*/
public void setAuthor(String v) {
this.author = v;
}
os.write("/Producer ".getBytes());
os.write(PDFStringHelper.makePDFString("gnujpdf - gnujpdf.sourceforge.net")
.getBytes());
os.write("\n".getBytes());
if(title!=null) {
os.write("/Title ".getBytes());
os.write(PDFStringHelper.makePDFString(title).getBytes());
os.write("\n".getBytes());
/**
* PDF has two values, a Creator and a Producer. The creator field is
* available for calling code. The producer is fixed by this library. Get
* the value of creator.
*
* @return value of creator.
*/
public String getCreator() {
return creator;
}
if(subject!=null) {
os.write("/Subject (".getBytes());
os.write(PDFStringHelper.makePDFString(subject).getBytes());
os.write(")\n".getBytes());
/**
* Set the value of creator.
*
* @param v Value to assign to creator.
*/
public void setCreator(String v) {
this.creator = v;
}
if(keywords!=null) {
os.write("/Keywords (".getBytes());
os.write(PDFStringHelper.makePDFString(keywords).getBytes());
os.write(")\n".getBytes());
/**
* Get the value of title.
*
* @return value of title.
*/
public String getTitle() {
return title;
}
// finish off with its footer
writeEnd(os);
} // end write
/**
* Set the value of title.
*
* @param v Value to assign to title.
*/
public void setTitle(String v) {
this.title = v;
}
/**
* Get the value of subject.
*
* @return value of subject.
*/
public String getSubject() {
return subject;
}
/**
* Set the value of subject.
*
* @param v Value to assign to subject.
*/
public void setSubject(String v) {
this.subject = v;
}
/**
* Get the value of keywords.
*
* @return value of keywords.
*/
public String getKeywords() {
return keywords;
}
/**
* Set the value of keywords.
*
* @param v Value to assign to keywords.
*/
public void setKeywords(String v) {
this.keywords = v;
}
/**
* @param os OutputStream to send the object to
* @exception IOException on error
*/
public void write(OutputStream os) throws IOException {
// Write the object header
writeStart(os);
// now the objects body
if (author != null) {
os.write("/Author (".getBytes());
os.write(PDFStringHelper.makePDFString(author).getBytes());
os.write(")\n".getBytes());
}
if (creator != null) {
os.write("/Creator (".getBytes());
os.write(PDFStringHelper.makePDFString(creator).getBytes());
os.write(")\n".getBytes());
}
os.write("/Producer ".getBytes());
os.write(PDFStringHelper.makePDFString("gnujpdf - gnujpdf.sourceforge.net")
.getBytes());
os.write("\n".getBytes());
if (title != null) {
os.write("/Title ".getBytes());
os.write(PDFStringHelper.makePDFString(title).getBytes());
os.write("\n".getBytes());
}
if (subject != null) {
os.write("/Subject (".getBytes());
os.write(PDFStringHelper.makePDFString(subject).getBytes());
os.write(")\n".getBytes());
}
if (keywords != null) {
os.write("/Keywords (".getBytes());
os.write(PDFStringHelper.makePDFString(keywords).getBytes());
os.write(")\n".getBytes());
}
// finish off with its footer
writeEnd(os);
} // end write
} // end class PDFInfo