[Solved] How to detect if a PDF page has an image in it

Using iText 5 you can find out whether images actually are shown on a page by parsing the page content into a custom RenderListener implementation. E.g. class ImageDetector implements RenderListener { public void beginTextBlock() { } public void endTextBlock() { } public void renderText(TextRenderInfo renderInfo) { } public void renderImage(ImageRenderInfo renderInfo) { imageFound = true; … Read more

[Solved] Convert Html to pdf with images

$(‘#showPdf’).click(function() { var pdf = new jsPDF(); pdf.addHTML($(“#divContent”), function() { var blob = pdf.output(“blob”); window.open(URL.createObjectURL(blob)); }); }); $(‘#downloadPdf’).click(function() { var pdf = new jsPDF(); pdf.addHTML($(“#divContent”), function() { pdf.save(‘pageContent.pdf’); }); }); <script src=”https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.debug.js”></script> <script src=”https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js”></script> <div id=”divContent” style=”background-color: white; padding:20px 25px”> <h3>SEA MINK</h3> <p>The sea mink (Neovison macrodon) was a mammal from the eastern coast of … Read more

[Solved] Create a PDF file in memory

this solution, using itext, primefaces media. <p:dataTable widgetVar=”tb1″ id=”tablaFact” var=”item” selection=”#{listadoFacturasMB.selectedFactura}” selectionMode=”single” paginator=”true” rows=”20″ rowKey=”#{item.idFactura}” value=”#{listadoFacturasMB.facturaUtilList}”> <p:ajax event=”rowSelect” update=”:frm1:growl :frm1:dialog” oncomplete=”PF(‘servDialog’).show()” listener=”#{listadoFacturasMB.createPDF}”/> <f:facet name=”header”> <h:outputText value=”Listado de facturas (Cantidad: #{listadoFacturasMB.cantFact})”/> </f:facet> <p:column style=”width:10%” headerText=”Nro” sortBy=”noFactura” filterFunction=”#{utilMB.filterByName}” filterBy=”noFactura” filterMatchMode=”contains”> <h:outputText value=”#{item.noFactura}”/> </p:column> </p:dataTable> <p:dialog resizable=”false” closeOnEscape=”true” appendTo=”@(body)” modal=”true” id=”dialog” header=”Detalles de la factura” widgetVar=”servDialog” width=”1000px” height=”630px”> … Read more

[Solved] Convert PDF to Excel [closed]

Getting data out from a pdf file is pretty messy. If the pdf table is ordered and has got a unique pattern embedded along with it, the best way to get the data is by converting the pdf to xml. For this you can use: pdftohtml. Installation: sudo apt-get install pdftohtml Usage: pdftohtml -xml *Your … Read more

[Solved] Form to PHP to PDF: Conversion Assistance

I’ve recently use pdftk (server) to do so: https://www.pdflabs.com/tools/pdftk-server/ First, install it on a webserver or locally. Then, here’s a PHP class I adapted from the web (copy it and name it PdfFormToPdftk.php): <?php class PdfFormToPdftk { /* * Path to raw PDF form * @var string */ private $pdfurl; /* * Path to PDFKTK … Read more

[Solved] How can I replace a single PDF page using Imagemagick?

A specific page or range of pages can be specified using the bracket syntax with zero-based indexing. For instance, [8] will refer to the ninth page, and [0-6] to the first seven pages. Using this, a duplicate of the PDF with the 8th page replaced can be achieved as follows: convert my-file.pdf[0-6] page-8.png my-file.pdf[8] output-file.pdf … Read more

[Solved] How can I make a searchable PDF from an PDF of scanned pages? [closed]

String image2Text(String imagePath) { dataPath= Environment.getExternalStorageDirectory().toString() + “/Android/data/” + appContext.getPackageName() + “https://stackoverflow.com/”; File tessdata = new File(dataPath); if (!tessdata.exists() || !tessdata.isDirectory()) { throw new IllegalArgumentException(“Data path must contain subfolder tessdata!”); } Bitmap image= BitmapFactory.decodeFile(imagePath); TessBaseAPI baseApi = new TessBaseAPI(); baseApi.init(dataPath, “eng”); baseApi.setImage(image); String recognizedText = baseApi.getUTF8Text(); baseApi.end(); return recognizedText; } 8 solved How can I … Read more