如何使用参数保存带有FDPF的PDF?(How do you save a PDF with FDPF using parameters?)
我有这个按钮,它与这个功能有关:
$('#genPDF').click(function () { var str = "hText=something" + "&cText=also something"; $.ajax({ url: "/wp-content/themes/mytheme/indexpdf.php", data: str, cache: false, success: function (result) { console.log("Success!"); $("#pdfobject").attr("src", "/wp-content/themes/mytheme/flyer.pdf"); var container = document.getElementById("pdfContainer"); var content = container.innerHTML; container.innerHTML = content; } }); });
为了解释成功的ajax代码的作用,首先输出“成功!” 在浏览器中的控制台中,然后用修改后的链接替换页面上的某个div(刷新页面的某个部分)。
上面的代码工作,并使它转到indexpdf.php,这是:
<?php $hText = trim(isset($_GET['hText']) ? $_GET['hText'] : ''); $cText = trim(isset($_GET['cText']) ? $_GET['cText'] : ''); require_once('fpdf.php'); require_once('fpdi.php'); // initiate FPDI $pdf = new FPDI(); $pdf->AddPage(); $pdf->setSourceFile("TestFlyer.pdf"); $tplIdx = $pdf->importPage(1); $pdf->useTemplate($tplIdx, 10, 10, 100); $pdf->SetFont('Helvetica'); $pdf->SetTextColor(255, 0, 0); $pdf->SetXY(30, 30); $pdf->Write(0, $hText.$cText); $pdf->Output("D","flyer.pdf"); ?>
问题是,它应该采用testflyer.pdf,加载它的第一页并将传入的参数写入其中。 然后,将自己保存为flyer.pdf。
这不是保存,我不知道正在做什么或问题是什么。
上面的所有PDF和PHP文件都在/ mytheme /文件夹中。
I have this button, that is tied to this function:
$('#genPDF').click(function () { var str = "hText=something" + "&cText=also something"; $.ajax({ url: "/wp-content/themes/mytheme/indexpdf.php", data: str, cache: false, success: function (result) { console.log("Success!"); $("#pdfobject").attr("src", "/wp-content/themes/mytheme/flyer.pdf"); var container = document.getElementById("pdfContainer"); var content = container.innerHTML; container.innerHTML = content; } }); });
To explain what the successful ajax code does, first outputs "success!" in the console, which the browser does, then replaces a certain div on the page with a revised link (refreshing a certain part of the page).
This above code works, and makes it's way over to indexpdf.php, which is:
<?php $hText = trim(isset($_GET['hText']) ? $_GET['hText'] : ''); $cText = trim(isset($_GET['cText']) ? $_GET['cText'] : ''); require_once('fpdf.php'); require_once('fpdi.php'); // initiate FPDI $pdf = new FPDI(); $pdf->AddPage(); $pdf->setSourceFile("TestFlyer.pdf"); $tplIdx = $pdf->importPage(1); $pdf->useTemplate($tplIdx, 10, 10, 100); $pdf->SetFont('Helvetica'); $pdf->SetTextColor(255, 0, 0); $pdf->SetXY(30, 30); $pdf->Write(0, $hText.$cText); $pdf->Output("D","flyer.pdf"); ?>
The problem is, it's supposed to take testflyer.pdf, load it's first page and write my passed in arguments into it. THEN, save itself as flyer.pdf.
It's not saving, I don't know what's doing on or what the problem is.
All PDF's and PHP files above are in the /mytheme/ folder.
原文:https://stackoverflow.com/questions/36650610
最满意答案
它似乎默认被压制。 运行
$ ulimit -c unlimited
将启用核心转储,并将它放在/ cores /中作为core.PID
It seems they are suppressed by default. Running
$ ulimit -c unlimited
Will enable core dumps for the current terminal, and it will be placed in /cores/ as core.PID. When you open a new session, it will be set to the default value again.
相关问答
更多-
Mac OS X 和Mac OS 10.5 , Mac OS 10.6三者区别在哪里 有什么不同[2022-02-22]
Mac OS X是指Macintosh操作系统10,10在罗马数字里是X,每个版本用不同的大型猫科动物命名包括10.5和10.6,你可以看看百度百科对Mac OS X -
它似乎默认被压制。 运行 $ ulimit -c unlimited 将启用核心转储,并将它放在/ cores /中作为core.PID It seems they are suppressed by default. Running $ ulimit -c unlimited Will enable core dumps for the current terminal, and it will be placed in /cores/ as core.PID. When you open a new ...
-
什么语言是Windows,Mac OS X和Linux?(What languages are Windows, Mac OS X and Linux written in?)[2022-10-13]
Windows:C ++,内核在C中 Mac:Objective C,内核是C(IO PnP子系统是Embedded C ++) Linux:大多数事情都在C中,许多用户应用程序都是Python,KDE是所有C ++ 所有内核也将使用一些汇编代码。 Windows: C++, kernel is in C Mac: Objective C, kernel is in C (IO PnP subsystem is Embedded C++) Linux: Most things are in C, many ... -
过了一会儿,我决定从头开始重新安装。 我用dotnetfx源删除了git repo,清除了'lib'和'opt'文件夹(来自'openssl'),删除了Cellar文件夹(其中'openssl'驻留)。 一旦我完成了所有这些,我就开始了一个新的安装,并按照官方资源上发布的说明这一次全部部署并且像魅力一样工作。 After a while, I decided to reinstall everything from scratch. I have deleted git repo with dotnetfx ...
-
有些工具可以在这里找到: 菜单Xcode>打开开发人员工具>更多开发人员工具...... 将打开developer.apple.com并且您必须登录 下载“Xcode的图形工具 - 2013年1月” 然后使用“Quartz Debug”作为Frame Meter。 还有一些用于调试CALayers的环境变量: CA_COLOR_FLUSH, CA_COLOR_NO_WAIT, CA_COLOR_OPAQUE, CA_LOG_IMPLICIT_TRANSACTIONS, CA_LOG_IMAGE_COPIES ...
-
它是来自Apple for Mac OS X的文档,所有类引用等。有了它,您可以查找Apple为您提供的每个类的不同信息(如果您想要了解有关NSString类中的方法的更多信息) 。 It's the documentation from Apple for Mac OS X, all of the class references, etc. With it, you can look up different information about every class that Apple offers ...
-
我不使用screen但我认为如果你将〜/ .bashrc中的source ~/git-completion.bash语句放在你的〜/ .bash_profile中它可能会有效。 我不认为screen算作登录shell。 I don't use screen but I think it will probably work if you put the source ~/git-completion.bash statement in your ~/.bashrc instead of your ~/.ba ...
-
Microsoft将函数描述为返回格式化字符串时将使用的字符数 - 请注意它们被记录为不包括空终止符。 int _vscprintf( const char *format, va_list argptr ); int _vscwprintf( const wchar_t *format, va_list argptr ); 初步答案 因此,可以使用vsprintf()和vswprintf()模拟这些函数: int _vscprintf(const char *format, ...
-
如果您需要“实时”,这意味着我想要将其用于将在屏幕上显示的实时流。 在这种情况下,您可能希望在GPU上做所有事情(而不是CPU,在这种情况下我建议使用vDSP)。 Core Image的CIFilter可能就是这样。 If you need it "real time" that implies to me you want to do it to a live stream that will be displayed onscreen. In that case you probably want to ...
-
java.util.prefs机制是处理此类事情的跨平台方式。 在Windows上它由注册表支持,在Mac上它由~/Library的.plist文件支持,在Linux和朋友上它由~/.java的文件支持,但是用于访问信息的API在所有平台。 The java.util.prefs mechanism is the cross-platform way to approach this sort of thing. On Windows it's backed by the registry, on Mac ...