Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

writeText does not recognize new line character when passing text from database #50

Open
GoogleCodeExporter opened this issue Mar 17, 2015 · 11 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Pass text from database and store in a local String variable
2. Assign that string variable to writeText(5,newVar)
3.

What is the expected output? What do you see instead?
New line where /n is used.

What version of the product are you using? On what operating system?
0.1.4.3

Please provide any additional information below.


Original issue reported on code.google.com by peterson...@gmail.com on 17 Jun 2008 at 12:04

@GoogleCodeExporter
Copy link
Author

Hi,

AlivePDF recognizes \n instead of /n.
If you really want to use /n, you can use a little regexp to replace each /n 
with a \n.

let me know ;)

kind regards,

Thibault

Original comment by thibault.imbert on 17 Jun 2008 at 12:40

@GoogleCodeExporter
Copy link
Author

Hi,

That was a typo...I am using \n.  Currently I store text in an Oracle database 
and 
read it in using Flex's RPC.  When it's read in from the database, ALIVEPDF 
does not 
recognize \n.  Though, if I hard code text in the writeText() method it works.

Thanks for your help.

Original comment by peterson...@gmail.com on 17 Jun 2008 at 6:33

@GoogleCodeExporter
Copy link
Author

Humm interesting, do you receive the data as XML data ? pure text ? AMF packets 
?

let me know ;)

Thibault

Original comment by thibault.imbert on 17 Jun 2008 at 6:51

@GoogleCodeExporter
Copy link
Author

I receive it as pure text.

Original comment by peterson...@gmail.com on 17 Jun 2008 at 10:34

@GoogleCodeExporter
Copy link
Author

Hello.

I receive the data as XML and have the same problem...
Any changes on this?

Thanks in advance,
Jácome

Original comment by jacomemi...@gmail.com on 4 Dec 2009 at 1:48

@GoogleCodeExporter
Copy link
Author

Hi,

I have the same problem...

Hard coding works fine, but when dynamic data is used it falls over.

Is there any fix for this problems?

Original comment by sde...@gmail.com on 16 Mar 2010 at 3:59

@GoogleCodeExporter
Copy link
Author

any solution to the problem with dynamic text from database, please communicate

Original comment by vipulsha...@gmail.com on 29 Apr 2010 at 9:48

@GoogleCodeExporter
Copy link
Author

Im not that good at programing as a whole.. how do i use regular expressions to 
find and replace "/n"? 
i found alot of info on regex in general but not for finding and replacing non 
print chars

Original comment by isy.ph...@gmail.com on 15 Dec 2010 at 2:29

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

I had the same problem writing to a SQL Server database from a Flash multiline 
textbox and then trying to use the writeText() function in AlivePDF. The answer 
is simple once you realise what is going on with the data. Flash sends a new 
line to the database as an ascii char(13) character, which is a carriage 
return. AlivePDF is looking for a char(13) + char(10) (carriage return + 
linefeed). So to fix this problem you'll have to add a function in your 
actionscript file to convert the flash char(13) to either a char(13) + char(10) 
or just use the "\n". I've pasted in the function that I use:
private function convertString(_value:String):String
{
 var returnString:String = "";
 var _chr:String = String.fromCharCode(13);
 var tempArray:Array = _value.split(_chr);
 for(var i:uint = 0; i < tempArray.length; i++)
  {
   returnString += tempArray[i] + "\n";
  }         
  return returnString;
}
Then just call this function from your main program:
myPdf.writeText(2, convertString(textFromDatabase);

John

Original comment by johng...@gmail.com on 16 Jan 2011 at 6:51

@GoogleCodeExporter
Copy link
Author

Brilliant John! Thanks for that! I was goofing around for quite a while 
replacing different characters without getting it right. How did you figure out 
what was saved in the database and what alive pdf was expecting? Loop over the 
string and somehow printing the ascii representation of each character?

Here is another version of your convertString function, using a regular 
expression rather than splitting the string and looping the array.

private function convertString(value:String):String
{
    return value.replace(/\r/g, "\n"));
}

Lars

Original comment by lars.ost...@gmail.com on 5 Jun 2011 at 9:50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant