首页 \ 问答 \ 如何使用参数保存带有FDPF的PDF?(How do you save a PDF with FDPF using parameters?)

如何使用参数保存带有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
更新时间:2022-05-31 12:05

最满意答案

它似乎默认被压制。 运行

$ 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是指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: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 ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)