Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #33972

    Hello,

    I need to inject some html code into my custom tag content, see example below:
    <sidebar style="display: block;box-sizing: border-box;padding: 10px 20px;background-color: #ededed;"> Hi! </sidebar>

    Should become (extra tag <section> should be added right after the sidebar):
    `<sidebar>
    <section style=”display: block;box-sizing: border-box;padding: 10px 20px;background-color: #ededed;”>
    Hi!
    </section>
    </sidebar>’
    I see there is CustomTag class in PD4ML that seems to allow to customize tag processing, however I cannot understand how to use it. Documentation contains sample of <star> tag which paints a star in a PDF, but that’s far away of real life necessity, I think in most cases there is a need to customize rendering of content of the tag. Also I was not able to find any detailed documentation about CustomTag class apart of this sample with ‘<star>’ and javadocs with no description.
    Probably, someone in community or PD4ML team could help me with this.

    So, I’ve created custom SidebarTag, and in getInstance method I’m trying to replace ‘code’ parameter with another value (for example, as specified above):

    @Override
    public CustomTag getInstance(String code, FontCache fontCache) {
    code = “<sidebar><section style=\”display: block;box-sizing: border-box;padding: 10px 20px;background-color: #ededed;\”>Hi!</section></sidebar>”;
    return new SidebarTag(code, fontCache, this);
    }

    I do that before call to constructor, so I assumed that this replacement would affect the whole further processing, however, when setElement method is invoked, element param contains original html code.
    Another point where I theoretically could customize tag processing is ‘paint()’ method, however it wants to paint using graphics api, while I need this code just to be rendered.

    Could you please help me to understand how can I do that? It seems to me that the answer lies on the surface as this is pretty trivial use case, however I cannot solve it.

    #33973

    Hi! We added the custom tags support to make possible a definition of features, not achievable with the standard HTML approach, for example a support of SVG vector graphics or MathML. It you need a simple content or HTML markup injection, the custom tags seem to be an overkill.

    First, do not forget that the input of PD4ML is HTML. You may always pre-process it as a text before it is passed to readHTML(). Let’s say, define your proprietary placeholders in HTML and substitute them with actual data before PD4ML takes part. In the case “the actual data” can be either content string or HTML markup.

    In the case you need to insert only text content, you may use PD4ML’s template mechanism. Define in your HTML placeholders in the format: $[var] ($[page], $[total] and $[title] are reserved) and substitute them with the API call:

    https://pd4ml.tech/javadoc/com/pd4ml/PD4ML.html#setDynamicData-java.util.Map-

    The advantage of the method is that you do not need to pre-read HTML to a buffer (if it is read-only or comes from HTTP) to pre-process. Disadvantage: you cannot pass HTML markup via the templating mechanism.

    There is also injectHtml() API call, but it allows to inject HTML portion either immediately after opening <body> or jus before the closing BODY tag.

    Or do you have a very special usage scenario, the above does not help?

    #33974

    Thanks for your reply.
    Unfortunately, I cannot modify original html.
    The initial problem is that sidebar tag is not rendered properly with PD4ML 4.0.9 (yes, I know this is not supported tag, but it worked properly with 3.x version). Section with styles applied are displayed separately from the text inside it (see pdf file attached: text “Hi from sidebar (no styling)” should be inside grey block).
    I’ve reported issue about that, but didn’t get a reply yet. Should I provide more details on this issue here?

    So, I was looking for a workaround, and the idea was to modify <sidebar>’s internals “on fly”.

    Attachments:
    You must be logged in to view attached files.
    #33976

    I’ve just replied to the Helpdesk ticket – from it was finally clear what kind of issue you faced with.

    As I see, the SIDEBAR tag implicitly closes and does not allow any nested content/markup, which is wrong.
    It looks like a regression in PD4ML defaults. A fix will be available with the next snapshot build.

    #33977

    Thank you!
    But I still didn’t receive an email regarding sidebar issue that I reported (spam folder is empty as well).
    Could you please let me know where can our team track the state of the issue? Maybe there is any tracking system available for clients?
    Also, when snapshot build is planned to be released?

    #33984

    Hello. Are there any updates on my question?

    #33985

    Hi! Unfortunately we do not provide a direct customer access to the issue tracking system. I am wondering why you do not receive our Helpdesk replies. Your gmail address looks correct.

    Well, we expect the custom tag issue fix will be available tomorrow morning with the nightly 4.0.9fx2 snapshot build.

    #33986

    Well, we expect the custom tag issue fix will be available tomorrow morning with the nightly 4.0.9fx2 snapshot build.

    Thank you! Will check tomorrow.

    I am wondering why you do not receive our Helpdesk replies. Your gmail address looks correct.

    That’s really strange. I receive notifications from forum (sender is <sales@pd4ml.com>), but not from support. Is sender email for support different?
    I’m going to submit another issue report, so don’t want to miss notifications…

    #33987

    Hello,

    For basic case (sidebar tag only) the issue is solved.
    However, for more complex structure it is still not working, please see sample structure:
    <section> <sidebar style="display: block;box-sizing: border-box;padding: 10px 20px;background-color: #ededed;"> <section> <h2>Header</h2> <section>Section section</section> <section>Section section 2</section> </section> </sidebar> </section>

    Could you please take a look? Should I report another issue for that (I’ll try to register another account for different email)?
    Thanks in advance.

    Attachments:
    You must be logged in to view attached files.
    #33989

    I am not sure if a nesting of section tags is semantically correct: usually a document divided to sections, sections to articles. However from technical perspective a section should be just as a regular div has no restrictions for a nesting. (And now the section tag is treated rather as a paragraph, which is not correct)

    We’ll align the issue asap.

    BTW: do you still receive no Helpdesk notifications? Yesterday it looked like we fixed a configuration issue.

    #33990

    I am not sure if a nesting of section tags is semantically correct: usually a document divided to sections, sections to articles. However from technical perspective a section should be just as a regular div has no restrictions for a nesting. (And now the section tag is treated rather as a paragraph, which is not correct)

    Understand, but this is a content we receive from a client, and I’m afraid we cannot influence it anyhow.

    We’ll align the issue asap.

    Thank you!

    BTW: do you still receive no Helpdesk notifications? Yesterday it looked like we fixed a configuration issue.

    Yes, I received a notification today, thanks!

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.