I'm trying to fill an XFA form using the example file using PdfBox 2 or 3 from:
https://issues.apache.org/jira/secure/attachment/12964530/XFAFormFiller.java
I'm not so used to PDFBox so not sure how to correct it.
I get compile errors. Basically how can I make it compile with latest PDFBox? Are my corrections below correct?
Line 107 I tried to fix with
Set<COSDictionary> objectsToWrite = new HashSet<>();
Line 121 I tried to fix with
COSWriter writer = new COSWriter(fos, new RandomAccessReadBuffer(baos.toByteArray()), objectsToWrite);
Line 128 I tried to fix with:
objectsToWrite.add(dataSetsStream);
What format should the XML input file be? Can someone give an example?
I get a corrupt PDF out with my corrections and feeding it the XML generated from dataSetsStream.
The file I feed:
<xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"
><xfa:data
><mycompany
>
.....
><mycompany
></dd:dataDescription
></xfa:datasets
>
Any help is appreciated.
Related
We are trying to convert XLS file to DRL file using Drool.net in C#. It is throwing error java.lang.RuntimeException: 'Script template is null - check for missing script definition.'. I am using basic sample template, but this error is kept on coming.
Sample rules table
Sample code
Please help us to resolve this issue.
Sample tried code
We are expecting this code to return text in DRL format.
I'm currently trying to load a .mat file in python using scipy and the following bit of code:
from scipy import io as sio
data= "file.mat"
output= sio.loadmat(data)
However when running the command I get the error:
ValueError: Mat 4 mopt wrong format, byteswapping problem?
What does this error message mean? Is there an issue with the file I'm trying to load?
I'm quite the novice when it comes to programming so any suggestions would be greatly appreciated : ) If there is a better way to load .mat files in python I'm open to hearing those too. Thanks in advance!
I've never seen this error before, but it is produced by line 113 in scipy/scipy/io/matlab/mio4.py
def read_header(self):
''' Read and return header for variable '''
data = read_dtype(self.mat_stream, self.dtypes['header'])
name = self.mat_stream.read(int(data['namlen'])).strip(b'\x00')
if data['mopt'] < 0 or data['mopt'] > 5000:
raise ValueError('Mat 4 mopt wrong format, byteswapping problem?')
...
Normally loadmat is the right file loader, at least among the supported types:
v4 (Level 1.0), v6 and v7 to 7.2 matfiles are supported.
Do you know anything about how this file was saved in MATLAB? Any format specifications such as these?
My requirement is to add the time stamp in the bottom of the PDF. I'm using itext 5.4.3 version to edit the PDF and able to add the time-stamp successfully. But the process is throwing java.lang.ArrayIndexOutOfBoundsException exception for some PDF.. Attaching the exception stack trace below.
at com.itextpdf.text.pdf.PdfEncryption.createInfoId(PdfEncryption.java:558)
at com.itextpdf.text.pdf.PdfStamperImp.close(PdfStamperImp.java:383)
at com.itextpdf.text.pdf.PdfStamperImp.close(PdfStamperImp.java:337)
at com.itextpdf.text.pdf.PdfStamper.close(PdfStamper.java:206)
I did the analysis and found this issue is happening due to bad trailer exist in pdf,itext is expecting 16 bit trailer data whereas my pdf is having only 4 bit or some times 10 bit. Attaching the trailer information below.
Valid Trailer:
/ID AA8280F47FC1BF4DCD5C88E6A493092D
Invalid Trailer:
/ID B2DE387A
We have asked vendor to re-scan the PDF again but looks like most of the PDF is having the similar trailer. Is there anyway to edit the PDF using itext which is having invalid trailer? Please help.
Any updated version will fix the issue?
This is reproducible with 5.4.3, but not with the current version, 5.5.7.
This is probably the commit that fixed it: e28f688033
(This fix seems to be a bit overkill, because it's creating new IDs whenever the existing one aren't 16 bytes, which isn't a requirement.)
I am using iTextSharp to load the XMP in PDF file
Reference: Is it possible to load XMP file in PDF using iTextSharp?
From above instruction I am loaded XMP data in PDF file, but there is one problem
In keywords section "; " semicolon and single space added in prefix by default as show below in screen shot.
PDF Properties Window:
XMP Sample I used to load:
I used source code to sort out this problem but I can't, still i am searching only. Before I would like to let you know to iTextSharp author, so only am posting this question.
Note:
In case I am setting Keywords dictionary by
Dictionary<String, String> info = reader.Info;
info.Add("Keywords", ",key1; key2");
It working fine.
The problem is probably caused by the XMP file you are adding. Adobe Reader is adding extra stuff to the keywords you define in the <dc:subject> based on what is present or missing in the pdf:Keywords attribute.
Please take a look at this example: xmp_metadata_added.pdf
This is what the XMP file looks like:
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.1.0-jc003">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:pdf="http://ns.adobe.com/pdf/1.3/"
xmlns:xmp="http://ns.adobe.com/xap/1.0/"
dc:format="application/pdf"
pdf:Keywords="Metadata, iText, PDF"
pdf:Producer="iText® 5.5.1 ©2000-2014 iText Group NV (AGPL-version); modified using iText® 5.5.1 ©2000-2014 iText Group NV (AGPL-version)"
xmp:CreateDate="2014-05-16T17:04:59+01:00"
xmp:CreatorTool="My program using iText"
xmp:ModifyDate="2014-05-16T17:04:59+01:00"
xmp:MetadataDate="2014-05-16T17:04:59+01:00">
<dc:description>
<rdf:Alt>
<rdf:li xml:lang="x-default">This example shows how to add metadata</rdf:li>
</rdf:Alt>
</dc:description>
<dc:creator>
<rdf:Seq>
<rdf:li>Bruno Lowagie</rdf:li>
</rdf:Seq>
</dc:creator>
<dc:subject>
<rdf:Bag>
<rdf:li>Metadata</rdf:li>
<rdf:li>iText</rdf:li>
<rdf:li>PDF</rdf:li>
</rdf:Bag>
</dc:subject>
<dc:title>
<rdf:Alt>
<rdf:li xml:lang="x-default">Hello World example</rdf:li>
</rdf:Alt>
</dc:title>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
You recognize:
<dc:subject>
<rdf:Bag>
<rdf:li>Metadata</rdf:li>
<rdf:li>iText</rdf:li>
<rdf:li>PDF</rdf:li>
</rdf:Bag>
</dc:subject>
But do you see:
pdf:Keywords="Metadata, iText, PDF"
You need that part too.
This is a screen shot with that part:
When I remove pdf:Keywords="Metadata, iText, PDF", I can reproduce your problem:
This proves that your problem is caused by your XMP file, not by iText.
I am creating pdf file through the XML, XSL and FOP. I want PDF file contents to display external file contents such as word document.
I know for displaying image in PDF we use but what tag we should to display file contents other than pdf file type.
There's a FOP extension that claims to be able to do this:
jeremias-maerki.ch/development/fop/index.html
Also see xmlgraphics.apache.org/fop/1.0/extensions.html#external-document
When I used in this way
xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"
content-type="pdf" src="C:\temp\reports\p2.pdf"/>
I am getting exception as
org.apache.fop.apps.FOPException: Error(Unknown location): No element mapping definition found for fox:external-document
Let me know the reason.
THanks in advance.
I'd say you're probably using an old Apache FOP version which doesn't have the fox:external-document extension, yet. Please upgrade to FOP 1.0 (or at least 0.95).
Change the namespace from:
http://xml.apache.org/fop/extensions
to
http://xmlgraphics.apache.org/fop/extensions