I have a pdf template file with form fields (amount_1, amount_2 etc) I created an XFDF file and am using PDFtk via command line to fill the form and flatten the file.
However, when I run the command below, the new pdf is created but the fields are not filled in.
/usr/bin/pdftk /home/admin/tickets/tickets.pdf fill_form /home/admin/tickets/files/1371711546.xfdf output 1371711546.pdf flatten
the XFDF looks like this
<?xml version="1.0" encoding="UTF-8"?>
<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
<fields>
<field name="amount_1">
<value>$17.00</value>
</field>
<field name="amount_2">
<value>$17.00</value>
</field>
<field name="amount_3">
<value>$17.00</value>
</field>
<field name="amount_4">
<value>$17.00</value>
</field>
</fields>
<ids original="095b7b1e54742b95f30a987149d65453" modified="1371711546" />
<f href="http://test.selebtom.co.zw/tickets/tickets.pdf" />
</xfdf>
I know it's been a while, but just in case someone is researching this, here's the way I solve this problem:
First, if you don't mind removing the XFA format from the file, thereby creating a new pdf 'template' to do your form fills with, then simply, remove extra XML data with the following command line:
"pdftk xfa-pdf-form.pdf output acro-pdf-form.pdf drop_xfa"
If this still gives you trouble, start over with the original XFA file and in LiveCylce save the the file as an Adobe Static PDF form. Or using Acrobat X Pro I think you can do this too. Then repeat the step above, by calling the command line to drop_xfa.
You should have a regular Acroform at this point.
From here you will be able to save the ouput file's data as an XFDF or FDF. Then it's business as usual.
Thanks to #enriquein, who pointing me in the right direction.
Related
I have a custom module where I add custom file upload fields like so:
my_upload_2d = fields.Binary(string="Upload 2D")
my_upload_3d = fields.Binary(string="Upload 3D")
The problem is that uploaded PDFs or Catia files are downloaded as .bin files - how can I see to it that the files are downloaded with the same name they have been uploaded with in the first place?
You need a field for the file itself and another field for the file name, ie:
description_data_file = fields.Binary('description data')
description_data_file_name = fields.Char('description file name', size=80)
And in the xml file:
<group string="File to import">
<field name='description_data_file' string="Desc file" widget="binary" filename="description_data_file_name"/>
<field name='description_data_file_name' string="Desc file" attrs="{'readonly':True, 'invisible':True}" />
</group>
Note that in the xml the binary data field relates to its name using the "filename" parameter.
I've been reading that there is a way to create/reference a .FDF file (used for merging data with a PDF form) that has an embedded URL to the original PDF to be filled in it, and a specifically crafted URL can be sent to the browser that will load Acrobat or related programs that will merge the FDF data with the PDF.
Presumably something like:
http://host/path/original.pdf#FDF=http://host/path/data.fdf
But I can't get that to work. Perhaps the path to the original PDF can be embedded within the .FDF file? I've heard there is something called an /F key that can be used. Can anyone give me an example of it's use, and if there is a special MIME format that is needed to have the browser recognize the file/merge, what would it be?
Here's an example of an FDF file - where do I put the original PDF url?
%FDF-1.2
%▒▒▒▒
1 0 obj
<</FDF<</F(Stand Alone EE.pdf)/Fields[
<</T(date)/V(07/11/2018)>>
<</T(uname)/V(Jennifer Smith)>>
<</T(pctbefore)/V(35)>>
<</T(aftfee)/V(40)>>
<</T(newclient)/V(Yes)>>
<</T(current_dateplus90days)/V(10/11/2018)>>
<</T(im_url)/V(http://internal_usl_for_something_else)>>
]/ID[<A3715E58793D9B5B9A48E8B2E0E057FF><BCE39B7672548444B7E6606F1B14E048>]/UF(Stand Alone EE.pdf)>>/Type/Catalog>>
endobj
trailer
<</Root 1 0 R>>
%%EOF
I have kind of given up on the .fdf format since apparently a newer version, .xfdf is available, but if either way can work, it would be great.
I have also tried this with the XFDF format as documented here:
https://forums.adobe.com/thread/425699
The problem I've run into with the XFDF version is, when I click on the .xfdf it wants to save the file locally. I checked to make sure the mime type is set in the web server and it is. But if I save the .fdf and click on it, it opens up Acrobat, which then tries to open a document in Firefox with the same URL, which then prompts me if I want to open the document in Acrobat and it keeps spawning a circle of windows in Mozilla. Any idea what's wrong?
Here's a sample .fdf
<?xml version="1.0" encoding="UTF-8"?>
<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
<f href="http://myhost/sample.pdf" />
<fields>
<field name="date"><value>07/11/2018</value></field>
<field name="atty"><value>Jennifer Smith</value></field>
<field name="typeofclaim"><value>Automobile Collision</value></field>
</fields>
</xfdf>
Anybody see anything wrong in the composition? What mime.type issues could I be having? My server is set to recognize .xfdf as "application/vnd.adobe.xfdf"
I set up a shell script to output the mime-type "application/vnd.adobe.xfdf", and then dump the content of the fxdf file above. The browser recognizes it as an Adobe app and I can open it with Acrobat, but then I get this error:
Xml parsing error: xml processing instruction not at start of external entity (error code 17) line 2 of file xxxxx.xfdf
Any idea what the error could be in the xml file? The parser says it's correct. Is it ok to terminate lines with \n?
One problem I found with the field parsing is that it's very picky about the content of the form data if it's not encapsulated in some kind of structure (i.e. CDATA) that says "leave as is", so if you have a data form field, for example, that has unbalanced parenthesis, this can cause bizarre errors.
One of my fixes was to fully-validate the form field data. And make sure things like for every open parenthesis, there were closed parenthesis. This at least fixed one of the errors.
the .XFDF format here works:
<?xml version="1.0" encoding="UTF-8"?>
<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
<f href="http://myhost/sample.pdf" />
<fields>
<field name="date"><value>07/11/2018</value></field>
<field name="atty"><value>Jennifer Smith</value></field>
<field name="typeofclaim"><value>Automobile Collision</value></field>
</fields>
</xfdf>
I'm getting the above error when I try uploading an auto-suggest xml file to Google's custom site search. I tried trimming the file down to the bear minimum to see if I could isolate the problem but even the following won't upload:
<?xml version="1.0" encoding="utf-8"?>
<Autocompletions>
<Autocompletion term="My term" type="1" />
</Autocompletions>
Am I missing something blindingly obvious?
Kind regards,
Karl
It turns out, despite the Google information to the contrary, that the 'language' attribute is required even if it's value is blank. I added that and the file was successfully imported.
<?xml version="1.0" encoding="utf-8"?>
<Autocompletions>
<Autocompletion term="My term" type="1" language="" />
</Autocompletions>
Make sure that your encoding is UTF-8. Also, term="" i.e. an empty term should not be there in the XML file.
I have an oni file where depth and rgb images are not aligned. I read in other questions that in this case it is useful to use GetAlternativeViewPointCap(). However this does not work.
I tried the following code:
if (depth.IsCapabilitySupported(XN_CAPABILITY_ALTERNATIVE_VIEW_POINT)) {
depth.GetAlternativeViewPointCap().SetViewPoint(image);
}
In the xml file I tried (one of the several attempts)
....
<Recording file="file.oni" />
<Node type="Depth" >
<Query>
<Capabilities>
<Capability>Alternative View</Capability>
</Capabilities>
</Query>
<Configuration>
</Configuration>
</Node>
....
Is it possible to use GetAlternativeViewPointCap also for already recorded files?
How the xml file should be configured?
Based on the capabilities that I add I get the error: Open failed: The node is locked for changes!
Any idea?
Tks!
If you load a recording file you cannot change its Capabilities, Resolution, etc.
Configuring is only relates when connecting to a real hardware.
how to add new line in my string resource file?
I already tried \r\n, \n,
,
but it displays exactly what you've indicated, it does not give a new line.
Thanks for your help
When editing resource file in designer press Shift + Enter for new line.
You could, but its a bit indirect. By using
you could add a new line, the only trick here is that & gets converted to in the background. To bring it back to
, all you have to do is open your .resx the file in xml (right-click and open with XML (Text) editor), remove the amp; of the
Before
<data name="HelloWorld" xml:space="preserve">
<value>Hello World</value>
</data>
After
<data name="HelloWorld" xml:space="preserve">
<value>Hello
World</value>
</data>