Forum Replies Created

Viewing 15 posts - 61 through 75 (of 4,249 total)
  • Author
    Posts
  • in reply to: Rendering images
    #27356

    Image embedding is one of the major functions of PD4ML, which is available since the first version of the software. So normally for GIF, JPEG and PNG it should be no problems.

    A possible reason of the issue is image addressing: you need to make sure, that image URLs are either fully-specified (include protocol, server, port), or the URLs are relative to the actual document location (or to setting of the doc). If the image URL is defined like

    /WebAppName/path/to/image.gif”

    PD4ML requires, that you pass current servlet context to it with

    useServletContext(ServletContext ctx)

    otherwise PD4ML has no chance to resolve the virtual path. (PD4ML JSP Taglib triggers the method implicitly)

    If the above is not relevant for your particular case, please provide us with some more info:

    • PD4ML usage scenario: Java, JSP, PHP, etc…
    • A sample of image reference
    • PD4ML debug output for a case, when it cannot load an image ()you may switch the debug output on with pd4ml.enableDebugInfo() call
    in reply to: Rendering images
    #27357

    Ok, here are more details:
    It is a Java application. JDK 1.4.

    The process is writing the HTML in a path, then the HTML is read from the path to write the PDF in the same path. Ex:

    File fz = new File(path+filename); //HTML to read
    java.io.FileInputStream fis = new java.io.FileInputStream(fz);
    InputStreamReader isr = new InputStreamReader( fis );

    The images are being rendered correctly in most cases, but for example when I mix different kind of images (jpg, png, gif) in the HTML to export, then the last kind of image fails, when the ssame image in the same path can be rendered when it is the only image.
    Here is the output of pd4ml on debug mode:

    version: PD4ML 350 Pro (eval)
    not yet in cache: file:C:\Fonts/pd4fonts.properties
    ‘serif’ is not in pd4fonts.properties file
    reject TTF lookup for: ‘serif’
    not yet in cache: file:C:\Fonts/times.ttf
    read ‘times new roman’ from file:C:\Fonts/times.ttf
    ‘serif bold’ is not in pd4fonts.properties file
    reject TTF lookup for: ‘serif bold’
    not yet in cache: file:C:\Fonts/timesbd.ttf
    read ‘times new roman bold’ from file:C:\Fonts/timesbd.ttf
    not yet in cache: file:C:\Fonts/verdana.ttf
    read ‘verdana’ from file:C:\Fonts/verdana.ttf
    image not yet in cache: image not yet in cache: http://xxx.xxx.x.xxx/mgr/attach/mmfiles/HT24603dp254.jpg
    not yet in cache: http://xxx.xxx.x.xxx/mgr/attach/mmfiles/HT24603dp254.jpg
    image size: 116658
    image not yet in cache: http://xxx.xxx.x.xxx/mgr/attach/mmfiles/HT24604Control Panel Exhibit_1246900352801.gif
    not yet in cache: http://xxx.xxx.x.xxx/mgr/attach/mmfiles/HT24604Control Panel Exhibit_1246900352801.gif
    resource http://xxx.xxx.x.xxx/mgr/attach/mmfiles/HT24604Control Panel Exhibit_1246900352801.gif not found.
    image http://xxx.xxx.x.xxx/mgr/attach/mmfiles/HT24604Control Panel Exhibit_1246900352801.gif not found.
    can not load image: http://xxx.xxx.x.xxx/mgr/attach/mmfiles/HT24604Control Panel Exhibit_1246900352801.gif
    not yet in cache: file:C:\Fonts/cour.ttf
    read ‘courier new’ from file:C:\Fonts/cour.ttf
    done in 1817ms.

    On the last lines there is a message that an image can not be loaded. But I copy that URL to the browser and the image can be reached with out problem.

    If you need some more information please let me know. Thanks for the help.

    in reply to: Rendering images
    #27358

    I would suspect space characters in the image URLs.

    Try to replace them with “%20”

    in reply to: Rendering images
    #27359

    Yes it was that, the spaces in the image path can not be resoved by pd4ml. Thanks

    One more question, is there a way to autofit an image according to the pdf? I mean when I hace the img tag and it doesn’t specify a size, the image in the pdf is bigger or seems strange. So, is it possible or a way to autofit the image according to the PDF size?

    in reply to: General questions / FAQ
    #26223

    I am attempting to perform a proof of concept using the trial version of PD4ML and java (no jsp). I want to be able to display multiple tables in the header and footer. When I create a string containing html table tags and use setHtmlTemplate(htmlstring) to place this string in the header the rendered HTML does not appear in the resulting PDF document. I am wondering what I am doing wrong.

    My test code looks like this:

    [language=java:3fb0dy6f]private void generatePDF(String inputHTMLFileName, File outputPDFFile,
    Dimension format, String fontsDir, String headerBody)
    throws Exception
    {
    java.io.FileOutputStream fos = new java.io.FileOutputStream(outputPDFFile);
    PD4ML pd4ml = new PD4ML();
    pd4ml.setPageInsets(new Insets(20, 10, 10, 10));
    pd4ml.setHtmlWidth(950);
    pd4ml.enableImgSplit(false);
    if ( fontsDir != null && fontsDir.length() > 0 ) {
    pd4ml.useTTF( fontsDir, true );
    }
    PD4PageMark header = new PD4PageMark();
    header.setAreaHeight( 20 );
    header.setHtmlTemplate(populateHTMLHeaderFields());
    pd4ml.setPageHeader( header );
    pd4ml.render(“file:” + inputHTMLFileName, fos);
    }

    private String populateHTMLHeaderFields()
    {
    StringBuffer str = new StringBuffer();

    str.append(“

    “);
    str.append(“Name: John Doe”);
    str.append(“
    “);
    str.append(“DOCUMENT PRINT TEST”);
    str.append(“
    “);
    str.append(“07/09/09”);
    str.append(“

    “);
    str.append(““);

    return str.toString();
    }[/language:3fb0dy6f]
    Am I using setHtmlTemplate() incorrectly?

    thank you for your help.

    jean

    #27374

    setHtmlTemplate() works in the trial versions. But it is a feature of PD4ML Pro, so first make sure you use Pro version of the software.

    The simpliest way to check that is to run PD4ML in GUI mode and to open About dialog:

    [language=java:3j8ekjgx]java -jar pd4ml_demo.jar[/language:3j8ekjgx]
    Also try to set header.setAreaHeight( -1 ); to autocompute the header height. You use 20pt height, which may be too low for the header table (only table margins fit the space; the content is clipped)

    #27375

    Thank you for your help. I will try your suggestions!

    in reply to: PD4ML Tips & Tricks
    #26224

    Hi,

    I am using the latest java version of pd4ml and noticed that utf-8 encoded html pages with Chinese characters are not converted properly. The chinese characters appear like ??? in the generated pdf. Please let me know how to fix it.

    PS: I am using command line execution on unix

    Thanks!

    in reply to: HTML/CSS rendering issues
    #26225

    Hi

    Is it possible to ensure that a div dose not get split over pages in the same way as a

    with style=”page-break-inside:avoid;”

    so

    ??

    would be very useful to know..

    many thanks

    mil
      in reply to: Troubleshooting
      #26226

      Hello,

      I’m currently evaluating pd4ml. I’ve a problem using the method PD4ML.setDynamicParams(). As this works well for parameters defined in the page body, dynamic parameters in the header don’t get replaced by the value stored in the map given to the setDynamicParams() method.

      Here is a code fragment showing how I proceeded:

      [language=java:5w376w5i]final PD4ML pdfCreator = new PD4ML();
      final Map dynamic = new HashMap();
      dynamic.put(“variable”,”value”);
      pdfCreator.setDynamicParams(dynamic);

      final PD4PageMark header = new PD4PageMark();

      //$[variable] is contained in “someHTML”, e.g. $[variable]
      header.setHtmlTemplate(someHTML);

      header.setAreaHeight(-1);
      pdfCreator.setPageHeader(header);

      //if $[variable] is contained in the HTML code returned by url, its value gets replaced as expected
      pdfCreator.render(url, outputStream);[/language:5w376w5i]
      I use the current version of pd4ml (3.5.1b1). Am I doing anything wrong?

      Regards,
      Matthias

      in reply to: Dynamic parameters
      #27385

      Yes, you are right. PD4ML does not substitute placeholders for headers/footers defined that way (however it works for inline headers and footers, i.e. )

      It is quite a trivial task to replace the placeholders in someHTML before it passed to PD4ML. For example, with String.replaceAll() Java API call.

      If the workaround, for some reasons, is not acceptable by you, or if you want to keep the placeholder replacement mechanism of PDF generating module in your application consistent, we could add the feature to the forthcomming release.

      in reply to: Conversion issue with Chinese characters
      #27376

      ??? characters instead of CJK glyphs may appear in two cases:

      mil
        in reply to: Dynamic parameters
        #27386

        Thanks a lot for your quick response! This restriction won’t be a showstopper for us as there’s the comfortable workaround you’ve mentioned. (We’ve already thought of that workaorund before posting the question to the forum: Our intention was prevent “to reinvent the wheel”, that means use the given method if possible.)

        Regards,
        Matthias

        mil
          in reply to: Troubleshooting
          #26227

          Hello,

          we have a problem in conjunction with the definition of stylesheets. Currently we set the stylesheet file via call to PD4ML.addStyle(), e.g.

          [language=java:24wq1k8v]pdfCreator.addStyle(someUrl, true);[/language:24wq1k8v]

          We define the page header using the method PD4ML.setPageHeader(somePD4PageMark).

          We use PD4PageMark.setHTMLTemplate(someHTML) to set the HTML content.

          First of all: Does “someHTML” have to be valid HTML, that means does it have to contain tags like “” or ““?

          After that, we render the page using the method PD4ML.render(someURL, someStream);

          (Again: Does the HTML returned by “someURL” have to be valid HTML?)

          The problem concerning the stylesheet definition now is as follows:
          The stylesheet file contains the following style definition:

          body {
          background-color: white;
          font-family: Arial,Helvetica,Geneva,sans-serif;
          }

          The resulting pdf document only contains the header, but not the content retrieved by call to PD4ML.render(). (We found out that the content somehow gets painted over by the background-color.)
          After removing “background-color: white” out of this style definition, everthing works fine. As our customers can define their own styles for their printings, we cannot assure that a customers won’t create a stylesheet we ran in problems with. Could you please instruct us how to prevent that issue?

          Regards,
          Matthias

          in reply to: HTML-to-Image conversion with PD4ML
          #27258

          We are looking to use this feature however we would like some additional documentation on what the parameters are and how we can make use of them.
          I have only seen this feature referenced in release notes and this forum. There is no mention in the API or Reference manual that I have found.

          Thanks , James

        Viewing 15 posts - 61 through 75 (of 4,249 total)