本文整理匯總了Java中org.apache.pdfbox.pdmodel.font.PDType1Font.HELVETICA屬性的典型用法代碼示例。如果您正苦於以下問題:Java PDType1Font.HELVETICA屬性的具體用法?Java PDType1Font.HELVETICA怎麽用?Java PDType1Font.HELVETICA使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.apache.pdfbox.pdmodel.font.PDType1Font
的用法示例。
在下文中一共展示了PDType1Font.HELVETICA屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setUpProjectionProfile
@Before
public void setUpProjectionProfile() {
PDPage pdPage = new PDPage();
TextElement textElement = new TextElement(5f, 15f, 10f, 20f, PDType1Font.HELVETICA, 1f, "test", 1f);
TextElement textElement2 = new TextElement(5f, 15f, 10f, 20f, PDType1Font.HELVETICA, 1f, "test", 1f);
List<TextElement> textList = new ArrayList<>();
textList.add(textElement);
textList.add(textElement2);
Ruling ruling = new Ruling(0, 0, 10, 10);
List<Ruling> rulingList = new ArrayList<>();
rulingList.add(ruling);
page = new Page(0, 0, 1, 1, 0, 1, pdPage, textList, rulingList);
List<Rectangle> rectangles = new ArrayList<>();
rectangles.add(new Rectangle(0f, 0f, 500f, 5f));
pProfile = new ProjectionProfile(page, rectangles, 5, 5);
}
示例2: createTextElement
@Test
public void createTextElement() {
TextElement textElement = new TextElement(5f, 15f, 10f, 20f, PDType1Font.HELVETICA, 1f, "A", 1f);
Assert.assertNotNull(textElement);
Assert.assertEquals("A", textElement.getText());
Assert.assertEquals(1f, textElement.getFontSize(), 0);
Assert.assertEquals(15f, textElement.getLeft(), 0);
Assert.assertEquals(5f, textElement.getTop(), 0);
Assert.assertEquals(10f, textElement.getWidth(), 0);
Assert.assertEquals(20f, textElement.getHeight(), 0);
Assert.assertEquals(PDType1Font.HELVETICA, textElement.getFont());
Assert.assertEquals(1f, textElement.getWidthOfSpace(), 0);
Assert.assertEquals(0f, textElement.getDirection(), 0);
}
示例3: createTextElementWithDirection
@Test
public void createTextElementWithDirection() {
TextElement textElement = new TextElement(5f, 15f, 10f, 20f, PDType1Font.HELVETICA, 1f, "A", 1f, 6f);
Assert.assertNotNull(textElement);
Assert.assertEquals("A", textElement.getText());
Assert.assertEquals(1f, textElement.getFontSize(), 0);
Assert.assertEquals(15f, textElement.getLeft(), 0);
Assert.assertEquals(5f, textElement.getTop(), 0);
Assert.assertEquals(10f, textElement.getWidth(), 0);
Assert.assertEquals(20f, textElement.getHeight(), 0);
Assert.assertEquals(PDType1Font.HELVETICA, textElement.getFont());
Assert.assertEquals(1f, textElement.getWidthOfSpace(), 0);
Assert.assertEquals(6f, textElement.getDirection(), 0);
}
示例4: mergeFourElementsIntoOneWord
@Test
public void mergeFourElementsIntoOneWord() {
List<TextElement> elements = new ArrayList<>();
elements.add(new TextElement(0f, 15f, 10f, 20f, PDType1Font.HELVETICA, 1f, "A", 1f, 6f));
elements.add(new TextElement(0f, 25f, 10f, 20f, PDType1Font.HELVETICA, 1f, "B", 1f, 6f));
elements.add(new TextElement(0f, 35f, 10f, 20f, PDType1Font.HELVETICA, 1f, "C", 1f, 6f));
elements.add(new TextElement(0f, 45f, 10f, 20f, PDType1Font.HELVETICA, 1f, "D", 1f, 6f));
List<TextChunk> words = TextElement.mergeWords(elements);
List<TextChunk> expectedWords = new ArrayList<>();
TextChunk textChunk = new TextChunk(new TextElement(0f, 15f, 10f, 20f, PDType1Font.HELVETICA, 1f, "A", 1f, 6f));
textChunk.add(new TextElement(0f, 25f, 10f, 20f, PDType1Font.HELVETICA, 1f, "B", 1f, 6f));
textChunk.add(new TextElement(0f, 35f, 10f, 20f, PDType1Font.HELVETICA, 1f, "C", 1f, 6f));
textChunk.add(new TextElement(0f, 45f, 10f, 20f, PDType1Font.HELVETICA, 1f, "D", 1f, 6f));
expectedWords.add(textChunk);
Assert.assertEquals(expectedWords, words);
}
示例5: mergeElementsWithSkippingRules
@Test
public void mergeElementsWithSkippingRules() {
List<TextElement> elements = new ArrayList<>();
elements.add(new TextElement(0f, 15f, 10f, 20f, PDType1Font.HELVETICA, 1f, "A", 1f, 6f));
elements.add(new TextElement(0f, 17f, 10f, 20f, PDType1Font.HELVETICA, 1f, "A", 1f, 6f));
elements.add(new TextElement(0f, 25f, 10f, 20f, PDType1Font.HELVETICA, 1f, "B", 1f, 6f));
elements.add(new TextElement(0.001f, 25f, 10f, 20f, PDType1Font.HELVETICA, 1f, " ", 1f, 6f));
elements.add(new TextElement(0f, 35f, 10f, 20f, PDType1Font.HELVETICA, 1f, "C", 1f, 6f));
elements.add(new TextElement(0f, 45f, 10f, 20f, PDType1Font.TIMES_ROMAN, 10f, "D", 1f, 6f));
List<TextChunk> words = TextElement.mergeWords(elements);
List<TextChunk> expectedWords = new ArrayList<>();
TextChunk textChunk = new TextChunk(new TextElement(0f, 15f, 10f, 20f, PDType1Font.HELVETICA, 1f, "A", 1f, 6f));
textChunk.add(new TextElement(0f, 25f, 10f, 20f, PDType1Font.HELVETICA, 1f, "B", 1f, 6f));
textChunk.add(new TextElement(0f, 35f, 10f, 20f, PDType1Font.HELVETICA, 1f, "C", 1f, 6f));
textChunk.add(new TextElement(0f, 45f, 10f, 20f, PDType1Font.TIMES_ROMAN, 10f, "D", 1f, 6f));
expectedWords.add(textChunk);
Assert.assertEquals(expectedWords, words);
}
示例6: writeInputFieldToPDFPage
/**
* <a href="http://stackoverflow.com/questions/43604973/creating-a-checkbox-and-printing-it-to-pdf-file-is-not-working-using-pdfbox-1-8">
* Creating a checkbox and printing it to pdf file is not working using pdfbox 1.8.9 api
* </a>
* <p>
* The OP's method for checkbox creation.
* </p>
* @see #testCheckboxLikeSureshGoud()
*/
public static void writeInputFieldToPDFPage( PDPage pdPage, PDDocument document, Float x, Float y, Boolean ticked) throws IOException {
PDFont font = PDType1Font.HELVETICA;
PDResources res = new PDResources();
String fontName = res.addFont(font);
String da = ticked?"/" + fontName + " 10 Tf 0 0.4 0 rg":"";
COSDictionary acroFormDict = new COSDictionary();
acroFormDict.setBoolean(COSName.getPDFName("NeedAppearances"), true);
acroFormDict.setItem(COSName.FIELDS, new COSArray());
acroFormDict.setItem(COSName.DA, new COSString(da));
PDAcroForm acroForm = new PDAcroForm(document, acroFormDict);
acroForm.setDefaultResources(res);
document.getDocumentCatalog().setAcroForm(acroForm);
PDGamma colourBlack = new PDGamma();
PDAppearanceCharacteristicsDictionary fieldAppearance =
new PDAppearanceCharacteristicsDictionary(new COSDictionary());
fieldAppearance.setBorderColour(colourBlack);
if(ticked) {
COSArray arr = new COSArray();
arr.add(new COSFloat(0.89f));
arr.add(new COSFloat(0.937f));
arr.add(new COSFloat(1f));
fieldAppearance.setBackground(new PDGamma(arr));
}
COSDictionary cosDict = new COSDictionary();
COSArray rect = new COSArray();
rect.add(new COSFloat(x));
rect.add(new COSFloat(new Float(y-5)));
rect.add(new COSFloat(new Float(x+10)));
rect.add(new COSFloat(new Float(y+5)));
cosDict.setItem(COSName.RECT, rect);
cosDict.setItem(COSName.FT, COSName.getPDFName("Btn")); // Field Type
cosDict.setItem(COSName.TYPE, COSName.ANNOT);
cosDict.setItem(COSName.SUBTYPE, COSName.getPDFName("Widget"));
if(ticked) {
cosDict.setItem(COSName.TU, new COSString("Checkbox with PDFBox"));
}
cosDict.setItem(COSName.T, new COSString("Chk"));
//Tick mark color and size of the mark
cosDict.setItem(COSName.DA, new COSString(ticked?"/F0 10 Tf 0 0.4 0 rg":"/FF 1 Tf 0 0 g"));
cosDict.setInt(COSName.F, 4);
PDCheckbox checkbox = new PDCheckbox(acroForm, cosDict);
checkbox.setFieldFlags(PDCheckbox.FLAG_READ_ONLY);
checkbox.setValue("Yes");
checkbox.getWidget().setAppearanceCharacteristics(fieldAppearance);
pdPage.getAnnotations().add(checkbox.getWidget());
acroForm.getFields().add(checkbox);
}
示例7: chooseMatchingHelvetica
/**
* Get a PDType1Font.HELVETICA-variant, which matches the given font
*
* @param font
* Font to get the styles from
* @return a PDFont Helvetica variant which matches the style in the given Font
* object.
*/
public static PDFont chooseMatchingHelvetica(Font font) {
if ((font.getStyle() & (Font.ITALIC | Font.BOLD)) == (Font.ITALIC | Font.BOLD))
return PDType1Font.HELVETICA_BOLD_OBLIQUE;
if ((font.getStyle() & Font.ITALIC) == Font.ITALIC)
return PDType1Font.HELVETICA_OBLIQUE;
if ((font.getStyle() & Font.BOLD) == Font.BOLD)
return PDType1Font.HELVETICA_BOLD;
return PDType1Font.HELVETICA;
}
示例8: mergeTenElementsIntoTwoWords
@Test
public void mergeTenElementsIntoTwoWords() {
List<TextElement> elements = new ArrayList<>();
elements.add(new TextElement(0f, 0f, 10f, 20f, PDType1Font.HELVETICA, 1f, "H", 1f, 6f));
elements.add(new TextElement(0f, 10f, 10f, 20f, PDType1Font.HELVETICA, 1f, "O", 1f, 6f));
elements.add(new TextElement(0f, 20f, 10f, 20f, PDType1Font.HELVETICA, 1f, "L", 1f, 6f));
elements.add(new TextElement(0f, 30f, 10f, 20f, PDType1Font.HELVETICA, 1f, "A", 1f, 6f));
elements.add(new TextElement(0f, 60f, 10f, 20f, PDType1Font.HELVETICA, 1f, "M", 1f, 6f));
elements.add(new TextElement(0f, 70f, 10f, 20f, PDType1Font.HELVETICA, 1f, "U", 1f, 6f));
elements.add(new TextElement(0f, 80f, 10f, 20f, PDType1Font.HELVETICA, 1f, "N", 1f, 6f));
elements.add(new TextElement(0f, 90f, 10f, 20f, PDType1Font.HELVETICA, 1f, "D", 1f, 6f));
elements.add(new TextElement(0f, 100f, 10f, 20f, PDType1Font.HELVETICA, 1f, "O", 1f, 6f));
List<TextChunk> words = TextElement.mergeWords(elements);
List<TextChunk> expectedWords = new ArrayList<>();
TextChunk textChunk = new TextChunk(new TextElement(0f, 0f, 10f, 20f, PDType1Font.HELVETICA, 1f, "H", 1f, 6f));
textChunk.add(new TextElement(0f, 10f, 10f, 20f, PDType1Font.HELVETICA, 1f, "O", 1f, 6f));
textChunk.add(new TextElement(0f, 20f, 10f, 20f, PDType1Font.HELVETICA, 1f, "L", 1f, 6f));
textChunk.add(new TextElement(0f, 30f, 10f, 20f, PDType1Font.HELVETICA, 1f, "A", 1f, 6f));
textChunk.add(new TextElement(0f, 30f, 10.5f, 20f, PDType1Font.HELVETICA, 1f, " ", 1f)); //Check why width=10.5?
expectedWords.add(textChunk);
TextChunk textChunk2 = new TextChunk(new TextElement(0f, 60f, 10f, 20f, PDType1Font.HELVETICA, 1f, "M", 1f, 6f));
textChunk2.add(new TextElement(0f, 70f, 10f, 20f, PDType1Font.HELVETICA, 1f, "U", 1f, 6f));
textChunk2.add(new TextElement(0f, 80f, 10f, 20f, PDType1Font.HELVETICA, 1f, "N", 1f, 6f));
textChunk2.add(new TextElement(0f, 90f, 10f, 20f, PDType1Font.HELVETICA, 1f, "D", 1f, 6f));
textChunk2.add(new TextElement(0f, 100f, 10f, 20f, PDType1Font.HELVETICA, 1f, "O", 1f, 6f));
expectedWords.add(textChunk2);
Assert.assertEquals(2, words.size());
Assert.assertEquals(expectedWords, words);
}
示例9: mergeTenElementsIntoTwoLines
@Test
public void mergeTenElementsIntoTwoLines() {
List<TextElement> elements = new ArrayList<>();
elements.add(new TextElement(0f, 0f, 10f, 20f, PDType1Font.HELVETICA, 1f, "H", 1f, 6f));
elements.add(new TextElement(0f, 10f, 10f, 20f, PDType1Font.HELVETICA, 1f, "O", 1f, 6f));
elements.add(new TextElement(0f, 20f, 10f, 20f, PDType1Font.HELVETICA, 1f, "L", 1f, 6f));
elements.add(new TextElement(0f, 30f, 10f, 20f, PDType1Font.HELVETICA, 1f, "A", 1f, 6f));
elements.add(new TextElement(20f, 0f, 10f, 20f, PDType1Font.HELVETICA, 1f, "M", 1f, 6f));
elements.add(new TextElement(20f, 10f, 10f, 20f, PDType1Font.HELVETICA, 1f, "U", 1f, 6f));
elements.add(new TextElement(20f, 20f, 10f, 20f, PDType1Font.HELVETICA, 1f, "N", 1f, 6f));
elements.add(new TextElement(20f, 30f, 10f, 20f, PDType1Font.HELVETICA, 1f, "D", 1f, 6f));
elements.add(new TextElement(20f, 40f, 10f, 20f, PDType1Font.HELVETICA, 1f, "O", 1f, 6f));
List<TextChunk> words = TextElement.mergeWords(elements);
List<TextChunk> expectedWords = new ArrayList<>();
TextChunk textChunk = new TextChunk(new TextElement(0f, 0f, 10f, 20f, PDType1Font.HELVETICA, 1f, "H", 1f, 6f));
textChunk.add(new TextElement(0f, 10f, 10f, 20f, PDType1Font.HELVETICA, 1f, "O", 1f, 6f));
textChunk.add(new TextElement(0f, 20f, 10f, 20f, PDType1Font.HELVETICA, 1f, "L", 1f, 6f));
textChunk.add(new TextElement(0f, 30f, 10f, 20f, PDType1Font.HELVETICA, 1f, "A", 1f, 6f));
expectedWords.add(textChunk);
TextChunk textChunk2 = new TextChunk(new TextElement(20f, 0f, 10f, 20f, PDType1Font.HELVETICA, 1f, "M", 1f, 6f));
textChunk2.add(new TextElement(20f, 10f, 10f, 20f, PDType1Font.HELVETICA, 1f, "U", 1f, 6f));
textChunk2.add(new TextElement(20f, 20f, 10f, 20f, PDType1Font.HELVETICA, 1f, "N", 1f, 6f));
textChunk2.add(new TextElement(20f, 30f, 10f, 20f, PDType1Font.HELVETICA, 1f, "D", 1f, 6f));
textChunk2.add(new TextElement(20f, 40f, 10f, 20f, PDType1Font.HELVETICA, 1f, "O", 1f, 6f));
expectedWords.add(textChunk2);
Assert.assertEquals(2, words.size());
Assert.assertEquals(expectedWords, words);
}
示例10: testAddEmptySignatureField
/**
* <a href="http://stackoverflow.com/questions/37601092/pdfbox-identify-specific-pages-and-functionalities-recommendations">
* PDFBox identify specific pages and functionalities recommendations
* </a>
*
* <p>
* This test shows how to add an empty signature field with a custom appearance
* to an existing PDF.
* </p>
*/
@Test
public void testAddEmptySignatureField() throws IOException
{
try ( InputStream sourceStream = getClass().getResourceAsStream("test.pdf");
OutputStream output = new FileOutputStream(new File(RESULT_FOLDER, "test-with-empty-sig-field.pdf")))
{
PDFont font = PDType1Font.HELVETICA;
PDResources resources = new PDResources();
resources.put(COSName.getPDFName("Helv"), font);
PDDocument document = PDDocument.load(sourceStream);
PDAcroForm acroForm = new PDAcroForm(document);
acroForm.setDefaultResources(resources);
document.getDocumentCatalog().setAcroForm(acroForm);
PDRectangle rect = new PDRectangle(50, 750, 200, 50);
PDAppearanceDictionary appearanceDictionary = new PDAppearanceDictionary();
PDAppearanceStream appearanceStream = new PDAppearanceStream(document);
appearanceStream.setBBox(rect.createRetranslatedRectangle());
appearanceStream.setResources(resources);
appearanceDictionary.setNormalAppearance(appearanceStream);
PDPageContentStream contentStream = new PDPageContentStream(document, appearanceStream);
contentStream.setStrokingColor(Color.BLACK);
contentStream.setNonStrokingColor(Color.LIGHT_GRAY);
contentStream.setLineWidth(2);
contentStream.addRect(0, 0, rect.getWidth(), rect.getHeight());
contentStream.fill();
contentStream.moveTo(1 * rect.getHeight() / 4, 1 * rect.getHeight() / 4);
contentStream.lineTo(2 * rect.getHeight() / 4, 3 * rect.getHeight() / 4);
contentStream.moveTo(1 * rect.getHeight() / 4, 3 * rect.getHeight() / 4);
contentStream.lineTo(2 * rect.getHeight() / 4, 1 * rect.getHeight() / 4);
contentStream.moveTo(3 * rect.getHeight() / 4, 1 * rect.getHeight() / 4);
contentStream.lineTo(rect.getWidth() - rect.getHeight() / 4, 1 * rect.getHeight() / 4);
contentStream.stroke();
contentStream.setNonStrokingColor(Color.DARK_GRAY);
contentStream.beginText();
contentStream.setFont(font, rect.getHeight() / 5);
contentStream.newLineAtOffset(3 * rect.getHeight() / 4, -font.getBoundingBox().getLowerLeftY() * rect.getHeight() / 5000);
contentStream.showText("Customer");
contentStream.endText();
contentStream.close();
PDSignatureField signatureField = new PDSignatureField(acroForm);
signatureField.setPartialName("SignatureField");
PDPage page = document.getPage(0);
PDAnnotationWidget widget = signatureField.getWidgets().get(0);
widget.setAppearance(appearanceDictionary);
widget.setRectangle(rect);
widget.setPage(page);
page.getAnnotations().add(widget);
acroForm.getFields().add(signatureField);
document.save(output);
document.close();
}
}
示例11: testDrawTextLineText
/**
* <a href="https://stackoverflow.com/questions/44503236/how-to-write-text-draw-a-line-and-then-again-write-text-in-a-pdf-file-using-pdf">
* How to write text, draw a line and then again write text in a pdf file using PDFBox
* </a>
* <p>
* This test shows how to draw tetx, then graphics, then again text.
* </p>
*/
@Test
public void testDrawTextLineText() throws IOException
{
PDFont font = PDType1Font.HELVETICA;
float fontSize = 14;
float fontHeight = fontSize;
float leading = 20;
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd");
Date date = new Date();
PDDocument doc = new PDDocument();
PDPage page = new PDPage();
doc.addPage(page);
PDPageContentStream contentStream = new PDPageContentStream(doc, page);
contentStream.setFont(font, fontSize);
float yCordinate = page.getCropBox().getUpperRightY() - 30;
float startX = page.getCropBox().getLowerLeftX() + 30;
float endX = page.getCropBox().getUpperRightX() - 30;
contentStream.beginText();
contentStream.newLineAtOffset(startX, yCordinate);
contentStream.showText("Entry Form � Header");
yCordinate -= fontHeight; //This line is to track the yCordinate
contentStream.newLineAtOffset(0, -leading);
yCordinate -= leading;
contentStream.showText("Date Generated: " + dateFormat.format(date));
yCordinate -= fontHeight;
contentStream.endText(); // End of text mode
contentStream.moveTo(startX, yCordinate);
contentStream.lineTo(endX, yCordinate);
contentStream.stroke();
yCordinate -= leading;
contentStream.beginText();
contentStream.newLineAtOffset(startX, yCordinate);
contentStream.showText("Name: XXXXX");
contentStream.endText();
contentStream.close();
doc.save(new File(RESULT_FOLDER, "textLineText.pdf"));
}
示例12: renderText
public void renderText(String Info, int marginwidth) throws IOException
{
if (content == null || textRenderingLineY < 12)
newPage();
textRenderingLineY-=12;
System.out.print("lineno=" + textRenderingLineY);
PDFont fontPlain = PDType1Font.HELVETICA;
content.beginText();
content.setFont(fontPlain, 10);
content.moveTextPositionByAmount(marginwidth, textRenderingLineY);
content.drawString(Info);
content.endText();
}
示例13: tryBuiltinFallback
private PDFont tryBuiltinFallback(String fontFamily, boolean isItalic, boolean isBold)
{
PDFont font;
fontFamily = fontFamily.toLowerCase();
switch (fontFamily) {
case "courier":
case "courier new":
case "lucida console":
if (isBold && isItalic) { font = PDType1Font.COURIER_BOLD_OBLIQUE;}
else if (isBold) { font = PDType1Font.COURIER_BOLD;}
else if (isItalic) { font = PDType1Font.COURIER_OBLIQUE;}
else { font = PDType1Font.COURIER;}
break;
case "times":
case "garamond":
case "georgia":
case "times new roman":
case "serif":
if (isBold && isItalic) { font = PDType1Font.TIMES_BOLD_ITALIC;}
else if (isBold) { font = PDType1Font.TIMES_BOLD;}
else if (isItalic) { font = PDType1Font.TIMES_ITALIC;}
else { font = PDType1Font.TIMES_ROMAN;}
break;
default:
if (isBold && isItalic) { font = PDType1Font.HELVETICA_BOLD_OBLIQUE;}
else if (isBold) { font = PDType1Font.HELVETICA_BOLD;}
else if (isItalic) { font = PDType1Font.HELVETICA_OBLIQUE;}
else { font = PDType1Font.HELVETICA;}
break;
}
return font;
}
示例14: testArrangeTextForTeamotea
/**
* <a href="https://stackoverflow.com/questions/46908322/apache-pdfbox-how-can-i-specify-the-position-of-the-texts-im-outputting">
* Apache PDFBox: How can I specify the position of the texts I'm outputting
* </a>
* <p>
* This test shows how to arrange text pieces using relative coordinates
* to move from line start to line start.
* </p>
*/
@Test
public void testArrangeTextForTeamotea() throws IOException {
try (PDDocument document = new PDDocument()) {
PDPage page = new PDPage();
document.addPage(page);
PDFont font = PDType1Font.HELVETICA;
String text = "Text 1";
String text1 = "Text 2";
String text2 = "Text 3";
String text3 = "Text 4";
String text4 = "Text 5";
String text5 = "Text 6";
try (PDPageContentStream contentStream = new PDPageContentStream(document, page)) {
contentStream.beginText();
contentStream.newLineAtOffset(175, 670);
contentStream.setFont(font, 12);
contentStream.setLeading(15);
contentStream.showText(text);
contentStream.newLine();
contentStream.showText(text1);
contentStream.newLineAtOffset(225, 10);
contentStream.setFont(font, 15);
contentStream.showText(text2);
contentStream.newLineAtOffset(-390, -175);
contentStream.setFont(font, 13.5f);
contentStream.setLeading(17);
contentStream.showText(text3);
contentStream.newLine();
contentStream.showText(text5);
contentStream.newLineAtOffset(300, 13.5f);
contentStream.showText(text4);
contentStream.endText();
contentStream.moveTo(0, 520);
contentStream.lineTo(612, 520);
contentStream.stroke();
}
document.save(new File(RESULT_FOLDER, "arrangedText.pdf"));
}
}
示例15: addLinkToPage
@SuppressWarnings("unused")
private void addLinkToPage(float x, float y, String text, PDFPage page) throws IOException {
PDFont font = PDType1Font.HELVETICA;
float textWidth = (font.getStringWidth( text )/1000) * 18;
addLinkToPage(x, y, textWidth, page);
}