Thanks Tilman I was able to run the example now However, when I tested in https://www.pdfen.com/pdf-a-validator, it said [image: image.png]
Tilman Hausherr <thaush...@t-online.de> 於 2022年2月1日週二 下午11:04寫道: > Because you're not using the 2.0 CreatePDFA.java example. That one goes > like this: > > // add XMP metadata > XMPMetadata xmp = XMPMetadata.createXMPMetadata(); > > try > { > DublinCoreSchema dc = xmp.createAndAddDublinCoreSchema(); > dc.setTitle(file); > > PDFAIdentificationSchema id = > xmp.createAndAddPFAIdentificationSchema(); > id.setPart(1); > id.setConformance("B"); > > XmpSerializer serializer = new XmpSerializer(); > ByteArrayOutputStream baos = new ByteArrayOutputStream(); > serializer.serialize(xmp, baos, true); > > PDMetadata metadata = new PDMetadata(doc); > metadata.importXMPMetadata(baos.toByteArray()); > doc.getDocumentCatalog().setMetadata(metadata); > } > catch(BadFieldValueException e) > { > // won't happen here, as the provided value is valid > throw new IllegalArgumentException(e); > } > > Tilman > > Am 01.02.2022 um 21:17 schrieb Tommy Wu: > > I still cannot get it to compile > > > > <dependency> > > <groupId>org.apache.pdfbox</groupId> > > <artifactId>pdfbox</artifactId> > > <version>2.0.25</version> > > </dependency> > > > > <dependency> > > <groupId>org.apache.pdfbox</groupId> > > <artifactId>xmpbox</artifactId> > > <version>2.0.24</version> > > </dependency> > > <dependency> > > <groupId>org.apache.pdfbox</groupId> > > <artifactId>fontbox</artifactId> > > <version>2.0.25</version> > > </dependency> > > // jempbox version > > XMPMetadata xmp = new XMPMetadata(); > > XMPSchemaPDFAId pdfaid = new XMPSchemaPDFAId(xmp); > > xmp.addSchema(pdfaid); > > pdfaid.setConformance("B"); > > pdfaid.setPart(1); > > pdfaid.setAbout(""); > > metadata.importXMPMetadata(xmp); > > > > *java: constructor XMPMetadata in class org.apache.xmpbox.XMPMetadata > > cannot be applied to given types;* > > * required: no arguments* > > * found: no arguments* > > * reason: XMPMetadata() has protected access in > > org.apache.xmpbox.XMPMetadata* > > > > > > > > > > *java: cannot find symbol symbol: class XMPSchemaPDFAId location: > class > > com.example.pdfboxtest.CreatePDFAjava: cannot find symbol symbol: > class > > XMPSchemaPDFAId location: class com.example.pdfboxtest.CreatePDFAjava: > > incompatible types: org.apache.xmpbox.XMPMetadata cannot be converted to > > byte[]* > > > > Tilman Hausherr <thaush...@t-online.de> 於 2022年2月1日週二 下午3:03寫道: > > > >> Use xmpbox, not jempbox. > >> > >> Tilman > >> > >> Am 01.02.2022 um 20:19 schrieb Tommy Wu: > >>> Here's the dependency I used > >>> > >>> <dependency> > >>> <groupId>org.apache.pdfbox</groupId> > >>> <artifactId>pdfbox</artifactId> > >>> <version>2.0.25</version> > >>> </dependency> > >>> <!-- https://mvnrepository.com/artifact/org.apache.pdfbox/jempbox --> > >>> <dependency> > >>> <groupId>org.apache.pdfbox</groupId> > >>> <artifactId>jempbox</artifactId> > >>> <version>1.8.16</version> > >>> </dependency> > >>> > >>> > >>> pdfboxTest\src\main\java\com\example\pdfboxtest\CreatePDFA.java:101:40 > >>> java: incompatible types: org.apache.jempbox.xmp.XMPMetadata cannot be > >>> converted to byte[] > >>> > >>> line 40 is > >>> > >>> metadata.importXMPMetadata(xmp); > >>> > >>> > >>> Tilman Hausherr <thaush...@t-online.de> 於 2022年2月1日週二 下午1:56寫道: > >>> > >>>> Then please tell what errors you get, and what libraries you're using > >>>> (hopefully pdfbox, fontbox and xmpbox). > >>>> > >>>> Tilman > >>>> > >>>> Am 01.02.2022 um 19:42 schrieb Tommy Wu: > >>>>> I can't even get it to compile > >>>>> > >>>>> Andreas Lehmkuehler <andr...@lehmi.de> 於 2022年2月1日週二 上午12:35寫道: > >>>>> > >>>>>> Hi, > >>>>>> > >>>>>> Am 31.01.22 um 22:03 schrieb Tommy Wu: > >>>>>>> The following cookbook is not long working for the new version. Do > >> you > >>>>>> have > >>>>>>> a way to do it now? > >>>>>> Which version are you referring to? > >>>>>> > >>>>>> What exactly doesn't work? > >>>>>> > >>>>>> Andreas > >>>>>>> Apache PDFBox | PDF/A Creation > >>>>>>> <https://pdfbox.apache.org/1.8/cookbook/pdfacreation.html> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> Thanks > >>>>>>> > >>>>>> > --------------------------------------------------------------------- > >>>>>> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org > >>>>>> For additional commands, e-mail: users-h...@pdfbox.apache.org > >>>>>> > >>>>>> > >>>> --------------------------------------------------------------------- > >>>> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org > >>>> For additional commands, e-mail: users-h...@pdfbox.apache.org > >>>> > >>>> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org > >> For additional commands, e-mail: users-h...@pdfbox.apache.org > >> > >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org > For additional commands, e-mail: users-h...@pdfbox.apache.org > >