私はPDFBoxとBoxableを初めて使用しています。この質問は、ここで質問された質問を参考にしています(Ref:https://github.com/dhorions/boxable/issues/89) flurinBooneaは、テキスト、画像、表をすべて同じページに配置するための小さなサンプルコードを提示しました。 私の質問は、(内部の内容に基づいて動的な高さを持つ)テーブルを作成し、テーブルの後ろにテキストを配置する必要がある場合です。どのように私はそれを行うことができますか? どこかは、私はテーブルを描きながら、私は次のコードの前にtable.drawを使用するたびに、私は次の要素のためのYPositionを得るために似たような、前に描画するとテーブルが消えるcontentStream - PDFBox with Boxable
float yPosition = table.draw()
を使用し、次の要素のために、この位置を使用するが、その読み、
PDPageContentStream contentStream = new PDPageContentStream(doc, page);
contentStream.beginText();
contentStream.setFont(font, 18);
contentStream.moveTextPositionByAmount(0, yPosition - 20);
contentStream.drawString("This is a test message");
contentStream.endText();
contentStream.close();
表が消え、テキストのみが表示されます。これを回避する方法がわかりません。誰かがこれで私を助けてくださいできますか?私はかなりの間この問題に悩まされています。したがって、あなたをこのコンテンツのストリームを作成する場合
/**
* Create a new PDPage content stream. This constructor overwrites all existing content streams
* of this page.
*
* @param document The document the page is part of.
* @param sourcePage The page to write the contents to.
* @throws IOException If there is an error writing to the page contents.
*/
public PDPageContentStream(PDDocument document, PDPage sourcePage) throws IOException
: は、あなたがこのコンストラクタは次のように文書化されて
PDPageContentStream contentStream = new PDPageContentStream(doc, page);
を使用して、問題のページのための追加コンテンツストリームを作成し、事前