用iText解析html到pdf,图像base64[复制]

时间:2022-11-13 12:26:48

This question already has an answer here:

这个问题已经有了答案:

I'm doing a PDF report in which I have to insert some html fragments. I'm done with iText5 and my code is:

我正在做一个PDF报告,其中我必须插入一些html片段。我已经完成了iText5,我的代码是:

Paragraph paragraph = new Paragraph();
HTMLWorker htmlWorker = new HTMLWorker(docPDF);
htmlWorker.parse(new StringReader(...html string in here....));

Everything is working fine but when in the html code there is a tag with the source in base64 like this

一切都很正常,但是在html代码中,有一个标签,在base64中是这样的。

<img alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUh......">

it displays the following error:

它显示了以下错误:

ExceptionConverter: java.io.FileNotFoundException: C:\data:image\png;base64,iVBORw0KGgoAAAANSUhEUgAAAOUAAADpCAIAAABUaWc6AAAgAElEQVR4nO2deXxTZdr3z8wDtK6AioAsohVFAesGMgjCIOrIzIBLBwd8B+ZFh0FnZNDRF3kUpoNsIooOCLi0jApaShegi3Sj+56kW5ZmOznZ0+xNQtM2bfP+cZfD6cnZsxZzfX5\QJuepCff3rnu674WyB+3uI0eg6L9AuIWNxYW5zVuo8nivMZtNFmc17iNJrvWePX5fDqDAUiqgMVyJZnQh9lstmi\6rgxtVHPKwBUIodFsEZm9iCuAc4Sq40iWCORw0aTKdq\VtyIbVTy6nZ7EI1WLIfFWmMwgNLgqzUKlWqxXAkjarfbE+1fOm5+\6jj1WgyCRVI+BilkERjFcths9kS7Xvws7bRwavX6xXLlVKjPSqk4iQ12sVxnyFKFuu86gwGkRwO0jENk2Rmj1CBwIja5\NF+z79XCx2ebXZbEJEH3UoKaT3DJguD5ouD2qclxGdCVapYRhWqVSGKxbnOOQWi7z6fD6xAlbYe6JOJCqDZ9DeO+jsG+ruG+odGGL7G5lMJhiGEQTxer3huGM\H4s5Xo0mk0RjjTqgiGvAeHnQ2TfU4xtijSe59fX1aTSa0F3vZ2exxatMqYrusqp1D1i9g+7+IfZrKAtDECTuKnCzWOHV5\OJ5NEJVAFZega9YYV0pFmtVrvdH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bgbgGhIge0VBVrYTP4ryOMvN6vTCiFsnhyJeOyYzdQgVCOzIzrBbndRSb2+2BEbVYDoc1OUGsNUoVMEXNaiQtzus1YmDdFcuVYrlSqFRzjjDIzB4hohciepEchhE12\ypcFuc12vZjCaTzmAY5lgBAxBxEitgqQLWGQw69tl9kbc4r3EbTRbnNW6jyeK8xm00WZzXuI0m+\8gZ08fpVj9RQAAAABJRU5ErkJggg== (El nombre de archivo, el nombre de directorio o la sintaxis de la etiqueta del volumen no son correctos)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at com.lowagie.text.Image.getInstance(Unknown Source)
at com.lowagie.text.Image.getInstance(Unknown Source)
at com.lowagie.text.html.simpleparser.HTMLWorker.startElement(Unknown Source)
at com.lowagie.text.xml.simpleparser.SimpleXMLParser.processTag(Unknown Source)
at com.lowagie.text.xml.simpleparser.SimpleXMLParser.go(Unknown Source)
at com.lowagie.text.xml.simpleparser.SimpleXMLParser.parse(Unknown Source)
at com.lowagie.text.html.simpleparser.HTMLWorker.parse(Unknown Source)
at com.crc.tecnatom.gaddie.reports.ExamenInforme.imprimePDF(ExamenInforme.java:61)
at com.crc.tecnatom.gaddie.controllers.ExamenesController.descargarExamen(ExamenesController.java:114)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

4 个解决方案

#1


6  

It's possible to replace the built-in tags processors of iText(Sharp). Here is the C# code with custom image tag processor which supports base64 images too. It's easy to convert it to java (base libraries iText and iTextSharp have the same API).

它有可能替换iText(Sharp)内置的标签处理器。这里是带有自定义图像标签处理器的c#代码,它也支持base64图像。很容易将其转换为java(基础库iText和iTextSharp具有相同的API)。

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.html;
using iTextSharp.text.html.simpleparser;
using iTextSharp.text.pdf;

namespace CustomHtmlWorkerTag
{
    /// <summary>
    /// Our custom HTML Tag to add an IElement.
    /// </summary>
    public class CustomImageHTMLTagProcessor : IHTMLTagProcessor
    {
        /// <summary>
        /// Tells the HTMLWorker what to do when a close tag is encountered.
        /// </summary>
        public void EndElement(HTMLWorker worker, string tag)
        {
        }

        /// <summary>
        /// Tells the HTMLWorker what to do when an open tag is encountered.
        /// </summary>
        public void StartElement(HTMLWorker worker, string tag, IDictionary<string, string> attrs)
        {
            Image image;
            var src = attrs["src"];

            if (src.StartsWith("data:image/"))
            {
                // data:[<MIME-type>][;charset=<encoding>][;base64],<data>
                var base64Data = src.Substring(src.IndexOf(",") + 1);
                var imagedata = Convert.FromBase64String(base64Data);
                image = Image.GetInstance(imagedata);
            }
            else
            {
                image = Image.GetInstance(src);
            }

            worker.UpdateChain(tag, attrs);
            worker.ProcessImage(image, attrs);
            worker.UpdateChain(tag);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            using (var pdfDoc = new Document(PageSize.A4))
            {
                PdfWriter.GetInstance(pdfDoc, new FileStream("Test.pdf", FileMode.Create));
                pdfDoc.Open();

                FontFactory.Register("c:\\windows\\fonts\\tahoma.ttf");

                var tags = new HTMLTagProcessors();
                // Replace the built-in image processor
                tags[HtmlTags.IMG] = new CustomImageHTMLTagProcessor();

                var html = "<img alt='' src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAodJREFUeNpsk0tME1EUhv87UwlCREhRFpi4cGMMRrTE4MaoxBhAsDyMssFHfCQu3BlXGuNKNy5NmqALoqEEMJWCgEUjYojllSpofIUNBNqmIKU6OnQennunUxvgJF86957z/+d27hkGigMlDJfOAmV7AcYsKGqIZljRSvhNE+CMTwEtXmBy2gQb7mCQJUBKkTIQYtfJYCNMAxO9hzq5CYmFiWFY6ISE9VFLRedc1SONeqwf+uJLuKreNPI9nltbLG0orhpqUCM90DRVoEbJ5MSLho1MMg1O0bHOuyoD9crCcxL+xa0HqwL+rEQHsb/CW89reO1aAyEuq+yp+zXvg66rgng8LrDXSmwYpUc8dZkmDsJNL+NCeVVXbWK+O32cpJ7E6OgkwuEwrl8phaHrVsfYD+x03XTPjN3nzZnD0HGxvPppTSLcLwo0I4lldRFK8jdCoZBlJquAbBnr0BD9GUTRvubahclW5qDukqkpIqlodGQ1At3UxZXaIUvauqsyjBV+jZJEJ3s83HO5j+UWI7E6C4mp2EQCTixyV2CvbbKzNmN2zNfHtbzPM3p4FOy/M5CXtwsOKZmmsOi2IHMvyyFhJhgY4BqutQ/aRRstocEngZzswnQnO+x1lqTjy8hIgNdyDc+x5nomxrKJhpcSp2lSrx48WlZhGArynG5hsLLoE7/jQ59f0aR7ZBkdbf7U6Ge+mKYaBvdx8wwZXjtWvfswfTrp3Over29J8NAXYO1t/v/7csZA5U5/Q35nH+aKt8OMR2POPSUFOyRmorvje3BiCt4b9zBANTmwGvP/aMoZRluJbURB8APmnPlQliNLzk8flxbeh9Du8eId5bYQ2SnxH36b/wQYABNFRsIaESsTAAAAAElFTkSuQmCC' />";

                var styles = new StyleSheet();
                styles.LoadTagStyle(HtmlTags.BODY, HtmlTags.FONTFAMILY, "tahoma");
                styles.LoadTagStyle(HtmlTags.BODY, HtmlTags.ENCODING, "Identity-H");

                PdfPCell pdfCell = new PdfPCell { Border = 0 };
                pdfCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;

                using (var reader = new StringReader(html))
                {
                    var parsedHtmlElements = HTMLWorker.ParseToList(reader, styles, tags, null);

                    foreach (var htmlElement in parsedHtmlElements)
                    {
                        pdfCell.AddElement(htmlElement);
                    }
                }

                var table1 = new PdfPTable(1);
                table1.AddCell(pdfCell);
                pdfDoc.Add(table1);
            }

            Process.Start("Test.pdf");
        }
    }
}

#2


5  

Here is the java implementation of custom image tag processor:

这是自定义图像标签处理器的java实现:

package com.example.itext.processor;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.itextpdf.text.Chunk;
import com.itextpdf.text.Element;
import com.itextpdf.text.Image;
import com.itextpdf.text.log.Level;
import com.itextpdf.text.log.Logger;
import com.itextpdf.text.log.LoggerFactory;
import com.itextpdf.text.pdf.codec.Base64;
import com.itextpdf.tool.xml.NoCustomContextException;
import com.itextpdf.tool.xml.Tag;
import com.itextpdf.tool.xml.WorkerContext;
import com.itextpdf.tool.xml.exceptions.LocaleMessages;
import com.itextpdf.tool.xml.exceptions.RuntimeWorkerException;
import com.itextpdf.tool.xml.html.HTML;
import com.itextpdf.tool.xml.pipeline.html.HtmlPipelineContext;

public class ImageTagProcessor extends com.itextpdf.tool.xml.html.Image {

private final Logger logger = LoggerFactory.getLogger(getClass());

/*
 * (non-Javadoc)
 * 
 * @see com.itextpdf.tool.xml.TagProcessor#endElement(com.itextpdf.tool.xml.Tag, java.util.List, com.itextpdf.text.Document)
 */
@Override
public List<Element> end(final WorkerContext ctx, final Tag tag, final List<Element> currentContent) {
    final Map<String, String> attributes = tag.getAttributes();
    String src = attributes.get(HTML.Attribute.SRC);
    List<Element> elements = new ArrayList<Element>(1);
    if (null != src && src.length() > 0) {
        Image img = null;
        if (src.startsWith("data:image/")) {
            final String base64Data = src.substring(src.indexOf(",") + 1);
            try {
                img = Image.getInstance(Base64.decode(base64Data));
            } catch (Exception e) {
                if (logger.isLogging(Level.ERROR)) {
                    logger.error(String.format(LocaleMessages.getInstance().getMessage(LocaleMessages.HTML_IMG_RETRIEVE_FAIL), src), e);
                }
            }
            if (img != null) {
                try {
                    final HtmlPipelineContext htmlPipelineContext = getHtmlPipelineContext(ctx);
                    elements.add(getCssAppliers().apply(new Chunk((com.itextpdf.text.Image) getCssAppliers().apply(img, tag, htmlPipelineContext), 0, 0, true), tag,
                        htmlPipelineContext));
                } catch (NoCustomContextException e) {
                    throw new RuntimeWorkerException(e);
                }
            }
        }

        if (img == null) {
            elements = super.end(ctx, tag, currentContent);
        }
    }
    return elements;
}
}

Following code snippet registers the custom image tag processor and coverts an HTML document to PDF

下面的代码片段注册自定义图像标记处理器,并将HTML文档覆盖到PDF。

public static void main(String[] args) {
    convertHtmlToPdf();

}

private static void convertHtmlToPdf() {
    try {
        final OutputStream file = new FileOutputStream(new File("C:\\Test.pdf"));
        final Document document = new Document();
        final PdfWriter writer = PdfWriter.getInstance(document, file);
        document.open();
        final TagProcessorFactory tagProcessorFactory = Tags.getHtmlTagProcessorFactory();
        tagProcessorFactory.removeProcessor(HTML.Tag.IMG);
        tagProcessorFactory.addProcessor(new ImageTagProcessor(), HTML.Tag.IMG);

        final CssFilesImpl cssFiles = new CssFilesImpl();
        cssFiles.add(XMLWorkerHelper.getInstance().getDefaultCSS());
        final StyleAttrCSSResolver cssResolver = new StyleAttrCSSResolver(cssFiles);
        final HtmlPipelineContext hpc = new HtmlPipelineContext(new CssAppliersImpl(new XMLWorkerFontProvider()));
        hpc.setAcceptUnknown(true).autoBookmark(true).setTagFactory(tagProcessorFactory);
        final HtmlPipeline htmlPipeline = new HtmlPipeline(hpc, new PdfWriterPipeline(document, writer));
        final Pipeline<?> pipeline = new CssResolverPipeline(cssResolver, htmlPipeline);
        final XMLWorker worker = new XMLWorker(pipeline, true);
        final Charset charset = Charset.forName("UTF-8");
        final XMLParser xmlParser = new XMLParser(true, worker, charset);
        final InputStream is = new FileInputStream("C:\\test.html");
        xmlParser.parse(is, charset);

        is.close();
        document.close();
        file.close();
    } catch (Exception e) {
        e.printStackTrace();
        // TODO
    }
}

#3


0  

the solution provided by Ajay Deshwal is a very good reference point to work on .png Base64 images in iText.

Ajay Deshwal提供的解决方案是一个非常好的参考点,可以在iText中使用.png Base64图像。

all i did was to goto my HTMLWOrker and edit the method startElement(String tag, HashMap h);

我所做的就是去找我的HTMLWOrker并编辑方法startElement(字符串标签,HashMap h);

at this section of the method, if (tag.equals(HtmlTags.IMAGE)), blahblah.. just add anther check

在该方法的这一节中,if (tag.equals(htmltag . image)), blahblah。只是添加花药检查

if(src.startsWith("data:image/png;base64")){
        final String base64Data = src.substring(src.indexOf(",") + 1);
try {
        img = Image.getInstance(Base64.decode(base64Data));
} catch (Exception e) {
        throw new ExceptionConverter(e);
}
}

#4


0  

Add the below width and height of the image in the above code of Ajay Deshwal which is working perfectly for me.

在Ajay Deshwal的代码中添加下图的宽度和高度,这对我来说非常完美。

package com.example.itext.processor;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.itextpdf.text.Chunk;
import com.itextpdf.text.Element;
import com.itextpdf.text.Image;
import com.itextpdf.text.log.Level;
import com.itextpdf.text.log.Logger;
import com.itextpdf.text.log.LoggerFactory;
import com.itextpdf.text.pdf.codec.Base64;
import com.itextpdf.tool.xml.NoCustomContextException;
import com.itextpdf.tool.xml.Tag;
import com.itextpdf.tool.xml.WorkerContext;
import com.itextpdf.tool.xml.css.CssUtils;
import com.itextpdf.tool.xml.exceptions.LocaleMessages;
import com.itextpdf.tool.xml.exceptions.RuntimeWorkerException;
import com.itextpdf.tool.xml.html.HTML;
import com.itextpdf.tool.xml.pipeline.html.HtmlPipelineContext;

public class ImageTagProcessor extends com.itextpdf.tool.xml.html.Image {
private final CssUtils utils = CssUtils.getInstance();
private final Logger logger = LoggerFactory.getLogger(getClass());

/*
 * (non-Javadoc)
 * 
 * @see
 * com.itextpdf.tool.xml.TagProcessor#endElement(com.itextpdf.tool.xml.Tag,
 * java.util.List, com.itextpdf.text.Document)
 */
@Override
public List<Element> end(final WorkerContext ctx, final Tag tag,
        final List<Element> currentContent) {
    final Map<String, String> attributes = tag.getAttributes();
    String src = attributes.get(HTML.Attribute.SRC);
    List<Element> elements = new ArrayList<Element>(1);
    if (null != src && src.length() > 0) {
        Image img = null;
        if (src.startsWith("data:image/png;base64")) {
            final String base64Data = src.substring(src.indexOf(",") + 1);
            try {
                img = Image.getInstance(Base64.decode(base64Data));

            } catch (Exception e) {
                if (logger.isLogging(Level.ERROR)) {
                    logger.error(String.format(LocaleMessages.getInstance()
                            .getMessage(
                                    LocaleMessages.HTML_IMG_RETRIEVE_FAIL),
                            src), e);
                }
            }
            if (null != img) {
                String width = attributes.get(HTML.Attribute.WIDTH);
                float widthInPoints = utils.parsePxInCmMmPcToPt(width);
                String height = attributes.get(HTML.Attribute.HEIGHT);
                if (width == null || height == null)
                    img.setScaleToFitLineWhenOverflow(true);
                else
                    img.setScaleToFitLineWhenOverflow(false);
                float heightInPoints = utils.parsePxInCmMmPcToPt(height);
                if (widthInPoints > 0 && heightInPoints > 0) {
                    img.scaleAbsolute(widthInPoints, heightInPoints);
                } else if (widthInPoints > 0) {
                    heightInPoints = img.getHeight() * widthInPoints
                            / img.getWidth();
                    img.scaleAbsolute(widthInPoints, heightInPoints);
                } else if (heightInPoints > 0) {
                    widthInPoints = img.getWidth() * heightInPoints
                            / img.getHeight();
                    img.scaleAbsolute(widthInPoints, heightInPoints);
                }
            }
            if (img != null) {
                try {

                    final HtmlPipelineContext htmlPipelineContext = getHtmlPipelineContext(ctx);
                    elements
                            .add(getCssAppliers()
                                    .apply(
                                            new Chunk(
                                                    (com.itextpdf.text.Image) getCssAppliers()
                                                            .apply(img,
                                                                    tag,
                                                                    htmlPipelineContext),
                                                    0, 0, true), tag,
                                            htmlPipelineContext));
                } catch (NoCustomContextException e) {
                    throw new RuntimeWorkerException(e);
                }
            }
        }

        if (img == null) {
            elements = super.end(ctx, tag, currentContent);
        }
    }
    return elements;
}

}

}

#1


6  

It's possible to replace the built-in tags processors of iText(Sharp). Here is the C# code with custom image tag processor which supports base64 images too. It's easy to convert it to java (base libraries iText and iTextSharp have the same API).

它有可能替换iText(Sharp)内置的标签处理器。这里是带有自定义图像标签处理器的c#代码,它也支持base64图像。很容易将其转换为java(基础库iText和iTextSharp具有相同的API)。

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.html;
using iTextSharp.text.html.simpleparser;
using iTextSharp.text.pdf;

namespace CustomHtmlWorkerTag
{
    /// <summary>
    /// Our custom HTML Tag to add an IElement.
    /// </summary>
    public class CustomImageHTMLTagProcessor : IHTMLTagProcessor
    {
        /// <summary>
        /// Tells the HTMLWorker what to do when a close tag is encountered.
        /// </summary>
        public void EndElement(HTMLWorker worker, string tag)
        {
        }

        /// <summary>
        /// Tells the HTMLWorker what to do when an open tag is encountered.
        /// </summary>
        public void StartElement(HTMLWorker worker, string tag, IDictionary<string, string> attrs)
        {
            Image image;
            var src = attrs["src"];

            if (src.StartsWith("data:image/"))
            {
                // data:[<MIME-type>][;charset=<encoding>][;base64],<data>
                var base64Data = src.Substring(src.IndexOf(",") + 1);
                var imagedata = Convert.FromBase64String(base64Data);
                image = Image.GetInstance(imagedata);
            }
            else
            {
                image = Image.GetInstance(src);
            }

            worker.UpdateChain(tag, attrs);
            worker.ProcessImage(image, attrs);
            worker.UpdateChain(tag);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            using (var pdfDoc = new Document(PageSize.A4))
            {
                PdfWriter.GetInstance(pdfDoc, new FileStream("Test.pdf", FileMode.Create));
                pdfDoc.Open();

                FontFactory.Register("c:\\windows\\fonts\\tahoma.ttf");

                var tags = new HTMLTagProcessors();
                // Replace the built-in image processor
                tags[HtmlTags.IMG] = new CustomImageHTMLTagProcessor();

                var html = "<img alt='' src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAodJREFUeNpsk0tME1EUhv87UwlCREhRFpi4cGMMRrTE4MaoxBhAsDyMssFHfCQu3BlXGuNKNy5NmqALoqEEMJWCgEUjYojllSpofIUNBNqmIKU6OnQennunUxvgJF86957z/+d27hkGigMlDJfOAmV7AcYsKGqIZljRSvhNE+CMTwEtXmBy2gQb7mCQJUBKkTIQYtfJYCNMAxO9hzq5CYmFiWFY6ISE9VFLRedc1SONeqwf+uJLuKreNPI9nltbLG0orhpqUCM90DRVoEbJ5MSLho1MMg1O0bHOuyoD9crCcxL+xa0HqwL+rEQHsb/CW89reO1aAyEuq+yp+zXvg66rgng8LrDXSmwYpUc8dZkmDsJNL+NCeVVXbWK+O32cpJ7E6OgkwuEwrl8phaHrVsfYD+x03XTPjN3nzZnD0HGxvPppTSLcLwo0I4lldRFK8jdCoZBlJquAbBnr0BD9GUTRvubahclW5qDukqkpIqlodGQ1At3UxZXaIUvauqsyjBV+jZJEJ3s83HO5j+UWI7E6C4mp2EQCTixyV2CvbbKzNmN2zNfHtbzPM3p4FOy/M5CXtwsOKZmmsOi2IHMvyyFhJhgY4BqutQ/aRRstocEngZzswnQnO+x1lqTjy8hIgNdyDc+x5nomxrKJhpcSp2lSrx48WlZhGArynG5hsLLoE7/jQ59f0aR7ZBkdbf7U6Ge+mKYaBvdx8wwZXjtWvfswfTrp3Over29J8NAXYO1t/v/7csZA5U5/Q35nH+aKt8OMR2POPSUFOyRmorvje3BiCt4b9zBANTmwGvP/aMoZRluJbURB8APmnPlQliNLzk8flxbeh9Du8eId5bYQ2SnxH36b/wQYABNFRsIaESsTAAAAAElFTkSuQmCC' />";

                var styles = new StyleSheet();
                styles.LoadTagStyle(HtmlTags.BODY, HtmlTags.FONTFAMILY, "tahoma");
                styles.LoadTagStyle(HtmlTags.BODY, HtmlTags.ENCODING, "Identity-H");

                PdfPCell pdfCell = new PdfPCell { Border = 0 };
                pdfCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;

                using (var reader = new StringReader(html))
                {
                    var parsedHtmlElements = HTMLWorker.ParseToList(reader, styles, tags, null);

                    foreach (var htmlElement in parsedHtmlElements)
                    {
                        pdfCell.AddElement(htmlElement);
                    }
                }

                var table1 = new PdfPTable(1);
                table1.AddCell(pdfCell);
                pdfDoc.Add(table1);
            }

            Process.Start("Test.pdf");
        }
    }
}

#2


5  

Here is the java implementation of custom image tag processor:

这是自定义图像标签处理器的java实现:

package com.example.itext.processor;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.itextpdf.text.Chunk;
import com.itextpdf.text.Element;
import com.itextpdf.text.Image;
import com.itextpdf.text.log.Level;
import com.itextpdf.text.log.Logger;
import com.itextpdf.text.log.LoggerFactory;
import com.itextpdf.text.pdf.codec.Base64;
import com.itextpdf.tool.xml.NoCustomContextException;
import com.itextpdf.tool.xml.Tag;
import com.itextpdf.tool.xml.WorkerContext;
import com.itextpdf.tool.xml.exceptions.LocaleMessages;
import com.itextpdf.tool.xml.exceptions.RuntimeWorkerException;
import com.itextpdf.tool.xml.html.HTML;
import com.itextpdf.tool.xml.pipeline.html.HtmlPipelineContext;

public class ImageTagProcessor extends com.itextpdf.tool.xml.html.Image {

private final Logger logger = LoggerFactory.getLogger(getClass());

/*
 * (non-Javadoc)
 * 
 * @see com.itextpdf.tool.xml.TagProcessor#endElement(com.itextpdf.tool.xml.Tag, java.util.List, com.itextpdf.text.Document)
 */
@Override
public List<Element> end(final WorkerContext ctx, final Tag tag, final List<Element> currentContent) {
    final Map<String, String> attributes = tag.getAttributes();
    String src = attributes.get(HTML.Attribute.SRC);
    List<Element> elements = new ArrayList<Element>(1);
    if (null != src && src.length() > 0) {
        Image img = null;
        if (src.startsWith("data:image/")) {
            final String base64Data = src.substring(src.indexOf(",") + 1);
            try {
                img = Image.getInstance(Base64.decode(base64Data));
            } catch (Exception e) {
                if (logger.isLogging(Level.ERROR)) {
                    logger.error(String.format(LocaleMessages.getInstance().getMessage(LocaleMessages.HTML_IMG_RETRIEVE_FAIL), src), e);
                }
            }
            if (img != null) {
                try {
                    final HtmlPipelineContext htmlPipelineContext = getHtmlPipelineContext(ctx);
                    elements.add(getCssAppliers().apply(new Chunk((com.itextpdf.text.Image) getCssAppliers().apply(img, tag, htmlPipelineContext), 0, 0, true), tag,
                        htmlPipelineContext));
                } catch (NoCustomContextException e) {
                    throw new RuntimeWorkerException(e);
                }
            }
        }

        if (img == null) {
            elements = super.end(ctx, tag, currentContent);
        }
    }
    return elements;
}
}

Following code snippet registers the custom image tag processor and coverts an HTML document to PDF

下面的代码片段注册自定义图像标记处理器,并将HTML文档覆盖到PDF。

public static void main(String[] args) {
    convertHtmlToPdf();

}

private static void convertHtmlToPdf() {
    try {
        final OutputStream file = new FileOutputStream(new File("C:\\Test.pdf"));
        final Document document = new Document();
        final PdfWriter writer = PdfWriter.getInstance(document, file);
        document.open();
        final TagProcessorFactory tagProcessorFactory = Tags.getHtmlTagProcessorFactory();
        tagProcessorFactory.removeProcessor(HTML.Tag.IMG);
        tagProcessorFactory.addProcessor(new ImageTagProcessor(), HTML.Tag.IMG);

        final CssFilesImpl cssFiles = new CssFilesImpl();
        cssFiles.add(XMLWorkerHelper.getInstance().getDefaultCSS());
        final StyleAttrCSSResolver cssResolver = new StyleAttrCSSResolver(cssFiles);
        final HtmlPipelineContext hpc = new HtmlPipelineContext(new CssAppliersImpl(new XMLWorkerFontProvider()));
        hpc.setAcceptUnknown(true).autoBookmark(true).setTagFactory(tagProcessorFactory);
        final HtmlPipeline htmlPipeline = new HtmlPipeline(hpc, new PdfWriterPipeline(document, writer));
        final Pipeline<?> pipeline = new CssResolverPipeline(cssResolver, htmlPipeline);
        final XMLWorker worker = new XMLWorker(pipeline, true);
        final Charset charset = Charset.forName("UTF-8");
        final XMLParser xmlParser = new XMLParser(true, worker, charset);
        final InputStream is = new FileInputStream("C:\\test.html");
        xmlParser.parse(is, charset);

        is.close();
        document.close();
        file.close();
    } catch (Exception e) {
        e.printStackTrace();
        // TODO
    }
}

#3


0  

the solution provided by Ajay Deshwal is a very good reference point to work on .png Base64 images in iText.

Ajay Deshwal提供的解决方案是一个非常好的参考点,可以在iText中使用.png Base64图像。

all i did was to goto my HTMLWOrker and edit the method startElement(String tag, HashMap h);

我所做的就是去找我的HTMLWOrker并编辑方法startElement(字符串标签,HashMap h);

at this section of the method, if (tag.equals(HtmlTags.IMAGE)), blahblah.. just add anther check

在该方法的这一节中,if (tag.equals(htmltag . image)), blahblah。只是添加花药检查

if(src.startsWith("data:image/png;base64")){
        final String base64Data = src.substring(src.indexOf(",") + 1);
try {
        img = Image.getInstance(Base64.decode(base64Data));
} catch (Exception e) {
        throw new ExceptionConverter(e);
}
}

#4


0  

Add the below width and height of the image in the above code of Ajay Deshwal which is working perfectly for me.

在Ajay Deshwal的代码中添加下图的宽度和高度,这对我来说非常完美。

package com.example.itext.processor;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.itextpdf.text.Chunk;
import com.itextpdf.text.Element;
import com.itextpdf.text.Image;
import com.itextpdf.text.log.Level;
import com.itextpdf.text.log.Logger;
import com.itextpdf.text.log.LoggerFactory;
import com.itextpdf.text.pdf.codec.Base64;
import com.itextpdf.tool.xml.NoCustomContextException;
import com.itextpdf.tool.xml.Tag;
import com.itextpdf.tool.xml.WorkerContext;
import com.itextpdf.tool.xml.css.CssUtils;
import com.itextpdf.tool.xml.exceptions.LocaleMessages;
import com.itextpdf.tool.xml.exceptions.RuntimeWorkerException;
import com.itextpdf.tool.xml.html.HTML;
import com.itextpdf.tool.xml.pipeline.html.HtmlPipelineContext;

public class ImageTagProcessor extends com.itextpdf.tool.xml.html.Image {
private final CssUtils utils = CssUtils.getInstance();
private final Logger logger = LoggerFactory.getLogger(getClass());

/*
 * (non-Javadoc)
 * 
 * @see
 * com.itextpdf.tool.xml.TagProcessor#endElement(com.itextpdf.tool.xml.Tag,
 * java.util.List, com.itextpdf.text.Document)
 */
@Override
public List<Element> end(final WorkerContext ctx, final Tag tag,
        final List<Element> currentContent) {
    final Map<String, String> attributes = tag.getAttributes();
    String src = attributes.get(HTML.Attribute.SRC);
    List<Element> elements = new ArrayList<Element>(1);
    if (null != src && src.length() > 0) {
        Image img = null;
        if (src.startsWith("data:image/png;base64")) {
            final String base64Data = src.substring(src.indexOf(",") + 1);
            try {
                img = Image.getInstance(Base64.decode(base64Data));

            } catch (Exception e) {
                if (logger.isLogging(Level.ERROR)) {
                    logger.error(String.format(LocaleMessages.getInstance()
                            .getMessage(
                                    LocaleMessages.HTML_IMG_RETRIEVE_FAIL),
                            src), e);
                }
            }
            if (null != img) {
                String width = attributes.get(HTML.Attribute.WIDTH);
                float widthInPoints = utils.parsePxInCmMmPcToPt(width);
                String height = attributes.get(HTML.Attribute.HEIGHT);
                if (width == null || height == null)
                    img.setScaleToFitLineWhenOverflow(true);
                else
                    img.setScaleToFitLineWhenOverflow(false);
                float heightInPoints = utils.parsePxInCmMmPcToPt(height);
                if (widthInPoints > 0 && heightInPoints > 0) {
                    img.scaleAbsolute(widthInPoints, heightInPoints);
                } else if (widthInPoints > 0) {
                    heightInPoints = img.getHeight() * widthInPoints
                            / img.getWidth();
                    img.scaleAbsolute(widthInPoints, heightInPoints);
                } else if (heightInPoints > 0) {
                    widthInPoints = img.getWidth() * heightInPoints
                            / img.getHeight();
                    img.scaleAbsolute(widthInPoints, heightInPoints);
                }
            }
            if (img != null) {
                try {

                    final HtmlPipelineContext htmlPipelineContext = getHtmlPipelineContext(ctx);
                    elements
                            .add(getCssAppliers()
                                    .apply(
                                            new Chunk(
                                                    (com.itextpdf.text.Image) getCssAppliers()
                                                            .apply(img,
                                                                    tag,
                                                                    htmlPipelineContext),
                                                    0, 0, true), tag,
                                            htmlPipelineContext));
                } catch (NoCustomContextException e) {
                    throw new RuntimeWorkerException(e);
                }
            }
        }

        if (img == null) {
            elements = super.end(ctx, tag, currentContent);
        }
    }
    return elements;
}

}

}