Forums

PDF document

Dimitry 28 Oct, 2015
Hello!
I ask you to forgive me for my english.
I have a question.
Now I create, in my opinion, a complicated form with your magnificent component. The result of this form I want to see a PDF document. The contents of this PDF document is text. But the fact is that when filling certain fields of my form, I would like to see some blocks of text is replaced by another block of text. That is, the text in the final PDF document varied depending on the filling of certain fields in the form.
Please tell me, is it possible to do?
Many thanks!
GreyHead 28 Oct, 2015
1 Likes
Hi Dimitry,

Yes you can do that. Use the TCPDF action to create the PHP. Put a Custom Code action before the TCPDF action and add code like this (it can be much more complex).
<?php
if ( $form->data['input_name'] == 'xxx' ) {
  $temp = "some text here {$form->data['aaa']} more text here. .  . ";
} else {
  $temp = "some other text here {$form->data['bbb']} more text here. .  . ";
}
$form->data['text_block_a'] = $temp;
?>
The put {text_block_a} in the TCPDF template.

Bob
Dimitry 28 Oct, 2015
I thank you for the answer!
However, I can not understand, how can I call you Bob or GreyHead?
I'm just starting to familiarize with the encoding. And when I reach the right moment, be sure to continue the conversation on this subject ... Now, I just would like to know whether this is possible. Not for nothing I started to create larger form. I realized that this is possible.
Many thanks! I'll write later ...
Dimitry 31 Oct, 2015
Hi Bob!
I ended up creating fields in my form. Now I need to create a PDF document to be generated depending on the fields filled my form. In my form 9 pages, where you must fill in the fields. And on page number 10, I would like to show the generated PDF document.
Have a look, please. Do I do:
http://prntscr.com/8xdjp8

What action is unnecessary, and what I need to add?

Thank you! Dmitriy.
GreyHead 31 Oct, 2015
1 Likes
Hi Dimitry,

The TCPDF action creates a PDF file which can be saved to the server* Once it is saved you can attach it to an email or show a download link.

Bob

* You can also have it download immediately but if you do this it must be the very last action as ChronoForms then loses control.
Dimitry 31 Oct, 2015
Thanks Bob!
I need to enable the user to print the PDF document, or save it on him computer if is not possible to print.
And yet, perhaps it's a stupid question, but still:
If this form will be used, for example, 100 users at a time, whether this form to work correctly?
Dimitry 31 Oct, 2015
Do I understand correctly?
The generated PDF document can not be inferred on the last page?
GreyHead 31 Oct, 2015
Hi Dimitry,

We are getting lost in translation - "can not be inferred" ???

Bob
Dimitry 31 Oct, 2015
I would like to display the generated PDF document on the last page of my form. For the user to validate the document. And if the user finds an error, it could return to the previous page to correct them. Possible?
GreyHead 31 Oct, 2015
Hi Dimitry,

No. You can display the PDF - but then ChronoForms loses control and you can't go back.

You can show the HTML content from the form submission and ask them to confirm that before the PDF is created.

Bob
Dimitry 31 Oct, 2015
This means that I must first display the generated html document, the user can check it. And at the bottom of this page to install two buttons: "Previous Page", for example "generate PDF"? Then what actions on the last page of my form I have to install?
Dimitry 31 Oct, 2015
I have to add custom code to the generated document?
GreyHead 31 Oct, 2015
Hi Dimitry,

In the page where you show the Confirm + Back buttons you will use a Custom Code element with some HTML to display the form results - this will look similar to the HTML that is used for an Email template.

In the final page you will want to have the TCPDF action using the same HTML so display the results, I would set that to save to server, and after that I would add a Csutom Code action with a Thank You message and a download link for the PDF.

You might also want an Email action(s) to send notices or results, and I would add a DB Save action to save the from results to a database table as backup.

Bob
Dimitry 31 Oct, 2015
Dear Bob!
1. I have a problem when I put in action PDF html code symbols in Cyrillic (Russian language) are displayed as "?????". What could it be?
http://prntscr.com/8xkc1i
2. And yet, perhaps it's a stupid question, but still:
If this form will be used, for example, 100 users at a time, whether this form to work correctly?
GreyHead 31 Oct, 2015
Hi Dimitry,

Please change the font to freesans which has Cyrillic support - it is possible to add other fonts if you need them.

Bob
Dimitry 01 Nov, 2015
Hi Bob! Thank you for your advice!
My question: My form has a field "drop-down list." This field contains two options (Option 1: word-1, Option 2: Word-2). Using this field change variants of words in one location in the document. I need to use the same field "drop-down list" with the other two variants of words (Option 1: Word-3 Option 2: Word 4) to change the word elsewhere in the document. How can i do this?
Thank you!
GreyHead 02 Nov, 2015
1 Likes
Hi Dimitry,

You can add a Custom Code action before the TCPDF action to set these strings. It will be something like:
<?php
switch ( $form->data['drop_down_1'] ) {
  case  'option 1':
    $form->data['string_1'] = 'some text';
    $form->data['string_2'] = 'some other text';
    break;
  case  'option 2':
    $form->data['string_1'] = 'some different text';
    $form->data['string_2'] = 'some other different text';
    break;
} 
?>
Then you can use {string_1} {string_2} etc, in the TCPDF template.

Bob

[[>> later : fixed typo <<]]
GreyHead 02 Nov, 2015
Hi Dimitry,

Sorry, I missed out the : at the end of the case lines case 'option 2':

Bob
GreyHead 02 Nov, 2015
Hi Dimitry,

What code have you used to define string_3 and string_4 ???

Bob

PS The code I posted works correctly when I test it.
Dimitry 02 Nov, 2015
I need to depending on the value of the field (drop-down list) changed the words in two places the phrase.
On your advice, I put this code in a custom code action:
<?php
switch ( $form->data['dropdown1412'] ) {
  case  '0':
    $form->data['string_1'] = 'проживающий';
    $form->data['string_2'] = 'именуемый';
    break;
  case  '1':
    $form->data['string_1'] = 'проживающая';
    $form->data['string_2'] = 'именуемая';
    break;
} 
?>

This piece of html:
<p style="text-align: justify;"><span style="font-family: arial, helvetica, sans-serif;">гр. <strong>{text1055}</strong>, {dropdown492} {dropdown493} {dropdown494} года рождения, {string_1} {string_3} по адресу: {text494}, {string_2} {string_4} в дальнейшем <strong>«ПРОДАВЕЦ»,</strong> с одной стороны, и</span></p>
Dimitry 02 Nov, 2015
It seems I made a mistake in the ordinal number of string ... (3 and 4)
GreyHead 02 Nov, 2015
Hi Dimitry,

Please look at your code and think about it . . . you have different string names in the two cases - so in each case the 'other' two values will not be set.

I also recommend that you don't use 0 as a drop-down value as sometimes it can be misunderstood - better to use a text string instead.

Bob
Dimitry 02 Nov, 2015
Thank you for your advice, Bob!
Dimitry 03 Nov, 2015
Hi Bob!
I need to value textbox fields are displayed in bold in the html document. How can I do this using the Text Box field?
GreyHead 03 Nov, 2015
Hi Dimitry,
Please try
<b>{textarea_name}</b>

Bob
Dimitry 03 Nov, 2015
This code can be inserted here?

<?php
if ( $form->data['input_name'] == 'xxx' ) {
  $temp = "some text here <b>{$form->data['aaa']}</b> more text here. .  . ";
} else {
  $temp = "some other text here <b>{$form->data['bbb']}</b> more text here. .  . ";
}
$form->data['text_block_a'] = $temp;
?>
GreyHead 03 Nov, 2015
Hi Dimitry,

Yes, you can add any HTML there.

Bob
Dimitry 03 Nov, 2015
It works! Thank you!
Dimitry 03 Nov, 2015
Bob, please tell me, if such a code like this a lot:
<?php
if ( $form->data['input_name'] == 'xxx' ) {
  $temp = "some text here {$form->data['aaa']} more text here. .  . ";
} else {
  $temp = "some other text here {$form->data['bbb']} more text here. .  . ";
}
$form->data['text_block_a'] = $temp;
?>

then each such code is better placed in a separate custom code action? Or I can put in a single operation all the code? If I can, then how to separate code blocks of each other?
Dimitry 03 Nov, 2015
Can I use a checkbox field for this case? And if so, what value instead of "check" I have to deliver, because in this kind of code is not working.
Thank you!
<?php
if ( $form->data['checkbox1203'] == 'check' ) {
  $temp = "<p style="text-align: justify;"><span style="font-family: arial, helvetica, sans-serif;">гр. <b>{$form->data['text1057']}</b>, {$form->data['dropdown500']} {$form->data['dropdown501']} {$form->data['dropdown502']} года рождения, проживающ{$form->data['dropdown1414']} по адресу: {$form->data['text505']}, далее по тексту <strong>«ПРОДАВЕЦ-2»</strong>,</span></p>,";
} else {
  $temp = "";
}
$form->data['text_block_f'] = $temp;
?>
GreyHead 03 Nov, 2015
Hi Dimitry,

You can put as much code as you like in a single Custom code element but working in the textareas is a little difficult so it helps to break the code up into separate chunks for each 'function' that you need to do,

You can use checkboxes BUT an un-checked checkbox returns nothing at all (unless you enable to ghost action).

What is returned is the part of the Options string before the = so if you have check=Some text . . . you will get check as the value.

Bob
Dimitry 04 Nov, 2015
Hi Bob again!
Please tell me: can this arrangement? I try and it's not working. What am I doing wrong?
<?php
if ( $form->data['input_name_1'] == 'xxx' ) {
  $temp = "some text here {$form->data['text_block_b']} more text here. .  . ";
} else {
  $temp = "some other text here {$form->data['bbb']} more text here. .  . ";
}
$form->data['text_block_a'] = $temp;
if ( $form->data['input_name_2'] == 'xxx' ) {
  $temp = "some text here {$form->data['aaa']} more text here. .  . ";
} else {
  $temp = "some other text here {$form->data['bbb']} more text here. .  . ";
}
$form->data['text_block_b'] = $temp;
if ( $form->data['input_name_3'] == 'xxx' ) {
  $temp = "some text here {$form->data['text_block_c']} more text here. .  . ";
} else {
  $temp = "some other text here {$form->data['bbb']} more text here. .  . ";
}
$form->data['text_block_c'] = $temp;
?>
Dimitry 04 Nov, 2015
I'm sorry. Here is the design:

<?php
if ( $form->data['input_name_1'] == 'xxx' ) {
  $temp = "some text here {$form->data['text_block_b']} more text here. .  . ";
} else {
  $temp = "some other text here {$form->data['bbb']} more text here. .  . ";
}
$form->data['text_block_a'] = $temp;
if ( $form->data['input_name_2'] == 'xxx' ) {
  $temp = "some text here {$form->data['text_block_c']} more text here. .  . ";
} else {
  $temp = "some other text here {$form->data['bbb']} more text here. .  . ";
}
$form->data['text_block_b'] = $temp;
if ( $form->data['input_name_3'] == 'xxx' ) {
  $temp = "some text here {$form->data['aaa']} more text here. .  . ";
} else {
  $temp = "some other text here {$form->data['bbb']} more text here. .  . ";
}
$form->data['text_block_c'] = $temp;
?>
GreyHead 04 Nov, 2015
Hi Dimitry,

Sorry, but this tells me nothing useful.

What exactly isn't working?

What values are being returned from your form?

What values are being set for the new variables you are creating?

You can see most of this by adding a Debugger action to the form On Submit event.

Bob
Dimitry 04 Nov, 2015
Bob, I'm sorry you have to deal with dilettantes like me. Let us, in order:
you said:
"You can use checkboxes BUT an un-checked checkbox returns nothing at all (unless you enable to ghost action).

What is returned is the part of the Options string before the = so if you have check=Some text . . . you will get check as the value."
I have a question:
Unfortunately, I do not have a check = some text. How can I assign it? Maybe here?

http://prntscr.com/8ymkll
GreyHead 04 Nov, 2015
Hi Dimitry,

What do you have in the Options box ?

Bob
GreyHead 04 Nov, 2015
Hi Dimitry,

In a single Checkbox it is the Field value and perhaps the Ghost value.

Bob
Dimitry 07 Nov, 2015
Hi Bob!
Whether it is possible to use the value of the field ("2" in the picture) in one location in the document, and the parameter field ("1" in the picture) elsewhere in the document?
http://prntscr.com/900z4k

Thanks Bob!
Dimitry 10 Nov, 2015
Hi Bob!
I can not solve my problem. Please help me.
I want to display in the PDF document is one of the versions of the text, so I created a php file which contains the html code for the text. And in that html code I need to insert php code: <? php echo num2str ("{$ form-> data ['text1111']}"); ?>. Inside the php code, I need to insert a text box in my form: {$ form-> data ['text1111']}. Do I do that?
<?php
if ( $form->data['radio1198'] == '0' ) {
  $temp = "в {$form->data['text1111']} <strong>(<?php echo num2str("{$form->data['text1111']}"); ?></strong>.";
} elseif ( $form->data['radio1198'] == '1' ) {...
Dimitry 10 Nov, 2015
I'm sorry, maybe I'm wrong explained:
in the html code I need to insert php code: num2str(text from the form);
How should I do it?
GreyHead 10 Nov, 2015
1 Likes
Hi Dimitry,,

Does PHP have a num2str() function??? I don't remember seeing that before. If it did the syntax would be
<?php
if ( $form->data['radio1198'] == '0' ) {
  $string = num2str($form-> data['text1111']);
  $temp = "в {$form->data['text1111']} <strong>({$string})</strong>.";
. . .

Bob
Dimitry 10 Nov, 2015
Thank you! I'll try to ...
This is a function that converts the recorded number of digits in the number of written words. For example: $ 1000 => one thousand dollars
Here's the code:
/**
 * Возвращает сумму прописью
 * @author runcore
 * @uses morph(...)
 */
function num2str($num) {
	$nul='ноль';
	$ten=array(
		array('','один','два','три','четыре','пять','шесть','семь', 'восемь','девять'),
		array('','одна','две','три','четыре','пять','шесть','семь', 'восемь','девять'),
	);
	$a20=array('десять','одиннадцать','двенадцать','тринадцать','четырнадцать' ,'пятнадцать','шестнадцать','семнадцать','восемнадцать','девятнадцать');
	$tens=array(2=>'двадцать','тридцать','сорок','пятьдесят','шестьдесят','семьдесят' ,'восемьдесят','девяносто');
	$hundred=array('','сто','двести','триста','четыреста','пятьсот','шестьсот', 'семьсот','восемьсот','девятьсот');
	$unit=array( // Units
		array('копейка' ,'копейки' ,'копеек',	 1),
		array('рубль'   ,'рубля'   ,'рублей'    ,0),
		array('тысяча'  ,'тысячи'  ,'тысяч'     ,1),
		array('миллион' ,'миллиона','миллионов' ,0),
		array('миллиард','милиарда','миллиардов',0),
	);
	//
	list($rub,$kop) = explode('.',sprintf("%015.2f", floatval($num)));
	$out = array();
	if (intval($rub)>0) {
		foreach(str_split($rub,3) as $uk=>$v) { // by 3 symbols
			if (!intval($v)) continue;
			$uk = sizeof($unit)-$uk-1; // unit key
			$gender = $unit[$uk][3];
			list($i1,$i2,$i3) = array_map('intval',str_split($v,1));
			// mega-logic
			$out[] = $hundred[$i1]; # 1xx-9xx
			if ($i2>1) $out[]= $tens[$i2].' '.$ten[$gender][$i3]; # 20-99
			else $out[]= $i2>0 ? $a20[$i3] : $ten[$gender][$i3]; # 10-19 | 1-9
			// units without rub & kop
			if ($uk>1) $out[]= morph($v,$unit[$uk][0],$unit[$uk][1],$unit[$uk][2]);
		} //foreach
	}
	else $out[] = $nul;
	$out[] = morph(intval($rub), $unit[1][0],$unit[1][1],$unit[1][2]); // rub
	$out[] = $kop.' '.morph($kop,$unit[0][0],$unit[0][1],$unit[0][2]); // kop
	return trim(preg_replace('/ {2,}/', ' ', join(' ',$out)));
}

/**
 * Склоняем словоформу
 * @ author runcore
 */
function morph($n, $f1, $f2, $f5) {
	$n = abs(intval($n)) % 100;
	if ($n>10 && $n<20) return $f5;
	$n = $n % 10;
	if ($n>1 && $n<5) return $f2;
	if ($n==1) return $f1;
	return $f5;
}
Dimitry 10 Nov, 2015
Thanks Bob!
Your solution works.
GreyHead 10 Nov, 2015
Hi Dimtry,

Good :-)

I hadn't thought of a custom function - that's OK.

Bob
Dimitry 10 Nov, 2015
This is an example of use:
num2str(878867.15);
Dimitry 13 Nov, 2015
Hi Bob!
Can I change the color of the text Placeholder? If it is possible, how can I do that?
GreyHead 13 Nov, 2015
1 Likes
Hi Dimitry,

This appears to work OK - replace chronoform-my_form_name with the id of your form
#chronoform-my_form_name .form-control:-moz-placeholder {
  color: blue !important;
}
#chronoform-my_form_name .form-control::-moz-placeholder {
  color: blue !important;
}
#chronoform-my_form_name .form-control:-ms-input-placeholder {
  color: blue !important;
}
#chronoform-my_form_name .form-control::-webkit-input-placeholder {
  color: blue !important;
}

Bob
GreyHead 14 Nov, 2015
Hi Dimitry,

The ID of that form is chronoform-demo-multipage not demo-multipage Please check the form page HTML to see that.

Bob
Dimitry 16 Nov, 2015
Hi Bob!
Thanks for your help!
Please tell me you can do to input text in textbox and textarea was bold and different colors?
Dimitry 16 Nov, 2015

Hi Dimitry,

Please change the font to freesans which has Cyrillic support - it is possible to add other fonts if you need them.

Bob



How can I change the font that supports the Cyrillic alphabet?
GreyHead 16 Nov, 2015
Hi Dimitry,

text in textbox and textarea was bold and different colors

Please use CSS in a Load CSS action

How can I change the font that supports the Cyrillic alphabet?

Sorry, I had forgotten that FreeSans wasn't standard :-(

First copy these files from here
  freesans.ctg.z, freesans.php, freesans.z
  freesansb.ctg.z, freesansb.php, freesansb.z
  freesansbi.ctg.z, freesansbi.php, freesansbi.z
  freesansi.ctg.z, freesansi.php, freesansi.z
and copy them to the folder
administrator/components/com_chronoforms5/chronoforms/actions/tcpdf/tcpdf/fonts

Then edit this file around line 193 to add FreeSans to the font lists /administrator/components/com_chronoforms5/chronoforms/actions/tcpdf/tcpdf.php
  $fonts = array('courier' => 'courier', 'helvetica' => 'helvetica', 'times' => 'times');


Note: That worked for me, another user said that he had to copy the fonts to the system php/tcpdf/fonts folder/

Bob
Dimitry 16 Nov, 2015
1. It will look like the code to change the text color and bold in textbox and textarea?

#chronoform-my_form_name .form-control:-moz-textbox {
  color: blue !important;
  font-weight: bold;
}
#chronoform-my_form_name .form-control::-moz-textbox {
  color: blue !important;
  font-weight: bold;
}
#chronoform-my_form_name .form-control:-ms-input-textbox {
  color: blue !important;
  font-weight: bold;
}
#chronoform-my_form_name .form-control::-webkit-input-textbox {
  color: blue !important;
  font-weight: bold;
}
#chronoform-my_form_name .form-control:-moz-textarea {
  color: blue !important;
  font-weight: bold;
}
#chronoform-my_form_name .form-control::-moz-textarea {
  color: blue !important;
  font-weight: bold;
}
#chronoform-my_form_name .form-control:-ms-input-textarea {
  color: blue !important;
  font-weight: bold;
}
#chronoform-my_form_name .form-control::-webkit-input-textarea {
  color: blue !important;
  font-weight: bold;
}


2. Free font works! Thank you!
How can I remove these lines?

http://prntscr.com/93cnzh
Dimitry 16 Nov, 2015
I've realized that my code is not working. Please tell me the code.
PS. I wrote you a message in the personal mail.
Dimitry 17 Nov, 2015
Sorry, Bob. I solved the problem with a bold. Thank you!
Dimitry 18 Nov, 2015
Hi Bob!
Please tell me whether it is possible to insert different versions of the text, depending on the presence or absence of a "comma" in the textarea?
For example, if the field contains a "comma", the text in the document will be "users". If the field does not contain "comma", the text in the document is a "user." If it is possible, how to do it?

Many thanks!
GreyHead 18 Nov, 2015
Hi Dimitry,

You can do that with PHP. I'd put it into a Custom Code action before the TCPDF action. The neatest way might be to explode the string and count the resulting array - though you can also use the standard PHP string functions to check for a comma.

Bob
Dimitry 18 Nov, 2015
The code might look like?

<?php
$mystring = $form->data['textarea1111'];
$findme   = ',';
$pos = strpos($mystring, $findme);
if ($pos === false) {
    $temp = "user";
} else {
   $temp = "users";
}
$form->data['text_block_a'] = $temp;
?>
GreyHead 18 Nov, 2015
Hi Dimitry,

Yes it might.

Bob
Dimitry 18 Nov, 2015
Thank you Bob!
I managed!
I know that for a long time should you coffee or two. I will definitely do it!
Please help me with the back button.
Dimitry 18 Nov, 2015
Hi Bob!
How can I remove these lines in PDF?

http://prntscr.com/93cnzh
GreyHead 19 Nov, 2015
Hi Dimitry,

I don't think that you can using the CF TCPDF action - they are the rules under the header and above the footer - possibly you could hide them with CSS but I don't know how to do that.

Bob
Dimitry 19 Nov, 2015
Thanks for the answer, Bob!
Strange. If footers do not need?
I'm sorry, Bob, maybe I do not understand something, but I'm wondering, why are you silent about the back button? Tell me, please, what should I do to get help from you. Or, then tell me how to do it.
I have tried the method Max. It works well. It has hidden links on each page. Also buttons with reference to these hidden fields. But in the my form is hidden containers. And in going back, they disclosed. This is not acceptable in my form. What to do?
GreyHead 19 Nov, 2015
Hi Dimitry,

The TCPDF action was built to create simple PDFs from form results. It uses a small subset of the features that are available in TCPDF - you can replace the action with Custom PHP to use the full range of features.

Bob
Dimitry 19 Nov, 2015
Hi Bob!
Maybe in the component have a file where I can remove headers and footers?
GreyHead 20 Nov, 2015
1 Likes
Hi Dimitry,

If you edit the file /administrator/components/com_chronoforms5/chronoforms/actions/tcpdf/tcpdf.php about line 99 that seems to hide them
		$pdf->SetFooterMargin($config->get('pdf_margin_footer', 10));
		$pdf->SetPrintHeader(false); // << add this line
		$pdf->SetPrintFooter(false); // << add this line

Bob
Dimitry 20 Nov, 2015
Hi Bob!
I removed the footers with your help. It works. Thank you!
I have a question:
To save or print the PDF document in the settings TCPDF have inline mode. It suits me.
I remember your advice. You are advised to save the document to the server and thanksgiving message has a link to download the document. It's a great idea, but in my case, the user enters into the form fields personal data, and I can not store the data on the server. It is against the law.
If you leave the inline mode. That the derivation of the page containing the PDF document, Chrono, loses control of the session. User is nothing left to do how to close this page. Then he comes out of my site. And that's not good.
I thought, what if you open the page containing the PDF document in a new window, and on the previous page, leave the desired message. Then, the user will have the choice to save or print the document. After the selected action, he will close the page with the PDF document. A page of my site will remain open. That is, he will remain on the site, you need to pre-done action.
So the question is: Is it possible to open a page containing the PDF document (inline mode) in a new window? I tried to cram in all sorts of places target = "_ blank", but there is no result.
Phew, I wrote ...

Thank you!
GreyHead 20 Nov, 2015
Hi Dimitry,

If the law allows you could use a cron job to delete any pdfs more than say 30 minutes old - would that help?

I do not know if you can open the pdf in a new window, the behaviour also seems to vary between browsers,

Bob
Dimitry 20 Nov, 2015
Hi Bob!
You mean that you can make the PDF file is automatically deleted from the server within 30 minutes after the formation of?
Sorry, but your second sentence, I do not understand ...
GreyHead 21 Nov, 2015
Hi Dimirty,

Yes, you could run a cron job on your server that runs, say every ten minutes. The URL of the cron job can be for a form event - or a PHP file, that checks the PDF folder and deletes all files with a time-stamp more than x minutes ago.

In the second sentence I am just saying that Chrome, IE, Edge, FireFox etc seem to handle the immediate downloads / display in different ways; and I don't know how to make them open the pdf in a different window :-(

Bob
Dimitry 21 Nov, 2015
Thank you for supporting Bob!
This means that the user remains on the site, I have to use the first option that you suggested.
Well, the first question arises:
I have to use a mode to save to server?
I tried to do it:
1. settings TСPDF I established a regime to maintain the server
2. I have to save the file: /home/m/meatrich/hahoo/public_html/images/PDF
where /home/m/meatrich/hahoo/public_html - the path to my server, and /images/PDF - path to the folder.
3. I tested, and the result is saved in the specified folder
http://prntscr.com/958dih
4. settings form:
http://prntscr.com/958e89
5. However, the page number 8 - empty.
http://prntscr.com/958ela


What should I do to display the page, the link to download PDF file?
GreyHead 21 Nov, 2015
Hi Dimitry,

Please see "Adding a link to an email or Thank you page" in this FAQ.

Bob
Dimitry 21 Nov, 2015
Hi Bob!
Thank you for your FAQ.
I did as it is written. However, when i click on the link (download) - opens a PDF document in a browser, just as in the mode shown inline.
Should it be? I just thought that when you click on the link, the file must be loaded onto the local computer.
GreyHead 22 Nov, 2015
Hi Dimitry,

It depends on the browser and browser settings - I usually say 'right click' and choose 'save pdf as'

Bob

PS Since the last Windows upgrade I found that PDFs downloaded in Chrome now open in MS Edge . . .
Dimitry 22 Nov, 2015
Hi Bob!
These browser settings suits me. I did so that this link opens in new window and the user can be on my site. Now I have only to make the PDF file is automatically deleted, and the back button.
By the way, I noticed that you can move to the previous page using the browser. For this to work, you must click on the left, and then refresh the page. I tried to connect the commands in the button: onclick history and the forced refresh the page but with no success.
Dimitry 22 Nov, 2015
Hello again, Bob.
I want to ask you about the automatic removal of the old PDF files:
My directory that created PDF files - /images/PDF/
I searched the net and that's what found. Check, please:
<?php
function clear_old_files(){

$expire_time = 300;

$dir = $_SERVER['DOCUMENT_ROOT']."/images/PDF/";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {

$time_sec=time();
$time_file=filemtime($dir . $file);
$time=$time_sec-$time_file;

$unlink = $_SERVER['DOCUMENT_ROOT'].'/tmp/'.$file;

if (is_file($unlink)){
if ($time>$expire_time){

if (unlink($unlink)){

echo 'File deleted';

}else {

echo 'Error deleting file';

}
}

}
}
closedir($dh);
}
}

}
?>


Please tell me whether this code to delete PDF files after a lapse of 5 minutes?
And can I put this file in custom code of my form. This custom code after I put custom code that creates a link to download the file.
Dimitry 22 Nov, 2015
I have corrected. Here's the code:
<?php
function clear_old_files(){

$expire_time = 300;

$dir = $_SERVER['DOCUMENT_ROOT']."/images/PDF/";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {

$time_sec=time();
$time_file=filemtime($dir . $file);
$time=$time_sec-$time_file;

$unlink = $_SERVER['DOCUMENT_ROOT'].'/images/PDF/'.$file;

if (is_file($unlink)){
if ($time>$expire_time){

if (unlink($unlink)){

echo 'File deleted';

}else {

echo 'Error deleting file';

}
}

}
}
closedir($dh);
}
}

}
?>
Dimitry 22 Nov, 2015
Hi Bob!
Why not work TCPDF width alignment? In an HTML document to test the CSS code works, and TCPDF - no.
Dimitry 22 Nov, 2015
I found a code in the FAQ
<?php
// change the next line to match your upload folder
// use this version for Joomla! 3 or later
//$files = glob(JPATH_SITE.'/components/com_chronoforms/uploads/*');
// set 'keep' period to 7 days
$checktime = time() - 7 * 24 * 60 * 60;
foreach ( $files as $v ) {
  if ( is_file($v) && filemtime($v) < $checktime ) {
    unlink($v);
  }
}
?>


But how can I set the file to be considered obsolete after 1 minute?
I have to do so?
$checktime = time() - 1* 60;
Dimitry 22 Nov, 2015
No, this code will not work for my case. In the folder where the PDF has loaded the index.html file, and it should not be removed. Because if it is removed, the TCPDF can not create a path to the download folder. I have to make sure that this file is removed.
Sorry Bob, I sent so many unnecessary messages.
Dimitry 23 Nov, 2015
Hi Bob!
1. I put this code after TCPDF action.
<?php
$files = glob(JPATH_SITE.'/images/PDF/*.pdf');
$checktime = time() - 60;
foreach ( $files as $v ) {
  if ( is_file($v) && filemtime($v) < $checktime ) {
     unlink($v);
  }
}
?>


According to my idea, this code should delete the PDF file from the folder images / PDF / after 1 minute. The code works, but not as much as I should. It removes the PDF file during re-session, that is, during the re-transition to the page where the code is located.
Please tell me where I'm wrong. I tried all the ways that I know ...
2. I can not align the text to the width. CSS and HTML do not help. Text is constantly aligned to the left. What can be wrong?
GreyHead 24 Nov, 2015
1 Likes
Hi Dimitry,

PHP has no sense of time - it only knows 'now'. So when your code runs it looks for files more than 60 minutes old when it runs. It does not and cannot wait 60 minutes and then delete them.

The way round this is to run a cron job - that is a PHP file that is run on a time schedule. Usually you can set these up from the Cpanel on your web host.

Bob
Dimitry 24 Nov, 2015
Ahh, now I understand. Thanks Bob!
The second problem I have decided. That's my fault. I messed up the code.
Dimitry 26 Nov, 2015
Hi Bob!
For some reason, cron job is not running. Please tell me this code at all right?
<?php
$files = glob(JPATH_SITE.'/images/PDF/*.pdf');
$checktime = time() - 60;
foreach ( $files as $v ) {
  if ( is_file($v) && filemtime($v) < $checktime ) {
     unlink($v);
  }
}
?>

And, the line:
$checktime = time() - 60;

it means that the file is older than 60 seconds to be removed? Or is it 60 minutes?
if the code is correct, then I may be wrong to point the way to the folder where the files are located?
I tried different ways of options, but without success.
Dimitry 27 Nov, 2015
Hi Bob!
I solved the problem with cron. I really made a mistake in specifying the path to the folder with the files.
Thank you!
Dimitry 15 Dec, 2015
Hi Bob!
Is there any news about the back button? Maybe is the result?
Dimitry 11 Jan, 2016
Hello dear Bob!
I congratulate you on the upcoming holidays! I wish you good health!
And I would still know: is there any news about the back button?
Dimitry 16 Jan, 2016
Hi Bob!
I think I decided my problem with the back button. So thank you!
I have a question:
How to change the appearance of links:
/index.php?option=com_chronoforms5&chronoform=exchangecontract-free&event=page2
to
exchangecontract-free&event=page2
This topic is locked and no more replies can be posted.