These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Text Field values, I have visuals

cyanstudios
Registered: May 6 2008
Posts: 81

I've posted a number of times on this question but haven't gotten a response, so this time I bring visuals. Please help me if you have any light to shed on the subject.

Here is the form that I'm working on:
http://www.cyan-studios.net/downloads/outputtest.pdf

If you click on the "Straight Joint" or "Transition" button, you'll see the behavior of the form that I'm after. If you enter dimensional/product data in per piece, then scroll to the bottom, you'll see the code that I'm causing the form to generate.
Update the data and the code updates.

In the end, I want all of that code at the end, with the line breaks and all, to be easily outputted to a text file.

Can this be done?

scottsheck
Registered: May 3 2007
Posts: 138
I get an error when i click on the PDF. But i did get to see the PDF. If the user is using Adobe reader to run the PDF, then you can't write to the computers hard drive, but you can submit the results. The results however would include data from all pages, unless you added some code to hide the other pages before submitting. hard to see how you want the text outputted since it all seems very jumbled.
cyanstudios
Registered: May 6 2008
Posts: 81
Yes, the error is something I need to get to later. It's basically caused by the form attempting a calculation on an Instance that isn't present until the fitting button is clicked.

Anyway, as to the "jumbled text". It looks jumbled to you, but that's the code that I want. If you click a new "Straight Joint", more code is added that block of text down below.

As weird as all that text may look to you, it is controlled and it is what is desired.

I'm thinking what seems most probable is a button that copies just the contents of that one field, pulls up notepad, and pastes it. The end user can save the file.

Is that any more realistic?

Thank you for the response. It's nice to get feedback.
scottsheck
Registered: May 3 2007
Posts: 138
Will the person using the PDF be using Adobe Reader to Adobe Acrobat? With Reader, you won't be able to do what you want. As for Acrobat, you might be able to write a script (using version 8). But within PDF, your script won't be able to access the clipboard.

'Submit' the data via email is one option if you want to use script within your PDF. Or you could bind your output text field to a database field or XML file.

I mentioned the jumbled text and error to maybe help you to possibly get more feedback.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
You should clear up all errors as they occur because JavaScript tends to abort at the first error encountered. You can use JavaScript's "try{...} catch() {...}" statement to trap the error and continue.

George Kaiser

cyanstudios
Registered: May 6 2008
Posts: 81
The error was being caused because the wall of text field was trying to find a field that was hidden on load. I have now set it up so that there is a button which will create the text [b]after[/b] the fittings are defined. If you scroll down the page you'll see two buttons, one "Regenerate Code" and "Wipe Code".
http://www.cyan-studios.net/downloads/outputtest.pdf

Thank you for that tip gkaiseril. While I have you here, I saw this topic:
http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=1308
And I'm curious to know if an approach like this, applied to my field with all of this "code" would do the trick.

Our fabrication shop just needs to be able to receive a .txt file with this text as it is in the text field. Be that extraction or email.

scottsheck wrote:
Will the person using the PDF be using Adobe Reader to Adobe Acrobat? With Reader, you won't be able to do what you want. As for Acrobat, you might be able to write a script (using version 8). But within PDF, your script won't be able to access the clipboard.'Submit' the data via email is one option if you want to use script within your PDF. Or you could bind your output text field to a database field or XML file.

I mentioned the jumbled text and error to maybe help you to possibly get more feedback.
The people using the form will probably only have Reader. I'm only two weeks into using LiveCycle and about four into JavaScript, so your 'Submit' idea or binding method sound great, I'm just not certain how to go about this. I've managed to email an XML file, but that comes complete with a lot of markup and in the wrong format.

Like I told gkaiseril, all I need is for our fabrication shop to receive this textfield as a txt file, with [b]just[/b] that text and the carriage returns. If I can have it email it, that would be beautiful, or if they could just extract it.

They're not going to be too keen on the notion of copying, opening notepad, pasting, then saving. They like it dumbed down sevenfold.
scottsheck
Registered: May 3 2007
Posts: 138
I know you would like it that simple, but I pretty much doubt you can write out to a text file because of security. That is interesting code you found though, but I don't recognize that capability so if you ever get that working of if Gkaiseril knows how that works, I'd be interested, but I kind of doubt it would write out a text file.
cyanstudios
Registered: May 6 2008
Posts: 81
Hey Scott,
Once again, thank you very much for your interest. You'll probably be pleased to know that I've turned to an HTTP submit and will most likely do this using PHP. I followed a tutorial and I've created a file in the same directory as this PDF called dump.php. Here's the code inside of it at the moment.

<HTML><HEAD><TITLE>HTTP Request Dump</TITLE></HEAD><BODY><h1>HTTP Request Dump</h1>This page sends back to you what your browser or other user-agent submitted to this page. <h2>HTTP Headers</h2><pre><?PHPDumpArray("HEADERS", emu_getallheaders());?></pre> <h2>Submitted Variables (as parsed by PHP)</h2><pre><?PHPecho $content_type;DumpArray("REQUEST",$_REQUEST);?></pre> <h2>Raw POST Body</h2> <pre><?PHP$body = file_get_contents("php://input");echo strlen($body);echo " bytes: <br>";?><span style="background-color: #e0e0f0"><?PHPwhile (strlen($body)>60) {echo substr($body, 0, 60);echo "\n";$body = substr($body, 60);}echo $body;?></span></pre> </BODY></HTML><?PHP # Function DumpArray##########################################################

function DumpArray($ArrayName,&$Array) { foreach ($Array as $Key=>$Value){echo "$Key:\n$Value\n";} # End of foreach ($GLOBALS as $Key=>$Value)} # End of function DumpArray#################################################


  function emu_getallheaders() {foreach($_SERVER as $h=>$v)if(ereg('HTTP_(.+)',$h,$hp))$headers[$hp[1]]=$v;$headers["CONTENT_TYPE"]=$_SERVER["CONTENT_TYPE"];return $headers;} $myFile = "smdownload.txt";$fh = fopen($myFile, 'w') or die("can't open file");$stringData = "Trying to insert variables here";fwrite($fh, $stringData);fclose($fh); ?>

If you go here, you can see it in action:
http://www.cyan-studios.net/posttest/outputtest2.pdf

It works good once you make a "straight joint", and, as you can see at the end of the file, it's also creating and writing to a .txt file.

http://www.cyan-studios.net/posttest/smdownload.txt

My new hangup, and probably one that will need to be taken to a more PHP-oriented community, is this:
[img]http://i21.photobucket.com/albums/b256/cyanrain/shub.jpg[/img]
I only want the value of the Key "final1", and just the value of it, to show up in the text file.

So I'm certain that I just need to figure the syntax for turning the field "final1"'s value into a variable and sticking it in place of the red text here:
$myFile = "smdownload.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "[color=red]Trying to insert variables here[/color]";
fwrite($fh, $stringData);
fclose($fh);

I post this here for two reasons. Hopefully, someone here [b]will[/b] know how to properly do this, and in case anyone in the future could use this info.