I am converting xml to pdf via php. I am using fpdf.
I need to replace the string "PageBreak" with the code in fpdf to add a new page .. ie. AddPage().
So, I used this:
But instead of replacing the string "PageBreak" with the code AddPage(), it adds the code AddPage() before each string - including the ones that do not have PageBreak anywhere in them.
In comparison, this code works perfectly fine to replace this string "Page##of####" with with the appropriate fpdf code for declaring the page number and number of pages so it prints out like "Page 1 of 50"...
I have no idea why this isn't working and I'm super frustrated. I could really use some help!
Anyone know what I'm doing wrong? Thanks in advance for any/all help!
I need to replace the string "PageBreak" with the code in fpdf to add a new page .. ie. AddPage().
So, I used this:
Code:
$strText = preg_replace("/PageBreak/",$this->AddPage(),$strText);
But instead of replacing the string "PageBreak" with the code AddPage(), it adds the code AddPage() before each string - including the ones that do not have PageBreak anywhere in them.
In comparison, this code works perfectly fine to replace this string "Page##of####" with with the appropriate fpdf code for declaring the page number and number of pages so it prints out like "Page 1 of 50"...
Code:
$strText = preg_replace("/([^#]|^)##([^#]|$)/", "\\01" . $this->PageNo() . "\\02", $strText);
$strText = preg_replace("/([^#]|^)####([^#]|$)/", "\\01" . "{nb}" . "\\02", $strText);
I have no idea why this isn't working and I'm super frustrated. I could really use some help!
Anyone know what I'm doing wrong? Thanks in advance for any/all help!