표 셀에 사각형을 그리는 방법은 무엇입니까? (How to draw rectangles in a Table cell?)


문제 설명

표 셀에 사각형을 그리는 방법은 무엇입니까? (How to draw rectangles in a Table cell?)

셀이 있는 테이블이 있고 그 안에 가로 막대 차트를 배치하고 싶습니다. 다른 라이브러리를 피하기 위해 이 셀에 직사각형으로 이 차트를 칠하고 싶습니다.

사각형을 그리려면 캔버스가 필요합니까? 캔버스를 셀에 배치하는 방법과 셀의 오른쪽 페이지에 캔버스를 만드는 방법은 무엇입니까?

감사합니다!


참조 솔루션

방법 1:

iText7 has two kinds of canvas objects:

A layout Canvas, a high‑level object that acts as a bridge between high‑and low‑level operations that allows you to add high‑level objects to a specified area. This canvas has no concept of a page.

A PdfCanvas that allows you to do low‑level operations on either a specific page or form XObject, such as drawing lines, adding text at absolute positions, ...

The constructors of Canvas require either a form XObject or a PdfCanvas, so a page can be specified for Canvas this way.

Now, in order to draw rectangles into cells, I recommend implementing your own cell‑event, and using PdfCanvas to draw the rectangles inside the event handling code.

Some useful links: Tutorial part on event handlers (final example is the one you want): http://developers.itextpdf.com/content/itext‑7‑jump‑start‑tutorial/chapter‑3‑using‑renderers‑and‑event‑handlers

Drawing using pdfCanvas: http://developers.itextpdf.com/content/itext‑7‑jump‑start‑tutorial/chapter‑2‑adding‑low‑level‑content

(by GerritSamuel Huylebroeck)

참조 문서

  1. How to draw rectangles in a Table cell? (CC BY‑SA 2.5/3.0/4.0)

#itext #itext7 #java






관련 질문

iText로 가변 페이지 PDF를 생성하려고 할 때 예외 (Exception when attempting to generate variable-page PDF with iText)

Icepdf 특수 문자 렌더링 문제 (Icepdf special character rendering issue)

JAVA에서 PDF 양식 테이블 채우기 (Filling PDF form tables in JAVA)

itext를 사용하여 poi에서 차트 내보내기 (Exporting charts from poi using itext)

표 셀에 사각형을 그리는 방법은 무엇입니까? (How to draw rectangles in a Table cell?)

동적 컨트롤로 PDF 양식 템플릿 수정 (Modify PDF Form Template with dynamic controls)

itext와 같은 라이브러리로 Java 응용 프로그램을 배포하는 방법은 무엇입니까? (how to distribute a java-application with libraries such as itext?)

종이 Itext7에서 첫 번째 줄과 마지막 줄 속성을 제거합니다. (Remove the first and last lines properties in the paper Itext7)

Java에서 iText 5를 사용하여 여러 셀을 만들고 각 셀에 각 문자를 설정하는 방법 (How to create multiple cells and set each character into each cell using iText 5 in Java)

iTextSharp(또는 iText 5)를 사용하여 다른 PdfImportedPage의 배경으로 전체 PdfImportedPage를 추가하는 방법 (How to add a full PdfImportedPage as background for another PdfImportedPage with iTextSharp (or iText 5))

그래픽 텍스트 효과가 있는 텍스트 요소 (Text element with graphical text effects)

iText7을 사용하여 PDFButtonFormField에 이미지를 추가할 때 종횡비를 유지하는 방법 (How to Maintain Aspect Ratio when Adding an Image to a PDFButtonFormField using iText7)







코멘트