Last active
August 26, 2019 13:37
-
-
Save netstart/ea41d915ccc5a9a4dfa2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.lowagie.text.Document; | |
import com.lowagie.text.DocumentException; | |
import com.lowagie.text.html.simpleparser.HTMLWorker; | |
import com.lowagie.text.pdf.PdfWriter; | |
import org.apache.pdfbox.exceptions.COSVisitorException; | |
import org.apache.pdfbox.pdmodel.PDDocument; | |
import org.apache.pdfbox.pdmodel.PDPage; | |
import org.apache.pdfbox.pdmodel.PDResources; | |
import org.apache.pdfbox.pdmodel.common.PDRectangle; | |
import org.apache.pdfbox.pdmodel.edit.PDPageContentStream; | |
import org.apache.pdfbox.pdmodel.font.PDType1Font; | |
import org.apache.pdfbox.pdmodel.graphics.PDExtendedGraphicsState; | |
import org.apache.pdfbox.pdmodel.graphics.xobject.PDJpeg; | |
import org.apache.pdfbox.pdmodel.graphics.xobject.PDPixelMap; | |
import org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectImage; | |
import org.apache.pdfbox.util.PDFMergerUtility; | |
private ByteArrayInputStream gerarPdfInformacaoTexto(List<InformacaoAtoEntity> informacoesAto) throws COSVisitorException, IOException { | |
PDFMergerUtility pdfMerge = new PDFMergerUtility(); | |
ByteArrayOutputStream saida = new ByteArrayOutputStream(); | |
for (InformacaoAtoEntity informacaoAto : informacoesAto) { | |
try { | |
InformacaoTextoEntity informacaoAnexo = (InformacaoTextoEntity) informacaoAto; | |
Document document = new Document(); | |
PdfWriter.getInstance(document, saida); | |
document.open(); | |
HTMLWorker htmlWorker = new HTMLWorker(document); | |
htmlWorker.parse(new StringReader("<body><B>uhuuuullll</B></body>")); | |
document.close(); | |
} catch (DocumentException e) { | |
throw new IOException(e); | |
} | |
} | |
pdfMerge.setDestinationStream(saida); | |
pdfMerge.mergeDocuments(); | |
return new ByteArrayInputStream(saida.toByteArray()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment