i want to generate a pdf with itext 7,but some wrong happens to us:
com.itextpdf.kernel.PdfException: Pdf indirect object belongs to other PDF document. Copy
This is how i solved the issue.
Add a static method
public class DocumentUtils { public static PdfFont setFont() throws Exception { return PdfFontFactory.createFont(StandardFonts.TIMES_ROMAN); } }
Use the font like:
PDfFont font = DocumentUtil.setFont();