public final class RawTextTools extends Object
Modifier and Type | Method and Description |
---|---|
static byte[] |
convertTextToPdf(byte[] original,
String font,
float fontSize)
Converts the provided plain text data to PDF.
|
static byte[] |
convertTextToPdf(byte[] original,
String font,
float fontSize,
String defaultCharset)
Converts the provided plain text data to PDF.
|
static String |
getMediaType(byte[] bytes,
String filename)
Detects the media type of the provided data.
|
static String |
getUnicodeString(byte[] original)
Returns a unicode encoded string corresponding to the provided data.
|
static String |
getUnicodeString(byte[] original,
String defaultCharset)
Returns a unicode encoded string corresponding to the provided data.
|
static boolean |
isPlainTextFile(byte[] bytes,
String filename)
Detects if the data contains plain text.
|
public static boolean isPlainTextFile(byte[] bytes, String filename) throws IOException
bytes
- data to analyzefilename
- name of the file the data is contained inIOException
- IO exception when trying to detect media typepublic static String getMediaType(byte[] bytes, String filename) throws IOException
bytes
- original datafilename
- name of the file the data was contained inIOException
- IO exception when reading original datapublic static byte[] convertTextToPdf(byte[] original, String font, float fontSize) throws com.lowagie.text.DocumentException, IOException
original
- plain text datafont
- font to use (like C:/Windows/Fonts/arial.ttf). This must be a true-type font!
If null or empty, a default helvetica font will be used. Note that unicode
characters will not work then.fontSize
- size of the fontcom.lowagie.text.DocumentException
- Exception when creating the PDF documentIOException
- IO exception when reading the original datapublic static byte[] convertTextToPdf(byte[] original, String font, float fontSize, String defaultCharset) throws com.lowagie.text.DocumentException, IOException
original
- plain text datafont
- font to use (like C:/Windows/Fonts/arial.ttf). This must be a true-type font!
If null or empty, a default helvetica font will be used. Note that unicode
characters will not work then.fontSize
- size of the fontdefaultCharset
- charset to use when auto-detection of charset failedcom.lowagie.text.DocumentException
- Exception when creating the PDF documentIOException
- IO exception when reading the original datapublic static String getUnicodeString(byte[] original) throws IOException
original
- original dataIOException
- IO exception when reading the original datapublic static String getUnicodeString(byte[] original, String defaultCharset) throws IOException
original
- original datadefaultCharset
- charset to use when auto-detection of charset failedIOException
- IO exception when reading the original dataCopyright © 2016 Lexmark Enterprise Software Deutschland GmbH. All rights reserved.