Have you actually read the PDF/A-1 (ISO 19005-1) standard?
Have you read the PDF 1.4 specification, which PDF/A-1 is based on?
It seems like you are trying to do this entirely via guesswork rather than
reading the relevant documentation and understanding them...
Leonard
From: Manulak Dissanayake [mailto:[email protected]]
Sent: Wednesday, September 05, 2012 12:29 AM
To: Post all your questions about iText here
Subject: Re: [iText-questions] [SPAM] Re: PDF Validation error with PDF/A1b
complaince
Hi Again
I found and experienced that the conversion of an existing PDF to a PDF A
complaint ones is merely impossible (or very hard and long process to do so)
and still I found that the problem is with the PDF Schema values when the newly
added metadata values are not matching with them.
I further found that it is quite possible to read a PDF and edit the PDF Schema
meta data. So I tried reading the existing PDF to an existing PdfCopy, add
metadata to it, and then forward it to the convertPdfA() method which is stated
in my below mail.
But still it doesn't work. (Assume that the file1 is the existing PDF and the
file2 is the PDFA complaint file which is the output)
PdfReader reader = new PdfReader(new
RandomAccessFileOrArray(file1.getPath()), null);
PdfStamper stamper = new PdfStamper(reader, new
FileOutputStream(newFile));
HashMap info = reader.getInfo();
info.put("Subject", "Report Executor");
info.put("Author", "Report building logic");
info.put("Keywords", "PDF/A compliant");
info.put("Title", "Report");
info.put("Creator", "Application reporting");
stamper.setMoreInfo(info);
ByteArrayOutputStream bo = new ByteArrayOutputStream();
XmpWriter xmp = new XmpWriter(bo, info);
xmp.close();
stamper.setXmpMetadata(bo.toByteArray());
stamper.close();
(I call this method before calling the convertToPdfA method, and then it will
return file1 with modified PDF document information)
In my already existing PDF (which is to be converted to PDFA), only the
following metadata are there.
(When executed - reader.getInfo() )
[0] "Type => Info"
[1] "Producer => null"
My PDF which was converted to PDFA from my convertToPdfA method compliance to
PDFA/1b correctly when I removed the title, keywords and subject fields from
the PDF information.
(Removed code)
//document.addTitle(reader.getInfo().get("Title").toString());
//document.addKeywords(reader.getInfo().get("Keywords").toString());
//document.addSubject(reader.getInfo().get("Subject").toString());
So it confirms that the above three properties are not existing in PDF
dictionary values, and if anyhow we can add those values to the already created
PDF and then pass it to conversion, it should work.
How can I change my approach? As this is not working for me, do you have any
more suggestions?
Is that enough to update only the PDF Schema like this and then use my
convertToPdfA method given below?
Thank you in advance.
-Manulak Dissanayake
From: Manulak Dissanayake
Sent: Tuesday, September 04, 2012 10:59 AM
To:
[email protected]<mailto:[email protected]>
Subject: RE: [iText-questions] [SPAM] Re: PDF Validation error with PDF/A1b
complaince
Hi
Thanks for the information.
Creating the PDFs as PDFA complaint files from the scratch is my second option
as it is not possible right now. So I tried adding the schema values first to
the created PDF, and then create a new file which is a PDFA conversion of the
previous file.
In my method converToPDFA (which I explained in earlier messages), I added a
call before all as follows.
public void convertToPdfA(File file1, File file2) { \\ This "file2" will be
the newly converted file to PDFA
file1 = editPDFSchema(file1);
PdfReader reader = null;
Document document = null;
......................
And I added that new method as follows...
private File editPDFSchema(File file1) {
File newFile = null;
PdfReader reader = null;
Document document = null;
File newFile = null;
try {
PdfReader reader = new PdfReader(new
RandomAccessFileOrArray(file1.getPath()), null);
PdfStamper stamper = new PdfStamper(reader, new
FileOutputStream(newFile));
HashMap info = reader.getInfo();
info.put("Subject", "Report Designer Operational Report");
info.put("Author", "Report ");
info.put("Keywords", "PDF/A compliant");
info.put("Title", " Designer Report");
info.put("Creator", "Application");
stamper.setMoreInfo(info);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
XmpWriter xmp = new XmpWriter(baos, info);
xmp.close();
stamper.setXmpMetadata(baos.toByteArray());
stamper.close();
return newFile;
} catch (Exception ex) {
writeLog(ex.getMessage());
return file1;
}
Still this makes the PDF as PDFA but does not validate.
Can you please help me to maybe update the already created PDF like that, and
then do the PDFA conversion?
Thank you in advance...!
- Manulak
-----Original Message-----
From: mkl
[mailto:[email protected]]<mailto:[mailto:[email protected]]>
Sent: Wednesday, August 29, 2012 2:07 PM
To:
[email protected]<mailto:[email protected]>
Subject: [iText-questions] [SPAM] Re: PDF Validation error with PDF/A1b
complaince
It is not strictly impossible to use iText to convert arbitrary PDFs to PDF/A
as the iText low level API allows you to to nearly everything allowed in PDF.
It is a very big project, though, especially if the PDFs to convert really are
arbitrary. It's safe to assume that programming that as a single developer
takes more than a year.
iText used to assume everyone uses the recommended namespace prefixes and,
therefore, failed for source PDFs which didn't.
But the metadata are merely a tiny part of the conversion problem. I would
propose you initially create PDFs as PDF/as, and for people who don't want
that, you stamp those PDF/as in a non-compliant manner. (If such a distinction
is required, that is!)
Regards, Michael
--
View this message in context:
http://itext-general.2136553.n4.nabble.com/PDF-Validation-error-with-PDF-A1b-complaince-tp4655986p4656073.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat
landscape has changed and how IT managers can respond. Discussions will include
endpoint security, mobile security and the latest in malware threats.
http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
iText-questions mailing list
[email protected]<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/ Please check the keywords list
before you ask for examples: http://itextpdf.com/themes/keywords.php
------------------------------------------------------------------------------
CONFIDENTIALITY AND DISCLAIMER NOTICE
This e-mail, including any attachments, is confidential and for use only by
the intended recipient. If you are not the intended recipient, please notify
us immediately and delete this e-mail from your system. Any use or disclosure
of the information contained herein is strictly prohibited. As internet
communications are not secure, we do not accept legal responsibility for the
contents of this message nor responsibility for any change made to this
message after it was sent by the original sender. We advise you to carry out
your own virus check as we cannot accept liability for damage resulting from
software viruses.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php