This topic is locked
[SOLVED]

 Print page- PDF creation

2/25/2021 12:06:15 PM
PHPRunner General questions
G
gchowani author

Hi ALL,
I need to create PDF file from print page produced mainly using HTML code on Custom View or snippets.

All seems to be easy using PDF View but I do not find any control on margins, tables and its borders, loosing width:100% functions for tables, text positioning etc.

Modifying json file does not help as my print page contain lot of View as custom code in HTML and not included there.
Finally I gave up with PDF View (I hope temporary) as my print page looks perfect on the browser screen right now and lose completely quality while printing using PDF View.

Searching similar topics on forum or pdfmake did not help me much also. I tested almost all ideas comes to my mind or found.



Right now I am using browser print function / virtual PDF printer to gain data to PDF File (I hope temporary)
.

I use also browser add-ons like Print Edit WE to keep the "colours" of the text and HTML parts.

This solution is not best one but PDF file looks much better.
Would you be so helpful to advice

---how can I paste "page X from Y" on each PDF page footer using virtual PDF printer? (I can not use this browser function- as right now on first page there is only header and footer)

---have more control on page header/ footer position PLEASE?
Of course any ideas how to work with PDF View or use other then pdfmake are welcome as best solution.
Take care <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=28163&image=1&table=forumtopics' class='bbc_emoticon' alt=':)' />

mbintex 2/28/2021

Coming from 9.8 with DOMPDF converting nearly every HTML to PDF I had the same headaches with PDFmake.js in PHPRunner 10.
My learnings were:

  • Don´t do anything in HTML mode anymore in 10 - nothing of what you do there will ever make it to the PDF.
  • Really be careful with HTML in CodeSnippets, since most HTML won´t make to the PDF.
  • Better don´t use any HTML in custom view for Print pages, since it won´t make it to the PDF.
  • Your best and only chances are simple things like bold, italic and font color. There is a htmltopdfmake.js to handle these.
    Further more the PDF API and standard PDF buttons don´t provide any means so far for
  • borders
  • paper size

    and you have no influence on how the tables are formatted.
    For me the conclusion was, that all more complex PDF printouts will have to be done in plain programming instead of using the Designer. What makes it more complicated is, that your programming should not deliver HTML, but better the page description PDFMake.js expects natively.

    For more see here:

    https://pdfmake.github.io/docs/0.1/

    There is an online playround for testing.
    All the necessary code can be written via custom buttons and events, no real problem, but a lot of work and trial and error.
    Positive side of all this is, that after you have undergone all the learning, trying and crying you can create in PDF whatever you want, for example:
  • headers and footers on all pages
  • watermarks
  • security settings for pdf
  • qr codes
  • different table designs
  • multicolumn pages
  • control over pagebreaks

S
Steve Seymour 2/28/2021



Coming from 9.8 with DOMPDF converting nearly every HTML to PDF I had the same headaches with PDFmake.js in PHPRunner 10.
My learnings were:

  • Don´t do anything in HTML mode anymore in 10 - nothing of what you do there will ever make it to the PDF.
  • Really be careful with HTML in CodeSnippets, since most HTML won´t make to the PDF.
  • Better don´t use any HTML in custom view for Print pages, since it won´t make it to the PDF.
  • Your best and only chances are simple things like bold, italic and font color. There is a htmltopdfmake.js to handle these.
    Further more the PDF API and standard PDF buttons don´t provide any means so far for
  • borders
  • paper size

    and you have no influence on how the tables are formatted.
    For me the conclusion was, that all more complex PDF printouts will have to be done in plain programming instead of using the Designer. What makes it more complicated is, that your programming should not deliver HTML, but better the page description PDFMake.js expects natively.

    For more see here:

    https://pdfmake.github.io/docs/0.1/

    There is an online playround for testing.
    All the necessary code can be written via custom buttons and events, no real problem, but a lot of work and trial and error.
    Positive side of all this is, that after you have undergone all the learning, trying and crying you can create in PDF whatever you want, for example:
  • headers and footers on all pages
  • watermarks
  • security settings for pdf
  • qr codes
  • different table designs
  • multicolumn pages
  • control over pagebreaks

S
Steve Seymour 2/28/2021



Coming from 9.8 with DOMPDF converting nearly every HTML to PDF I had the same headaches with PDFmake.js in PHPRunner 10.
My learnings were:

  • Don´t do anything in HTML mode anymore in 10 - nothing of what you do there will ever make it to the PDF.
  • Really be careful with HTML in CodeSnippets, since most HTML won´t make to the PDF.
  • Better don´t use any HTML in custom view for Print pages, since it won´t make it to the PDF.
  • Your best and only chances are simple things like bold, italic and font color. There is a htmltopdfmake.js to handle these.
    Further more the PDF API and standard PDF buttons don´t provide any means so far for
  • borders
  • paper size

    and you have no influence on how the tables are formatted.
    For me the conclusion was, that all more complex PDF printouts will have to be done in plain programming instead of using the Designer. What makes it more complicated is, that your programming should not deliver HTML, but better the page description PDFMake.js expects natively.

    For more see here:

    https://pdfmake.github.io/docs/0.1/

    There is an online playround for testing.
    All the necessary code can be written via custom buttons and events, no real problem, but a lot of work and trial and error.
    Positive side of all this is, that after you have undergone all the learning, trying and crying you can create in PDF whatever you want, for example:
  • headers and footers on all pages
  • watermarks
  • security settings for pdf
  • qr codes
  • different table designs
  • multicolumn pages
  • control over pagebreaks


All my PHPRunner PDF output is done with FPDF and FPDI and custom php scripts called from a custom button, this way you can print anything exactly where you want with sub millimeter accuracy.

http://www.fpdf.org/

mbintex 2/28/2021

I tried using DOMPDF, but in the end I decided to go the way with PDFmake. It is built in and I don´t think that it is a good idea to have two PDF Engines in one solution. With all simple lists and reports and viewpage PDFs the builtin PDF realization is OK for me.

Admin 3/2/2021

I just wanted to say that the switch from DOMPDF to PDFMake was mostly a success, it works much faster and produces better results out of the box and 90% of customers are happy with that. Unfortunately, neither will produce pixel-perfect PDF output.
So, everyone is correct, the solution for reliable and precise PDF output is a hand-written solution based on FPDF or PDFMake. In some situations, PDFForms template can help as well, especially when you are to export a single page like View.

G
gchowani author 3/6/2021

THANK you Mbintex!

THANK you Halcyondaze!

THANK you Corrie!
Thank you for sharing your thought, experience and advice!

I do not have experience with DOMPDF, the only I can say about is experience with PDFMake.

It really work fast and it is a good choice for simple documents. Maybe in future it will be more adjustable.

For now I will try to experiment based on your advice. THANK you!!
Take care Guys <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=94006&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />