jsreport / jsreport-pdf-utils

jsreport extension providing pdf operations like merge or concatenation
MIT License
8 stars 4 forks source link

PDF form elements (pdfFormField) #27

Closed mohamadserawan closed 4 years ago

mohamadserawan commented 4 years ago

I am trying to render the following template:

<html>
<head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body>
    {{{pdfFormField name='test' type='signature' width='100px' height='50px'}}}
    <div>
        <label>Name</label>
        {{{pdfFormField name='name' type='text' width='130px' height='40px'}}}
    </div>
    <div>
        <label>Surname</label>
        {{{pdfFormField name='surname' type='text' width='130px' height='40px'}}}
    </div>
</body>
</html>

And I got the excpeted pdf image

But when I am trying to add any Turkish character (Şş Çç Ğğ Üü Öö İi Iı) like:

<!DOCTYPE html>
<html>
<head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body>
    <div>
        Şş Çç Ğğ Üü Öö İi Iı
    </div>
    {{{pdfFormField name='test' type='signature' width='100px' height='50px'}}}
    <div>
        <label>Name</label>
        {{{pdfFormField name='name' type='text' width='130px' height='40px'}}}
    </div>
    <div>
        <label>Surname</label>
        {{{pdfFormField name='surname' type='text' width='130px' height='40px'}}}
    </div>
</body>
</html>

I am gotting the following: image

As you see the pdf is corrupted and if you zoom in you can find the following strings in the file fo rm@@ o rm@@ fo rm@@

By the way this problem is only when I place the Turkish characters befor pdfFormField elements, I mean that if you try to change the position of the first div and put it at the end of the file, the generated pdf will be as expected without any rendering problem.

Template properties: engine: handlebars recipe: chrome-pdf (i tried to use phantom-pdf but it has the same problem)

Jsreport version: 2.10.0 jsreport-pdf-utils version: 1.9.0

pofider commented 4 years ago

Thank you for the bug report. I pushed the fix. Please try the report from the master

npm i jsreport/jsreport-pdf-utils
mohamadserawan commented 4 years ago

You are great :)

mohamadserawan commented 4 years ago

Hi again, I have a problem in positioning of pdfFormField elements when I am trying to add margin top and bottom to template.

error
pofider commented 4 years ago

Yes, I see the same. Thank you. I am looking into it.

pofider commented 4 years ago

please update the extension from git master again, and let me know if it fixes the problem, thank you.

mohamadserawan commented 4 years ago

test.pdf

it is working ok for one page documents but unfortunately elements has been disappeared for multiple pages documents.

<!DOCTYPE html>
<html>
<head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body>
    page 1
    <div style="page-break-after: always;"></div>
    page 2
    <div>
        Şş Çç Ğğ Üü Öö İi Iı
    </div>
    {{{pdfFormField name='test' type='signature' width='100px' height='50px'}}}
    <div>
        <label>Name</label>
        {{{pdfFormField name='name' type='text' width='130px' height='40px'}}}
    </div>
    <div>
        <label>Surname</label>
        {{{pdfFormField name='surname' type='text' width='130px' height='40px'}}}
    </div>
</body>
</html>
pofider commented 4 years ago

Thank you for your example. Please update the dep from git and give it another try.

mohamadserawan commented 4 years ago

Thanks for quick reply, there was no problem in positioning unless I have tried to enable "display header/footer" checkbox from chrome-pdf option panel.

image

pofider commented 4 years ago

I see, thanks. Never-ending story here. It should be fixed now, please update again.

mohamadserawan commented 4 years ago

Thank you very much, now i can die in peace :)

shubhamsWEB commented 3 years ago

I am trying to render pdfFormField in multipage PDF but formField elements has been disappeared for multiple pages in the generated PDF. And this is happening randomly if i'm generating another PDF then some other formField elements are disappeared. HELP!! @pofider

pofider commented 3 years ago

@shubhamsWEB Do you have the latest pdf utils? If yes, please create a separate bug report and include a minimal example replicating the problem.

shubhamsWEB commented 3 years ago

@pofider Thanks for quick response, it is working now, I was only using jsreport-phantom-pdf. 😅