Forum Replies Created

Viewing 15 posts - 2,821 through 2,835 (of 4,234 total)
  • Author
    Posts
  • in reply to: HTML/CSS rendering issues
    #27001

    For test purposes, I have created a simple html file which has a simple table with the width of 600 pixel and a single row and column containing a little text snippet with font size 20pt and font family Verdana.
    If I generate a pdf file from the html file mentioned above using pd4ml pro, the created pdf file contains a table with exactly 600 pixel as well but the width of the text snippet (I measured the width of the whole text with a pixel ruler tool) is about 70 pixel less than the width of the same text displayed in the browser(displaying the original html file).

    That’s the important part of the pd4ml generation code:

    PD4ML pd4ml = new PD4ML();
    pd4ml.setPageSize(PD4Constants.A4);
    pd4ml.setHtmlWidth(793);
    pd4ml.setPageInsets(new Insets(0, 0, 0, 0));
    ……
    As you can see I set the html width to 793 pixel, which corresponds to the width of A4 with 595 points (I did the test on a windows machine which uses 96 dpi, what means that 595 points corresponds to 595 point * 1,3333 = 793 pixel, I think).
    Furthermore I did not set any insets.

    So I think I can calculate the scale factor the following way:

    (pageFormat.width – pageInsets.left – pageInsets.right) / htmlWidth = scale

    (595 pt – 0 – 0) /(595 pt ≙ 793 px) = 1

    Although the scale factor is 1, the width of the text within the generated pdf file has not the same size as the same text displayed by the browser.

    What did I wrong?

    in reply to: Scaling problems
    #29696

    A text width also depends on a particular font used.

    By default (when no TTF embedding configured), PD4ML outputs PDFs refer to Acroread’s built-in Type1 fonts; a Web browser most probably uses standard TTF from OS.

    Helvetica of Acroread looks very similar to Arial, but in fact they are not exactly the same (especially in glyph widths). Probably that is the reason.

    Try to configure TTF embedding and compare PDF and rendered HTML again.

    in reply to: HTML/CSS rendering issues
    #27002

    Hi Team,

    I am using .NET trial version of PD4ml and following code:

    public static void savePDF()
    {
    String path = null;
    PD4ML PDFcreator = new PD4ML();
    PDFcreator.PageSize = PD4Constants.A5;
    byte[] bytes = Encoding.UTF8.GetBytes(template);

    MemoryStream ms_reader = new MemoryStream(bytes);
    MemoryStream ms_writer = new MemoryStream(bytes);

    StreamReader reader = new StreamReader(ms_reader);

    SaveFileDialog saveFileDialog = new SaveFileDialog();
    saveFileDialog.InitialDirectory = “%UserProfile%/Desktop”;
    saveFileDialog.Filter = “pdf files (*.pdf)|*.pdf”;
    saveFileDialog.FilterIndex = 1;
    saveFileDialog.RestoreDirectory = true;
    StreamWriter writer = null;

    Stream myStream = ms_writer;

    try
    {
    if (saveFileDialog.ShowDialog() == DialogResult.OK)
    {
    path = saveFileDialog.FileName;
    writer = new StreamWriter(path);
    //PDFcreator.render(ms_reader, writer);
    PDFcreator.render(reader, writer);
    //PDFcreator.render(ms, myStream);
    //PDFcreator.render(reader, myStream);
    }
    }

    catch (Exception ex)
    {
    MessageBox.Show(ex.StackTrace);
    }

    finally
    {
    if (ms_reader != null)
    {
    ms_reader.Close();
    }
    if (reader != null)
    {
    reader.Close();
    }
    if (writer != null)
    {
    writer.Close();
    }
    }
    }

    I am getting an exception whenever I render this PDF. The exception reads as “Cannot read from Closed stream”; but I am not closing stream before render().

    There are 5 render() overloaded methods to writehtml template to a PDF file and I used all of them; but still no luck.

    And also I would like to understand is PD4ml trial version not letting me to render HTML as PDF or is PD4ml very strict to HTML tags…

    Please suggest.

    in reply to: Deployment / Configuration issues
    #27003

    We have moved our application to a new webserver. Now renders that used to take under a second are taking over a minute, or timing out. Any ideas as to what is wrong?

    in reply to: Performance Issue
    #29697

    Try to switch debug on (pd4ml.enableDebugInfo()) and inspect server’s log file (or STDOUT) if there are any requests to remote resources, could possibly cause a network delay.

    in reply to: HTML/CSS rendering issues
    #27004

    I am evaluating pd4ml. I have downloaded a few different version and I am comparing the resulting PDF generated from the same source web page and am seeing a significant difference in how it is rendered. In all cases I used the command line to generate the PDFs. I am currently using Java 8 on Windows 8.1 for the versions that require Java.

    I created a PDF using:
    1) pd4ml.web.win32.trial.090b2
    2) pd4ml.pro.trial.395
    3) pd4ml.pro.trial.dotnet20.385b1

    Option 1 rendered the page fairly well and was the closest to the original HTML page. Option 2 and 3 both did a terrible job rendering the page. Images were laid upon each other, tables were truncated, and many other styles were ignored or misinterpreted.
    The original page contains data URIs for images and css.

    To be honest I wasn’t sure what the differences other than version were between all the different download choices so I tried several of them.

    Am I using the correct versions? Are others experiencing the anything similar?

    Thank you.

    in reply to: HTML/CSS rendering issues
    #27005

    Hi,
    in our HTML we are including dynamic params (http://pd4ml.com/cookbook/pdf_dynamic_values.htm)

    It works well until we are enclosing the dynamic param with an HTML element having a css property text-transform uppercase

    dynamic param here

    The dynamic param is not replaced

    It seems that PD4ML is applying the css uppercase before replacing dynamic params

    in reply to: Rending issues with 395 for images and tables
    #29698

    PD4ML Std and Pro were never positioned as a solution for web sites capture. The 100% Java libraries allow you to define (or auto-generate) a PDF document template layout an easy way with a markup language everybody knows: HTML. As a pure Java solution it has its performance drawbacks and limitations – it just cannot compete in a page rendering quality with major web browsers when converting interactive media-rich web sites.

    PD4ML Web is intended to address the issues of Std/Pro, but unfortunately has its own limitations. It is built as a wrapper for PhantomJS/Webkit (native platform executable) runtime and exposes PD4ML API for Java applications. It utilizes print/PDF export subsystem of Webkit. An advantage of the approach is very good HTML rendering quality, but its PDF output is quite basic and not optimized: no support for hyperlinks, outlines, attachments, no flexibility with header/footer definitions, fonts are not shaped etc. PD4ML applies some post-processing to Webkit PDFs, but some issues are still there. And one of the major issues: calls to a native binary do not comply with J2EE guidelines.

    So you’ve got a choice:

    PD4ML Std/Pro – for an automatic reporting, invoice, documentation generation etc. You only need to drop a couple of JAR files to your application shared lib/ dir and the functionality is instantly available.

    PD4ML Web for web site capture (probably for archiving purposes). In the case you would additionally need to install PhantomJS binary and to point to it from your application.

    #29699

    Hi,
    maybe one solution would be to search & replace dynamic params using case insensitive mode.

    The case insensitive mode could be activate using a special flag
    in PD4Constants : PD4ML_CASE_INSENSITIVE_DYNAMIC_PARAMS

    Thanks

    in reply to: Troubleshooting
    #27006

    I get the following error (Screenshot.png) when I use the following fonts.jar : (These outputs are normally not seen on console, they only come when you enableDebugInfo on PD4ML)

    1. Allfonts.jar provided by PD4ML (http://pd4ml.com/i/allfonts.zip)
    2. Fonts jar I created using dejavu fonts.
    3. Fonts jar offered by PD4ML (http://pd4ml.com/i/easyfonts/fonts.jar)

    There are also other similar threads from the forums but none of them have been convincingly answered.

    There are similar issues reported on forums but I cannot seem to find a resolution to this :

    pdf-generation-troubleshooting-f4/does-not-find-new-fonts-t206.html
    pdf-generation-troubleshooting-f4/ttf-issues-pro-eval-version-3-8-vs-3-7-t520.html
    pdf-generation-library-deployment-configuration-issues-f5/unix-fonts-deployment-t373.html
    html-css-to-pdf-rendering-issues-f3/custom-fonts-t81.html

    Can you please help resolve this issue?

    -Regards,
    Manooj

    in reply to: Troubleshooting
    #27007

    What Font file extensions does PD4ML support?

    In windows we have font files with extension ‘ttc’, ‘fon’, ‘TTF’, ‘CompositeFont’ etc.
    In linux we usually have only ‘ttf’ or ‘TTF’.
    There are also ‘otf’ – Open type fonts.

    So, it is not available anywhere what font file extensions does PD4ML use for the TTF configuration.

    Can you please provide some information?

    -Regards,
    Manooj

    in reply to: General questions / FAQ
    #27008

    Hi,
    I am using the command line to convert HTML to PDF on my macbook.
    I have a mirrored setup on an Ubuntu server, also Java installed.
    Conversions are okay, but some characters are not encoded and result in ??.

    The file mimetype both on the server and my local dev is: UTF-8 (file –mime-encoding merged_booklet.xhtml)

    A part of the file:<br /> <?xml version="1.0" encoding="UTF-8" standalone="no"?><br /> <!DOCTYPE html><br /> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops"><br /> <head><br /> <meta charset="utf-8" /><br /> <meta name="viewport" content="width=420,height=420" /><br /> <title>Jouw_schoonheid_[NETQ_demo_versie_23]-1</title><br /> <link href="http://project-beauty.local/wp-content/uploads/booklet/src/nl/pdf/0.1.16/src/OEBPS/css/idGeneratedStyles.css" rel="stylesheet" type="text/css" /><br /> </head><br /> <body id="Jouw_schoonheid_-NETQ_demo_versie_23--1" lang="en-US" xml:lang="en-US" style="width:420px;height:420px"><div class="page"><br /> <div class="page"><br /> <div id="_idContainer009" class="Basistekstkader"><br /> <div style="width:340.15px;height:340.15px;position:absolute;top:0.05px;left:0px;"><br /> <p class="Pag-4--colofon-top ParaOverride-1"><span id="_idTextSpan026" class="CharOverride-5" style="position:absolute;top:4.29px;left:0px;">© </span>

    The © character in the last span for example does not get converted properly on my ubuntu box. On the mac, the PDF looks fine.

    Where should I start to look, because I know ubuntu supports utf-8, so I try to force pd4ml.jar to run in utf-8 mode?

    Hope you can help me out.
    Very happy with PD4ml, works like a charm.

    in reply to: PD4ML encoding issue (works on mac, not on linux)
    #29711

    By the way I use TTF:
    $cmdline = “$java -Xmx512m -Djava.awt.headless=true -cp $jar Pd4Cmd “$url” 420 420×420 -debug -ttf $fontsdir -insets 0,0,0,0,mm -out $pdfname 2>&1″;
    and the TTF fonts are working fine.
    The fonts that I use are:

    #this is an autogenerated file. please remove manually any references to copyrighted fonts
    #Sun Dec 07 15:44:21 EST 2014
    AmerType Md BT Bold=AmerTypewriterITCbyBT-Bold.ttf
    AmerType Md BT=AmerTypewriterITCbyBT-Medium.ttf
    Helvetica=helr45w.ttf
    Helvetica Bold=helr65w.ttf
    Helvetica Bold Oblique=helr66w.ttf
    Helvetica Narrow=helr47w.ttf
    Helvetica Narrow Bold=helr67w.ttf
    Helvetica Narrow Bold Oblique=helr68w.ttf
    Helvetica Narrow Oblique=helr48w.ttf
    Helvetica Neue=HelveticaNeue_0.ttf
    Helvetica Neue Bold=HelveticaNeueBold_0.ttf
    Helvetica Neue Bold Italic=HelveticaNeueBoldItalic_0.ttf
    Helvetica Neue Condensed Black=HelveticaNeueCondensedBlack_0.ttf
    Helvetica Neue Italic=HelveticaNeueItalic_0.ttf
    Helvetica Neue Light=HelveticaNeueLight_0.ttf
    Helvetica Neue Light Italic=HelveticaNeueLightItalic_0.ttf
    Helvetica Neue UltraLight=HelveticaNeueUltraLight_0.ttf
    Helvetica Neue UltraLight Italic=HelveticaNeueUltraLightItalic_0.ttf
    Helvetica Oblique=helr46w.ttf
    Myriad Pro=MyriadPro-Regular.otf

    in reply to: PD4ML encoding issue (works on mac, not on linux)
    #29712

    Adding -encoding utf-8 to the java command line fixed it on Ubuntu.

    #29700

    The issue has been fixed in the development build.
    The fix is going to be available with the next maintenance release.

Viewing 15 posts - 2,821 through 2,835 (of 4,234 total)