PrestaShop Forum

The best place in the world to ask questions about PrestaShop and get advice from our passionate community!

PrestaShop Forum

Jump to content

[SOLVED] Multiple pages invoices PDF error

33 replies to this topic
#1
Infordesign

    PrestaShop Newbie

  • Members
  • Pip
  • 24 posts
Hello all,

I realized that this is not the best section for this post. It should be on "General discussion" section because is not related to any Module but to a main Class (sorry about that).

As I've reported in bug-tracker (http://www.prestasho...cker/view/1275/), all multipages invoices gets misformated after the first page. I've made some changes on the original "/classes/PDF.php" file to correct the bug.

As I said on bug-tracker, this bug is not completely corrected, but is closer than before.

Attached to this post is a PDF.php file with all the changes stated above. There's also a PDF of a sample document made with the original PDF.php file (000005.pdf) and the same document made with the corrected PDF.php file (000005-corrected.pdf).

--- EDITED [26-01-2008]
I've made some changes to the "PDF.php" file since the first post. The attached "PDF.php" is the new version (finished today). It now displays correctly invoices, slips, deliveries, and so.
---

--- EDITED [27-01-2008] (first update)
I've made some changes to display correctly the page numbers of multiple invoices.
Now I just find an uncorrected bug: when printing multiple invoices, the "€" (euro sign) is not correctly shown.
---

--- EDITED [27-01-2008] (second update)
I've corrected the "€" (euro sign) bug when printing multiple invoices. I guess now this "PDF.php" is bug-free (but still testing). If you find any bug please tell me.
---

Attached Files


I N F O R D E S I G N ®

Infordesign - Unipessoal, Lda.
WEB: www.infordesign.com | MAIL: mail [at] infordesign [dot] com

#2
Matthieu Biart

    PrestaShop Fanatic

  • Members
  • PipPipPipPip
  • 1166 posts
Hi Infordesign!

Well, congratulation!
The corrected file looks really great.

We'll fix that bug from your contribution, and for such issues (PDF) help is really appreciated (because PDF in one of the PS part which needs the most time to be fixed).
Thank you very much :coolsmirk:
Matthieu BiartCore developer | Développeur coeurPrestaShop
Help PrestaShop, make a donation! • Aidez la communauté, soumettez vos rapports de bug uniquement en anglais

#3
Infordesign

    PrestaShop Newbie

  • Members
  • Pip
  • 24 posts
You're welcome Matthieu!

I'm glad I can contribute to (and use) this great project!
At this time I'm fixing some other bugs (on other modules) that I'll submit when they're finished and tested.

Congratulations to this project!
I N F O R D E S I G N ®

Infordesign - Unipessoal, Lda.
WEB: www.infordesign.com | MAIL: mail [at] infordesign [dot] com

#4
Philippe Sang

    PrestaShop Fanatic

  • Members
  • PipPipPipPip
  • 2136 posts
Hi,

I wanted to add your contribution to solution, but so many errors :

Strict Standards: Declaration of PDF_PageGroup::_beginpage() should be compatible with that of FPDF::_beginpage() in D:\BU Open-Source\version_1\trunk\classes\PDF.php on line 17

Warning: Missing argument 2 for FPDF::_beginpage(), called in D:\BU Open-Source\version_1\trunk\classes\PDF.php on line 43 and defined in D:\BU Open-Source\version_1\trunk\tools\fpdf\fpdf.php on line 1093

Notice: Undefined variable: format in D:\BU Open-Source\version_1\trunk\tools\fpdf\fpdf.php on line 1106

Notice: Undefined index: product_quantity_cancelled in D:\BU Open-Source\version_1\trunk\classes\PDF.php on line 580
FPDF error: Some data has already been output, can't send PDF file

Philippe SangOpen-Source Developper | Développeur Open-Source
Help PrestaShop, make a donation !

#5
Infordesign

    PrestaShop Newbie

  • Members
  • Pip
  • 24 posts
It worked on my Prestashop installation without any error...
What is the version you tried? Latest SVN? Installed on Apache (windows) or IIS? I would like to reproduce the error.
Thank you.
I N F O R D E S I G N ®

Infordesign - Unipessoal, Lda.
WEB: www.infordesign.com | MAIL: mail [at] infordesign [dot] com

#6
Philippe Sang

    PrestaShop Fanatic

  • Members
  • PipPipPipPip
  • 2136 posts
Because your are working without all PHP errors (notice, strict standards, etc).
Philippe SangOpen-Source Developper | Développeur Open-Source
Help PrestaShop, make a donation !

#7
Philippe Sang

    PrestaShop Fanatic

  • Members
  • PipPipPipPip
  • 2136 posts
PHP.ini :


; All, all, all
error_reporting = E_ALL | E_STRICT

Philippe SangOpen-Source Developper | Développeur Open-Source
Help PrestaShop, make a donation !

#8
Infordesign

    PrestaShop Newbie

  • Members
  • Pip
  • 24 posts
I'll install a clean prestashop version on a development server, make the changes stated on this post and I'll check it (and correct the errors if needed).
I N F O R D E S I G N ®

Infordesign - Unipessoal, Lda.
WEB: www.infordesign.com | MAIL: mail [at] infordesign [dot] com

#9
Infordesign

    PrestaShop Newbie

  • Members
  • Pip
  • 24 posts
I've installed PrestaShop Version 1.2 Alpha 1 (by the way, installer is not working on Safari and Firefox, only works on Opera - on Apple MacBook. It stops at database server configuration.)

Changed pdf.php for the file posted here and there's an error because one argument is missing (I don't know if it worked with the older fpdf version or if I forgot to include it). If you make this change, everything work ok:


function _beginpage($orientation, $arg2)
{
parent::_beginpage($orientation, $arg2);


Codepage must be "UTF-8, no BOM" too.

PDF is well generated with page numbers working correctly.
I N F O R D E S I G N ®

Infordesign - Unipessoal, Lda.
WEB: www.infordesign.com | MAIL: mail [at] infordesign [dot] com

#10
Philippe Sang

    PrestaShop Fanatic

  • Members
  • PipPipPipPip
  • 2136 posts
Still theses errors :

Strict Standards: Declaration of PDF_PageGroup::_beginpage() should be compatible with that of FPDF::_beginpage() in D:\BU Open-Source\version_1\trunk\classes\PDF.php on line 17

Notice: Undefined variable: arg2 in D:\BU Open-Source\version_1\trunk\classes\PDF.php on line 43

Notice: Undefined index: product_quantity_cancelled in D:\BU Open-Source\version_1\trunk\classes\PDF.php on line 580
FPDF error: Some data has already been output, can't send PDF file


Please active ALL php errors as I show you.

By the way, installer is working fine here on FF3.
Philippe SangOpen-Source Developper | Développeur Open-Source
Help PrestaShop, make a donation !

#11
Infordesign

    PrestaShop Newbie

  • Members
  • Pip
  • 24 posts
I have Firefox 3.0.9 and didn't work here.

During installation process all tests were passed, but after setting database login data and configured SMTP server (and both database connection test and test mail message worked correctly), I've pressed "Next" and nothing happened. Just a progress bar is shown at the top of installation page, then disappeared and the installation script didn't open the next page.

This happened both in Safari 3.2.1 and Firefox 3.0.9. Only worked ok on Opera 9.64.
I N F O R D E S I G N ®

Infordesign - Unipessoal, Lda.
WEB: www.infordesign.com | MAIL: mail [at] infordesign [dot] com

#12
Infordesign

    PrestaShop Newbie

  • Members
  • Pip
  • 24 posts
I've updated pdf.php for the latest version (1.2 Alpha 1).
You got those errors because the first pdf.php posted here was for a previous version of PrestaShop. I've applied all the changes that I made to support multiple pages on the latest file available (and included even error_reporting(6143); to be sure all errors and warnings of this pages are shown) and everything works ok.

Try the latest file (pdf.php) to see if you still get any errors.
I N F O R D E S I G N ®

Infordesign - Unipessoal, Lda.
WEB: www.infordesign.com | MAIL: mail [at] infordesign [dot] com

#13
Infordesign

    PrestaShop Newbie

  • Members
  • Pip
  • 24 posts
I've updated the file again because the one I've posted had lines to repeat invoice lines so I can had multilines invoices (just for debugging).
Now the PDF.php file on the first post is the latest one (and works nice).

Check it to see if you get any error, because here everything is ok.
I N F O R D E S I G N ®

Infordesign - Unipessoal, Lda.
WEB: www.infordesign.com | MAIL: mail [at] infordesign [dot] com

#14
Philippe Sang

    PrestaShop Fanatic

  • Members
  • PipPipPipPip
  • 2136 posts
Nice work, I have included it to SVN and it'll be available for next release :)

Thanks from PrestaShop team.
Philippe SangOpen-Source Developper | Développeur Open-Source
Help PrestaShop, make a donation !

#15
VIXUS

    PrestaShop Addict

  • Members
  • PipPipPip
  • 583 posts
I have version 1.1 and this PDF fix is not?

Anyone have older version of this fix that is compatibile with Presta 1.1?

tnx!

#16
Infordesign

    PrestaShop Newbie

  • Members
  • Pip
  • 24 posts
Philippe Sang:
I'm glad I can help on PrestaShop development! ;-)

DJ-Terror:
The PDF.php posted here works with latest version (1.2 Alpha 1), and probably don't work with 1.1 because some code have changed between the two versions. The most safe way to apply the correction to an older version is to apply (by hand) the corrections on your current PDF.php file.

On the file posted here all needed changes are highlighted by the starting comment line "[INI] INFORDESIGN" and the ending comment line "[END] INFORDESIGN". If you compare the PDF.php file with your current PDF.php file it's pretty easy to see where to apply the code lines. You can even apply one code block at a time to see if you get any error or warning.

Good luck! :-)
I N F O R D E S I G N ®

Infordesign - Unipessoal, Lda.
WEB: www.infordesign.com | MAIL: mail [at] infordesign [dot] com

#17
botc

    PrestaShop Apprentice

  • Members
  • PipPip
  • 27 posts
Does this also fix the "FPDF error: Some data has already been output, can't send PDF file" bug?

#18
Infordesign

    PrestaShop Newbie

  • Members
  • Pip
  • 24 posts
Hello botc,

That error usually happens when you save your file as utf-8 (with bom). You have to save the file as "utf-8, no bom", because some servers (usually IIS) give the error you said when the file is not in that format.

Good luck!
I N F O R D E S I G N ®

Infordesign - Unipessoal, Lda.
WEB: www.infordesign.com | MAIL: mail [at] infordesign [dot] com

#19
botc

    PrestaShop Apprentice

  • Members
  • PipPip
  • 27 posts
Where do I find this bom thing? In the BO or in some file?
Has it anything to do with the encoding in the BO - iso and cp1250 stuff?

Thanks for help - it's my last bug before going live :)

#20
Infordesign

    PrestaShop Newbie

  • Members
  • Pip
  • 24 posts
Hello again,

You can find more info at: http://en.wikipedia....Byte-order_mark
In your text (code) editor, you can choose encoding type, and choose the option to save the source file without the BOM. Some webservers don't support BOM and print unwanted chars on the output file, so you get that error you told.

If your webserver interprets your utf-8 file (with BOM) as iso-8859-1, it'll output this "" at the begining of the file and you get that error.

Do you get any PHP error or warning? If you do, that error/warning can be causing that error too.

Good luck with your new shop! ;-)
I N F O R D E S I G N ®

Infordesign - Unipessoal, Lda.
WEB: www.infordesign.com | MAIL: mail [at] infordesign [dot] com