boxable icon indicating copy to clipboard operation
boxable copied to clipboard

Rotated text with default alignment doesn't have tokens

Open Frulenzo opened this issue 8 years ago • 1 comments

As title say, when rotated text has default alignment (left,top) Paragraph class doesn't make tokenizer methode which means 0 tokens --> empty cell.

Test case

public void SampleTest11() throws IOException {

		// Set margins
		float margin = 10;

		// Initialize Document
		PDDocument doc = new PDDocument();
		PDPage page = addNewPage(doc);

		// Initialize table
		float tableWidth = page.getMediaBox().getWidth() - (2 * margin);
		float yStartNewPage = page.getMediaBox().getHeight() - (2 * margin);
		boolean drawContent = true;
		boolean drawLines = true;
		float yStart = yStartNewPage;
		float pageBottomMargin = 70;
		float pageTopMargin = 2*margin;
		BaseTable table = new BaseTable(yStart, yStartNewPage, pageBottomMargin, tableWidth, margin, doc, page, drawLines,
				drawContent);

		// set default line spacing for entire table
		table.setLineSpacing(1.5f);

		
		Row<PDPage> row = table.createRow(10f);

		Cell<PDPage> cell = row.createCell((100 / 3f),
				"<p>SINGLE SPACING</p><p>Integer eget elit vitae est feugiat laoreet. <b>Nam vitae ex commodo, euismod risus in, sodales do</p>",
				HorizontalAlignment.get("center"), VerticalAlignment.get("top"));
		cell.setFontSize(6);

		Cell<PDPage> cell2 = row.createCell((100 / 3f),
				"test test <br>test<b>bold text</b><i> italic </i><b><i>Bold italic </i></b>"
				);
		cell2.setTextRotated(true);
		cell2.setFontSize(6);

		Cell<PDPage> cell3 = row.createCell((100 / 3f),
				"Hello it's me");
		cell3.setFontSize(6);
		
		table.draw();

		// Save the document
		File file = new File("target/SampleTest11.pdf");
		System.out.println("Sample file saved at : " + file.getAbsolutePath());
		Files.createParentDirs(file);
		doc.save(file);
		doc.close();
	}

Frulenzo avatar Dec 07 '16 15:12 Frulenzo

@dhorions I didn't made PR (my bad) for this old issue but solution is very simple, maybe you can just commit that

https://github.com/SZUE/boxable/commit/c0db6808966f3a421b092f6fe3fa8dda981c2c06

Frulenzo avatar Feb 14 '17 11:02 Frulenzo