标签云

微信群

扫码加入我们

WeChat QR Code

Is it possible to add canvas along with the addParagraph to the document? i have long text(1000 page).I need to add canvas between text in certain places(graphics, shapes, etc.).For example, if there is a word "graph_add" in the textPdfDocument pdfDoc = new PdfDocument(new PdfWriter(DEST));PageSize ps = PageSize.A4;;Document doc = new Document(pdfDoc, ps);BufferedReader br = new BufferedReader(new FileReader("bigfileWithText.txt"));while ((line = br.readLine()) != null) {if("graph_add".equals(line))//Add canvas in document in this place!!doc.add(Canvas)doc.add(new Paragraph(line)}doc.close();this is example file:this article https://itextpdf.com/ru/resources/books/itext-7-building-blocks/chapter-2-adding-content-canvas-or-document does not fit, here i need to create on a separate page. Iin a certain moment after the text add a figure(Canvas) and then add again a text.Something like this:


maybe you could add a Div element of the desired height

2019年06月26日44分31秒

Stef ,I cannot add canvas in div element(

2019年06月26日44分31秒

You are aware that the test line =="graph_add" in Java most likely does not do what you want? It does not check whether line is a string with the same characters as "graph_add", instead it checks whether line is the identical string instance as that "graph_add" string. Most likely you want to use "graph_add".equals(line) instead.

2019年06月26日44分31秒

mkl yes, i know

2019年06月25日44分31秒

Ah, ok, you corrected your code. So what exactly happens if you try to add a Canvas to your document? And how exactly do you try?

2019年06月26日44分31秒

thanks a lot!!!

2019年06月26日44分31秒