提交到PDF格式是否有一個插件或東西,創建PDF文件從用戶輸入的表單數據,當它點擊提交按鈕?提交到WordPress的文本
回答
我還沒有完成WP插件的詳盡搜索,但從我可以告訴答案是否定的。當然,從零開始創建這樣一個插件是可能的,但是託管WP的服務器需要安裝正確的庫以使插件有用。
我發現這些插件允許發佈郵件或下載爲PDF文件。
http://wordpress.org/extend/plugins/tags/create-pdf
如果你是靈活的,這似乎可以以編程方式創建的帖子從用戶提交表單,然後創建後的PDF文件。從表單創建的帖子可以很容易地分配給一個特定的類別,該類別不會在網站上顯示。
以編程方式創建,更新和刪除帖子,看到WordPress的功能參考,特別是:
wp_insert_post wp update post wp delete post
快速google search展品很多的方法來創建PDF文件用PHP。有些困難,有些困難。 I found this class that might get you started: "FPDF"
如果你想填寫表格,然後處理該表格的細節並通過電子郵件發送給你,並附上詳細的pdf附件,幾周前我有類似的東西,我找不到任何可以工作的東西我想要的方式,所以...
我設置我的表單,然後使用自定義頁面模板,我分配到一個頁面,然後使用PHP和html2pdf class我創建了我的PDF格式,通過電子郵件發送附件...
繼承人的代碼,我用.. 作壓縮此頁面(記得要淨化你的用戶輸入)。
<?php
/*
Template Name: FORMTOPDF
*/
?>
<?php get_header(); ?>
<style>
/* STYLES FOR ERROR PLACEMENT */
label {
width: 80px;
text-align: right;
float: left;
}
.formerror {
border: 1px solid red;
background-color : #FFCCCC;
width: auto;
padding: 5px 0;
padding-left:10px;
}
.errortext {
font: bold smaller sans-serif;
}
</style>
<?php
// CREATE AN ARRAY FOR OUR ERRORS
$arrErrors = array();
// Check for FORM SUBMISSION
// using hidden form field
if(isset($_POST['action']) && ($_POST['action']=='send'))
{
/* ================= START FORM DATA ========================= */
$name = trim($_POST['name']);
if ($name=='') $arrErrors['name'] = 'Please provide your name.';
$email = trim($_POST['email']);
if ($email=='') $arrErrors['Email'] = 'Please provide your Email Address.';
$comments = trim($_POST['your-comments']);
if ($comments=='') $arrErrors['Comments'] = 'Please add your Comments.';
/* ================= END FORM DATA ========================= */
if (count($arrErrors) == 0) {
// Process form here
/* ================= START PDF CREATION ========================= */
$strContent = "<p>Submission from ".$name."</p>";
$strContent.= "<p><strong>Name</strong>:".$name."</p>";
$strContent.= "<p><strong>Email </strong>: ".$email."</p>";
$strContent.= "<p><strong>Comments</strong> : <br />".$comments."</p>";
/* ================= END PDF CREATION ========================= */
// Include our HTML to PDF creator
// FROM THEME DIRECTORY?
require(TEMPLATEPATH.'/html2pdf/html2fpdf.php');
$pdf=new HTML2FPDF();
$pdf->AddPage();
// folder location of HTML file
$fileLocation = "wp-content/uploads/";
// Call to the file name from the URL
$fileName = "Form_Submission_From_".$name;
// add the location 'wp-content/uploads/' to the fileToOpen
$fileToOpen = $fileLocation;
// Then add the actual file name // form_submission.pdf
// output should look like 'wp-content/uploads/form_submission_from_(name).pdf'
$fileToOpen .= $fileName.".pdf";
// Open the file with read access
$fp = fopen($fileToOpen,"r");
//$strContent = fread($fp, filesize($fileToOpen));
// Close of the page
fclose($fp);
// Create new PDF document from the Content
$pdf->WriteHTML($strContent);
// create our PDF in the wp uploads folder
$pdf->Output("wp-content/uploads/" .$fileName. ".pdf");
/* ================= END PDF ========================= */
/* ================= START EMAIL ========================= */
$headers= "From: YourWebsite <[email protected]>\r\n\\";
$emailSubject = "Submission from " . $name;
$emailAdmin = "[email protected]";
$emailMessage = "Submission from ".$yourcompanyname."\n\n";
$emailMessage.= "Company Name: ".$yourcompanyname."\n";
$emailMessage.= "Email : ".$email."\n";
$emailMessage.= "Comments : \n".$comments."\n\n";
$attachments = array(WP_CONTENT_DIR ."/uploads/".$fileName.".pdf", $target_path);
wp_mail($emailAdmin, $emailSubject, $emailMessage, $headers, $attachments);
// Delete our PDF from the server after email Sent
// uncomment this to delete after email sent?
//unlink($fileToOpen);
/* ================= END EMAIL ========================= */
// show thank you message if successful
$strGood = '<div class="formerror" style="background:#FFC;">
<h2>Thank You</h2>
<p>Thank you for contacting us.</p>
</div>';
}else{
// The error array had something in it. There was an error.
// Start adding error text to an error string.
$strError = '<div class="formerror"><p><img style="margin-left:10px;" src="'.get_option('home').'/wp-content/themes/mytheme/media/images/triangle_error.gif" width="16" height="16" hspace="5" alt=""><strong>Please check the following and try again:</strong></p><ul style="margin-left:50px;">';
// Get each error and add it to the error string
// as a list item.
foreach ($arrErrors as $error) {
$strError .= "<li style='list-style-type:circle;'><em>$error</em></li>";
}
$strError .= '</ul></div><br />';
}
}// NOT BEEN SUBMITTED
// show regular page with form
?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2>
<?php the_title(); ?>
</h2>
<?php
// show errors if there is any
echo $strError;
?>
<?php
// show thank you if successful
echo $strGood;
?>
<?php the_content('<p>Read the rest of this page »</p>'); ?>
<form method="post" action="<?php bloginfo('url');?>/your-form-page/" enctype="multipart/form-data">
<input type="hidden" value="send" name="action">
<p <?php if (!empty($arrErrors['name'])) echo ' class="formerror"'; ?>>Your Name:
<span class="errortext" style="color:#F00;">(required)</span><br>
The rest of the form below here ------ >
</form>
<?php endwhile; endif; ?>
<?php get_footer(); ?>
完蛋了,一旦用戶填寫表單,(我的形式有比這多很多領域外加文件上傳領域也附後。)
但形式提交,支票對於必填字段,如果成功,它將從$ strContent變量創建一個pdf文件,然後將其附加到使用wordpress中的wp_mail發送的電子郵件中,然後顯示一條感謝消息,否則它將顯示並突出顯示任何錯誤,
希望這有助於...
我們爲我們的客戶之一創建了一個定製解決方案,因爲沒有任何現成的插件可以完成。該系統通過從Gravity Forms中獲取數據來創建pdf/word文檔。
您可以在此查看解決方案的詳細信息。 Gravity Forms to PDF/Word Document Auto-Fill Soluion
有一個稱爲重力PDF插件擴展,從重力形式延伸。它將從表格生成PDF,您可以選擇下載或通過電子郵件發送。
來源 https://wordpress.org/plugins/gravity-forms-pdf-extended/
- 1. WordPress提交數據到我的sql
- 2. Rails的FormBuilder提交文本
- 3. 提交的文本輸入
- 4. 使用ajax提交表單提交到WordPress數據庫
- 5. 提交從文本文件
- 6. Ajax表單提交的WordPress
- 7. Wordpress中的表單提交
- 8. WordPress的用戶提交
- 9. 在WordPress內提交ajax文章
- 10. 恢復到本地提交?
- 11. 提交時提交版本
- 12. CakePHP文本形式提交
- 13. wordpress重力表格數據保存到csv文件提交
- 14. Wordpress表單未提交
- 15. 誤差提交在WordPress
- 16. WordPress SVN提交失敗
- 17. WordPress TinyMCE不提交內容
- 18. Fullcalendar wordpress提交訂單
- 19. wordpress表單動作提交
- 20. 如何提交在WordPress
- 21. WordPress用戶鏈接提交
- 22. 簡單的模態聯繫表單wordpress插件提交「404未找到」提交
- 23. 將本地Git提交到git-svn的一個提交中
- 24. 表單提交後更改提交按鈕的文本?
- 25. 如何在php中提交提交按鈕的文本
- 26. 提交html文本框的UrlDecode值提交
- 27. 提交後更改提交按鈕上的文本
- 28. Subversion:如何將文本追加到每個提交的文件?
- 29. 基本提交按鈕 - 保存文本
- 30. git - 提交到版本庫的日期
http://wordpress.stackexchange.com/questions/3895/submit-to-pdf-in-wordpress – serhio 2010-11-10 20:26:29