2017-08-29 115 views
1

我越來越熟悉PDFBox的風味了。我想知道是否有辦法將pdf-layout元素放入PDDocument對象中。 pdf-layout元素使用Document作爲父級,PDFBox使用PDDocument作爲父級。使用PDFBox PDDocument添加pdf-layout文檔?

PDDodcument doc = new PDDocument(); 
Paragraph someText = new Paragraph(); 
Frame shape = new Frame(someText); 
//Im looking for something like doc.add(shape); 

庫: https://pdfbox.apache.org/2.0/examples.html & https://github.com/ralfstuckert/pdfbox-layout

  • org.apache.pdfbox.pdmodel.PDDocument
  • rst.pdfbox.layout.elements.Frame
  • rst.pdfbox。 layout.elements.Document

回答

1

解決:原來,你必須做出rst.pdfbox.layout.elements.Document 父即:

Document ParentDoc = new Document(); 
Shape rec = new rec(10); 
ParentDoc.add(rec); 
//ParentDoc.getPDDocument()... use for PDFBox Items