/    Sign up×
Community /Pin to ProfileBookmark

fpdf new line object problem

basically when i enter a string into the WriteHTML(“blahnblah n blah”) all the breaks appear in the pdf fine but when i use a string or object it just prints the nr in the document. I’m guessing this has something to do with single and double quotes or some form of slashes being passed which aren’t being shown :S any help would be greatly appreciated.

[code=php]function LoadQuote($quote_number, $client_name, $job_name, $job_breakdown)
{
$this->quote_id = $quote_number;
$this->client_name = $client_name;
$this->job_name = $job_name;
$this->job_breakdown = $job_breakdown;
}

function NewPage()
{
//Instanciation of inherited class
$this->AddPage();
$this->SetLeftMargin(24);
$this->SetFont(‘Arial’,”,10);
$this->WriteHTML($this->job_breakdown);
$this->SetLeftMargin(10);
$this->Run();
}[/code]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@knowjauthorAug 07.2007 — This is the write function which is called by the WriteHTML() Around line 18 you can see where the content is walked through and the n found but for some reason the script isn't recognizing the n when the text is passed via an object or variable. But it is processing it if the text is entered into the WriteHTML() or Write() functions within quotes ""

Help/Suggestions will be greatly appreciated i am at a stand still here and out of ideas
[code=php]
function Write($h,$txt,$link='')
{
//Output text in flowing mode
$cw=&$this->CurrentFont['cw'];
$w=$this->w-$this->rMargin-$this->x;
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
$s=str_replace("r",'',$txt);
$nb=strlen($s);
$sep=-1;
$i=0;
$j=0;
$l=0;
$nl=1;
while($i<$nb)
{
//Get next character
$c=$s{$i};
if($c=="n")
{
//Explicit line break
$this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
$i++;
$sep=-1;
$j=$i;
$l=0;
if($nl==1)
{
$this->x=$this->lMargin;
$w=$this->w-$this->rMargin-$this->x;
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
}
$nl++;
continue;
}
if($c==' ')
$sep=$i;
$l+=$cw[$c];
if($l>$wmax)
{
//Automatic line break
if($sep==-1)
{
if($this->x>$this->lMargin)
{
//Move to next line
$this->x=$this->lMargin;
$this->y+=$h;
$w=$this->w-$this->rMargin-$this->x;
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
$i++;
$nl++;
continue;
}
if($i==$j)
$i++;
$this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
}
else
{
$this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link);
$i=$sep+1;
}
$sep=-1;
$j=$i;
$l=0;
if($nl==1)
{
$this->x=$this->lMargin;
$w=$this->w-$this->rMargin-$this->x;
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
}
$nl++;
}
else
$i++;
}
//Last chunk
if($i!=$j)
$this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link);
}

[/code]
Copy linkTweet thisAlerts:
@knowjauthorAug 07.2007 — After more testing it doesn't seem to be the objects/variables which are the problem.

It seems to be something with parring the data from a <textarea> via a $_POST is something done to the data in $_POST vars which could cause this problem?

I have turned magic quotes off
Copy linkTweet thisAlerts:
@knowjauthorAug 07.2007 — Problem solved.

I had my anti sql injection function running on the object which was being entered into the PDF
×

Success!

Help @knowj spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...