Forum Replies Created

Viewing 15 posts - 16 through 30 (of 4,246 total)
  • Author
    Posts
  • in reply to: General questions / FAQ
    #26181

    The process of HTML to PDF converting includes a step called “HTML rendering”. That means that the original HTML document is completely loaded and processed in RAM: HTML elements must be correctly positioned, images loaded, texts aligned, table column widths balanced, styles applied and so forth. The specifics of HTML rendering do not allow PD4ML to perform the converting to PDF by portions. So the maximal sizes of HTML and PDF depend on your JVM’s available memory resources.

    in reply to: General questions / FAQ
    #26182

    Basically it is PDF v1.4, however some features may come from later PDF specifications. It should not be a problem even if you use very old PDF viewer applications: as a rule PDF viewers ignore code/features they do not “understand”.

    in reply to: General questions / FAQ
    #26183

    PD4ML is intended to be used with JDK1.4 and above, although it works with minor restrictions under JDK1.3.1 as well.

    in reply to: General questions / FAQ
    #26184

    Standard version of PD4ML output PDFs that only refer to the standard fonts, come with Adobe Acrobat Reader: Courier,Times Roman and Helvetica.

    PD4ML Pro has no such limitations: it provides support for True Type and Open Type font embedding.

    in reply to: General questions / FAQ
    #26185

    PD4ML provides basic HTML 3.2 and HTML 4.0 support with some exceptions. Here is the list of supported tags.

    The list of supported CSS properties is based on CSS2 plus some features of CSS3.

    Both lists are not full yet, but constantly grow.

    PD4ML requires inline CSS sections or references to external CSS style sheets are located within tag.

    in reply to: General questions / FAQ
    #26188

    PD4ML allows you to secure your PDF documents with 40-bit/128-bit encryption. You can disable printing, modifications or extracting of text content, you can lock your PDF with a password.

    PD4ML API call example:

    [language=java:1n84lpj4]htmlConverter.setPermissions( “empty”,
    PD4Constants.AllowAnnotate | PD4Constants.AllowAssembly |
    PD4Constants.AllowContentExtraction | PD4Constants.AllowCopy |
    PD4Constants.AllowFillingForms | PD4Constants.AllowModify |
    PD4Constants.AllowPrint, true);[/language:1n84lpj4]

    The constants in the sample above represent integer values. If you use PD4ML JSP taglib you would need to pass the sum of the permission constant values.

    [language=xml:1n84lpj4][/language:1n84lpj4]

    The values correspond to the values defined in Adobe PDF specification and may be also taken from there.

    in reply to: General questions / FAQ
    #26189

    PD4ML is written 100% in Java and intended to be OS-independent. It is compatible with JDK 1.3 and above.

    Before being released every version of PD4ML is extensively tested on Solaris, Linux, Win32 with JDK 1.3-1.6 and under the following servlet engines / application servers:

    • Tomcat 4.1
    • Tomcat 5.5
    • Resin 2.1.17
    • JBoss 3.2.8

    Our customers successfully use PD4ML with Bea WebLogic, IBM WebSphere, Oracle Application Server. Supported hardware platforms include also MacOSX, HP/UX, AS/400, iSystem, mainframes (zOS) and many more.

    in reply to: Deployment / Configuration issues
    #26191

    If you use PD4ML in Java desktop application or with Java Servlet, than you need pd4ml.jar (or pd4ml_demo.jar) and a third-party library developed by CSS Parser open-source project ss_css2.jar, which can be found in lib/ subdirectory of PD4ML distribution package.

    If you plan to use PD4ML in JSP as JSP tag library, than you need in addition to the main pd4ml.jar to install pd4ml_tl.jar (pd4ml_tl_demo.jar) and pd4ml.tld files. The files can be found in the sample web application directory structure in taglib/WEB-INF/lib and taglib/WEB-INF/tlds.

    in reply to: Troubleshooting
    #26192

    [language=java:2s3u5kau]java.io.IOException: reset() not supported
    at java.io.Reader.reset(Reader.java:231)
    at org.zefer.C.B.K.A(Unknown Source)
    at org.zefer.C.B.K.?(Unknown Source)
    at org.zefer.pd4ml.PD4ML.A(Unknown Source)
    at org.zefer.pd4ml.PD4ML.render(Unknown Source)
    at org.zefer.pd4ml.PD4ML.render(Unknown Source)[/language:2s3u5kau]

    Problem is caused by a difference in the HTML encoding (given in html meta tag) and the actually used stream encoding.

    HTML parser takes default encoding this way:
    System.getProperty(“file.encoding”, “ISO8859_1”);

    The document encoding obtained from tag

    If the encodings does not match, than PD4ML tries to reset stream and to re-read it again respecting “Content-Type”. For some streams/readers it does not work.

    In order to fix the problem you could do one of the following:

    • remove if your document is not UNICODE and has Latin chars only
    • set XXX of to the same value, as returned by System.getProperty(“file.encoding”, “ISO8859_1”);
    • run your JVM with -Dfile.encoding=XXX parameter, where XXX is the HTML encoding
    • use the following PD4ML API call render(Reader isr, OutputStream os, URL base, String encoding) where the last parameter should match the HTML encoding
    in reply to: Troubleshooting
    #26193

    [language=java:1v7z3m0a]java.lang.NullPointerException
    at org.zefer.C.B.C.B.A(Unknown Source)
    at org.zefer.C.B.K.U(Unknown Source)
    at org.zefer.pd4ml.PD4ML.A(Unknown Source)
    at org.zefer.pd4ml.PD4ML.render(Unknown Source)[/language:1v7z3m0a]

    It is a bug in v3.0 code. The API call
    pd4ml.render(InputStreamReader, OutputStream);
    provides no default base URL.

    Please upgrade or use the following API call:
    pd4ml.render(InputStreamReader, OutputStream, new URL(“file:.”));

    in reply to: Troubleshooting
    #26194

    The “dead lock” happens if you try to use PD4ML with the JVM, whose default AWT toolkit is replaced with PJAToolkit or similar. You can check if it is your case by inspecting the JVM command line or JVM environment. It appears as
    awt.toolkit=com.eteks.awt.PJAToolkit
    variable assignment.

    in reply to: HTML/CSS rendering issues
    #26197

    Hi,

    sometimes when i generate a PDF file with pd4ml api, the text in tables, overflow the right margin of the document and some words os the text disappear. Sometimes the text appears over the border line of the table. like this:

    |
    text to be showed
    |
    or
    text to be |

    Anybody can help me? is there a trick to do that, or fix it?

    regards,
    Chico

    in reply to: Troubleshooting
    #26198

    My html includes references to images. When producing the PDF from the HTML, the images are scaled for some reason, causing anti-aliasing issues and display problems on the image.

    Is there any way to prevent this scaling from happening for images?

    in reply to: PD4ML Tips & Tricks
    #26199

    PD4ML component architecture includes two parts: HTML renderer and PDF writer. PDF wtiter is inherited from java.awt.Graphics and adds some extra methods, for example, for page breaking.

    On practice it is possible to substitute the PDF output device with any other “device”, implements java.awt.Graphics interface.

    As an exapmple here is BufferedImage output code.

    [language=java:p98q1s2s]private BufferedImage htmlToImage( URL path, int width,
    String ttfDir, boolean debug ) {

    PD4MLHtmlParser parser = new PD4MLHtmlParser(path, ttfDir, null, null, null,
    false, null, null, debug, null, null, -1, false);

    Document doc = parser.buildDocument();

    doc.layout(width);

    int height = doc.getHeight();

    if ( height > 48000 ) {
    height = 48000;
    }

    BufferedImage image =
    new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);

    Graphics g = image.getGraphics();
    g.setColor(Color.white);
    g.fillRect(0, 0, width, height);

    doc.paint(0, 0, new Rectangle(0, 0, width, height), g);

    return image;
    }[/language:p98q1s2s]

    The code above renders HTML as a single image. In the following sample it splits the HTML layout into smaller portions and produces a set of images (pages):

    [language=java:p98q1s2s]private Vector htmlToImages( URL path, int width,
    int pageHeight, String ttfDir, boolean debug ) {

    PD4MLHtmlParser parser = new PD4MLHtmlParser(path, ttfDir, null, null, null,
    false, null, null, debug, null, null, -1, false);

    Document doc = parser.buildDocument();

    doc.layout(width);

    int height = doc.getHeight();
    int pageNum = (int)((float)height / pageHeight + 1);

    Vector result = new Vector();

    for ( int i = 0; i < pageNum; i++ ) { BufferedImage image = new BufferedImage(width, pageHeight, BufferedImage.TYPE_4BYTE_ABGR); Graphics g = image.getGraphics(); g.setColor(Color.white); g.fillRect(0, 0, width, pageHeight); doc.paint(0, -(pageHeight * i), new Rectangle(0, -(pageHeight * i), width, pageHeight * (i+1)), g); result.addElement(image); } return result; }[/language:p98q1s2s] The resulting BufferedImage may be easily converted to GIF, JPEG or PNG. With support of JAI it may be converted to virtually any raster image format, including TIFF. The examples above do not respect page break tags, defined in HTML. A support of page breaks would require a more sophisticated technique (which is also supported by PD4ML).

    in reply to: PD4ML Tips & Tricks
    #26200

    In most of the situations PD4ML is able to resolve relative or absolute resource references (to images, to CSS etc) and load them. However there are special cases, when the default mechanisms are not sufficient.

    For example:

    • The resources are stored in an unusual place, i.e. in a database.
    • The resources are referenced by an “exotic” or non-standard protocol. For instance, Weblogic and WebSphere SSL implementations are not derived from the standard JDK SSL classes PD4ML relies on, so it causes ClassCastException.

    As a workaround PD4ML allows you to create your own resource loader, which takes an URL as a parameter, and should return the loaded resource as an array of bytes.

    [language=java:1r83hefy]import java.io.BufferedInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.net.URL;
    import java.net.URLConnection;

    import org.zefer.cache.ResourceProvider;

    public class CustomFileResourceProvider extends ResourceProvider {

    public byte[] getResourceAsBytes(String resource, boolean debugOn) throws IOException {
    ByteArrayOutputStream fos = new ByteArrayOutputStream();
    byte buffer[] = new byte[2048];

    InputStream is = null;

    resource = “http://pd4ml.com/i/&#8221; + resource;

    URL src = new URL(resource);
    URLConnection urlConnect = src.openConnection();
    try {
    urlConnect.connect();
    } catch (Throwable e) {
    return new byte[0];
    }
    is = urlConnect.getInputStream();
    BufferedInputStream bis = new BufferedInputStream(is);

    int read;
    do {
    read = is.read(buffer, 0, buffer.length);
    if (read > 0) { // something to put down
    fos.write(buffer, 0, read);
    }
    } while (read > -1);

    fos.close();
    bis.close();
    is.close();

    return fos.toByteArray();
    }
    }[/language:1r83hefy]

    In order to enable the loader, you may either pass to PD4ML the class name with an environment variable (add the following to JVM command line):

    -Dpd4ml.extra.resource.loaders=CustomFileResourceProvider

    or via API call:

    [language=java:1r83hefy]HashMap map = new HashMap();
    map.put( “pd4ml.extra.resource.loaders”, “CustomFileResourceProvider” );
    pd4ml.setDynamicParams(map);[/language:1r83hefy]

    It may also be a coma-separated list of multiple resource loaders.

Viewing 15 posts - 16 through 30 (of 4,246 total)