diff options
| author | leshe4ka46 <alex9102naid1@ya.ru> | 2025-10-19 14:47:59 +0300 |
|---|---|---|
| committer | leshe4ka46 <alex9102naid1@ya.ru> | 2025-10-19 14:47:59 +0300 |
| commit | e17a425dfb3382310fb5863f516dacdca9f44956 (patch) | |
| tree | 7babb3048d0eb20aa1e68e9b29c2acfa794ab96f /unipdf/model/xmputil | |
| parent | 091963a50c3bb2926f559f01c49e8f5bd03d2bfd (diff) | |
fuck the unipdf licencing
Diffstat (limited to 'unipdf/model/xmputil')
| -rw-r--r-- | unipdf/model/xmputil/pdfaextension/pdfaextension.go | 181 | ||||
| -rw-r--r-- | unipdf/model/xmputil/pdfaid/pdfaid.go | 48 | ||||
| -rw-r--r-- | unipdf/model/xmputil/xmputil.go | 193 |
3 files changed, 422 insertions, 0 deletions
diff --git a/unipdf/model/xmputil/pdfaextension/pdfaextension.go b/unipdf/model/xmputil/pdfaextension/pdfaextension.go new file mode 100644 index 0000000..5ab1095 --- /dev/null +++ b/unipdf/model/xmputil/pdfaextension/pdfaextension.go @@ -0,0 +1,181 @@ +// +// Copyright 2020 FoxyUtils ehf. All rights reserved. +// +// This is a commercial product and requires a license to operate. +// A trial license can be obtained at https://unidoc.io +// +// DO NOT EDIT: generated by unitwist Go source code obfuscator. +// +// Use of this source code is governed by the UniDoc End User License Agreement +// terms that can be accessed at https://unidoc.io/eula/ + +package pdfaextension ;import (_e "fmt";_g "github.com/trimmer-io/go-xmp/models/dc";_bf "github.com/trimmer-io/go-xmp/models/pdf";_ga "github.com/trimmer-io/go-xmp/models/xmp_base";_ea "github.com/trimmer-io/go-xmp/models/xmp_mm";_fb "github.com/trimmer-io/go-xmp/xmp"; +_a "reflect";_bc "sort";_b "strings";_f "sync";);var XmpMediaManagementSchema =Schema {NamespaceURI :"\u0068\u0074\u0074p\u003a\u002f\u002f\u006es\u002e\u0061\u0064\u006f\u0062\u0065\u002ec\u006f\u006d\u002f\u0078\u0061\u0070\u002f\u0031\u002e\u0030\u002f\u006d\u006d\u002f",Prefix :"\u0078\u006d\u0070M\u004d",Schema :"X\u004dP\u0020\u004d\u0065\u0064\u0069\u0061\u0020\u004da\u006e\u0061\u0067\u0065me\u006e\u0074",Property :[]Property {{Category :PropertyCategoryInternal ,Description :"\u0041\u0020\u0072\u0065\u0066\u0065\u0072\u0065\u006e\u0063\u0065\u0020\u0074\u006f\u0020\u0074\u0068\u0065\u0020\u006fr\u0069\u0067\u0069\u006e\u0061\u006c\u0020\u0064\u006f\u0063\u0075\u006d\u0065\u006e\u0074\u0020\u0066\u0072\u006f\u006d\u0020w\u0068\u0069\u0063\u0068\u0020\u0074\u0068\u0069\u0073\u0020\u006f\u006e\u0065\u0020i\u0073\u0020\u0064e\u0072\u0069\u0076\u0065\u0064\u002e",Name :"D\u0065\u0072\u0069\u0076\u0065\u0064\u0046\u0072\u006f\u006d",ValueType :ValueTypeNameResourceRef },{Category :PropertyCategoryInternal ,Description :"\u0054\u0068\u0065\u0020\u0063\u006fm\u006d\u006f\u006e\u0020\u0069d\u0065\u006e\u0074\u0069\u0066\u0069e\u0072\u0020\u0066\u006f\u0072 \u0061\u006c\u006c\u0020\u0076\u0065\u0072\u0073\u0069\u006f\u006e\u0073 \u0061\u006e\u0064\u0020\u0072\u0065\u006e\u0064\u0069\u0074\u0069\u006f\u006e\u0073\u0020o\u0066\u0020\u0061\u0020\u0072\u0065\u0073\u006fu\u0072\u0063\u0065",Name :"\u0044\u006f\u0063\u0075\u006d\u0065\u006e\u0074\u0049\u0044",ValueType :ValueTypeNameURI },{Category :PropertyCategoryInternal ,Description :"UU\u0049\u0044 \u0062\u0061\u0073\u0065\u0064\u0020\u0069\u0064\u0065n\u0074\u0069\u0066\u0069\u0065\u0072\u0020\u0066\u006f\u0072\u0020\u0073\u0070\u0065\u0063\u0069\u0066\u0069\u0063\u0020\u0069\u006e\u0063\u0061\u0072\u006e\u0061\u0074i\u006fn\u0020\u006f\u0066\u0020\u0061\u0020\u0064\u006fc\u0075m\u0065\u006et",Name :"\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0049\u0044",ValueType :ValueTypeNameURI },{Category :PropertyCategoryInternal ,Description :"\u0054\u0068\u0065\u0020\u0063\u006fm\u006d\u006f\u006e\u0020\u0069d\u0065\u006e\u0074\u0069\u0066\u0069e\u0072\u0020\u0066\u006f\u0072 \u0061\u006c\u006c\u0020\u0076\u0065\u0072\u0073\u0069\u006f\u006e\u0073 \u0061\u006e\u0064\u0020\u0072\u0065\u006e\u0064\u0069\u0074\u0069\u006f\u006e\u0073\u0020o\u0066\u0020\u0061\u0020\u0064\u006f\u0063\u0075m\u0065\u006e\u0074",Name :"\u004fr\u0069g\u0069\u006e\u0061\u006c\u0044o\u0063\u0075m\u0065\u006e\u0074\u0049\u0044",ValueType :ValueTypeNameURI },{Category :PropertyCategoryInternal ,Description :"\u0054\u0068\u0065 \u0072\u0065\u006e\u0064\u0069\u0074\u0069\u006f\u006e\u0020\u0063\u006c\u0061\u0073\u0073\u0020\u006e\u0061\u006d\u0065\u0020\u0066\u006f\u0072\u0020\u0074\u0068\u0069\u0073 \u0072\u0065\u0073\u006f\u0075\u0072\u0063\u0065",Name :"\u0052\u0065\u006e\u0064\u0069\u0074\u0069\u006f\u006eC\u006c\u0061\u0073\u0073",ValueType :ValueTypeNameRenditionClass },{Category :PropertyCategoryInternal ,Description :"\u0043\u0061n\u0020\u0062\u0065\u0020\u0075\u0073\u0065d\u0020t\u006f\u0020\u0070r\u006f\u0076\u0069\u0064\u0065\u0020\u0061\u0064\u0064\u0069\u0074\u0069\u006f\u006e\u0061\u006c\u0020\u0072\u0065\u006e\u0064\u0069t\u0069\u006f\u006e\u0020\u0070\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u0073\u0020\u0074\u0068a\u0074 \u0061r\u0065\u0020\u0074o\u006f\u0020\u0063\u006f\u006d\u0070\u006c\u0065\u0078\u0020\u006f\u0072\u0020\u0076\u0065\u0072\u0062o\u0073\u0065\u0020\u0074\u006f\u0020\u0065\u006e\u0063\u006f\u0064\u0065\u0020\u0069\u006e",Name :"\u0052e\u006ed\u0069\u0074\u0069\u006f\u006e\u0050\u0061\u0072\u0061\u006d\u0073",ValueType :ValueTypeNameText },{Category :PropertyCategoryInternal ,Description :"\u0054\u0068\u0065\u0020\u0064\u006f\u0063\u0075\u006d\u0065\u006e\u0074\u0020\u0076\u0065\u0072\u0073\u0069o\u006e\u0020\u0069\u0064\u0065\u006e\u0074i\u0066\u0069\u0065\u0072\u0020\u0066\u006f\u0072\u0020\u0074\u0068i\u0073\u0020\u0072\u0065\u0073\u006f\u0075\u0072\u0063\u0065\u002e",Name :"\u0056e\u0072\u0073\u0069\u006f\u006e\u0049D",ValueType :ValueTypeNameText },{Category :PropertyCategoryExternal ,Description :"\u0054\u0068\u0065\u0020\u0076\u0065r\u0073\u0069\u006f\u006e\u0020\u0068\u0069\u0073\u0074\u006f\u0072\u0079\u0020\u0061\u0073\u0073\u006f\u0063\u0069\u0061t\u0065\u0064\u0020\u0077\u0069\u0074\u0068\u0020\u0074\u0068\u0069\u0073\u0020\u0072e\u0073o\u0075\u0072\u0063\u0065",Name :"\u0056\u0065\u0072\u0073\u0069\u006f\u006e\u0073",ValueType :SeqOfValueTypeName (ValueTypeNameVersion )},{Category :PropertyCategoryInternal ,Description :"\u0054\u0068\u0065\u0020\u0072\u0065f\u0065\u0072\u0065\u006e\u0063\u0065\u0064\u0020\u0072\u0065\u0073\u006f\u0075r\u0063\u0065\u0027\u0073\u0020\u006d\u0061n\u0061\u0067\u0065\u0072",Name :"\u004da\u006e\u0061\u0067\u0065\u0072",ValueType :ValueTypeNameAgentName },{Category :PropertyCategoryInternal ,Description :"\u0054\u0068\u0065 \u0072\u0065\u0066\u0065\u0072\u0065\u006e\u0063\u0065\u0064\u0020\u0072\u0065\u0073\u006f\u0075\u0072\u0063\u0065\u0027\u0073\u0020\u006d\u0061\u006e\u0061\u0067\u0065\u0072 \u0076\u0061\u0072\u0069\u0061\u006e\u0074\u002e",Name :"\u004d\u0061\u006e\u0061\u0067\u0065\u0072\u0056\u0061r\u0069\u0061\u006e\u0074",ValueType :ValueTypeNameText },{Category :PropertyCategoryInternal ,Description :"\u0054\u0068\u0065 \u0072\u0065\u0066\u0065\u0072\u0065\u006e\u0063\u0065\u0064\u0020\u0072\u0065\u0073\u006f\u0075\u0072\u0063\u0065\u0027\u0073\u0020\u006d\u0061\u006e\u0061\u0067\u0065\u0072 \u0076\u0061\u0072\u0069\u0061\u006e\u0074\u002e",Name :"\u004d\u0061\u006e\u0061\u0067\u0065\u0072\u0056\u0061r\u0069\u0061\u006e\u0074",ValueType :ValueTypeNameText }}}; +func init (){_fb .Register (Namespace ,_fb .XmpMetadata );_fb .Register (SchemaNS );_fb .Register (PropertyNS );_fb .Register (ValueTypeNS );_fb .Register (FieldNS );}; + +// Schemas is the array of xmp metadata extension resources. +type Schemas []Schema ;var FieldVersionSchema =Schema {NamespaceURI :"\u0068\u0074\u0074p\u003a\u002f\u002f\u006e\u0073\u002e\u0061\u0064\u006f\u0062\u0065\u002e\u0063\u006f\u006d\u002f\u0078\u0061\u0070\u002f\u0031\u002e\u0030\u002f\u0073\u0054\u0079\u0070\u0065/\u0056\u0065\u0072\u0073\u0069\u006f\u006e\u0023",Prefix :"\u0073\u0074\u0056e\u0072",Schema :"\u0042a\u0073\u0069\u0063\u0020\u0076\u0061\u006c\u0075\u0065\u0020\u0074y\u0070\u0065\u0020\u0056\u0065\u0072\u0073\u0069\u006f\u006e",Property :[]Property {{Category :PropertyCategoryInternal ,Description :"\u0043\u006fmm\u0065\u006e\u0074s\u0020\u0063\u006f\u006ecer\u006ein\u0067\u0020\u0077\u0068\u0061\u0074\u0020wa\u0073\u0020\u0063\u0068\u0061\u006e\u0067e\u0064",Name :"\u0063\u006f\u006d\u006d\u0065\u006e\u0074\u0073",ValueType :ValueTypeNameText },{Category :PropertyCategoryInternal ,Description :"\u0048\u0069\u0067\u0068\u0020\u006c\u0065\u0076\u0065\u006c\u002c\u0020\u0066\u006f\u0072\u006d\u0061\u006c\u0020\u0064e\u0073\u0063\u0072\u0069\u0070\u0074\u0069\u006f\u006e\u0020\u006f\u0066\u0020\u0077\u0068\u0061\u0074\u0020\u006f\u0070\u0065r\u0061\u0074\u0069\u006f\u006e\u0020\u0074\u0068\u0065\u0020\u0075\u0073\u0065\u0072 \u0070\u0065\u0072f\u006f\u0072\u006d\u0065\u0064\u002e",Name :"\u0065\u0076\u0065n\u0074",ValueType :ValueTypeResourceEvent },{Category :PropertyCategoryInternal ,Description :"\u0054\u0068e\u0020\u0064\u0061\u0074\u0065\u0020\u006f\u006e\u0020\u0077\u0068\u0069\u0063\u0068\u0020\u0074\u0068\u0069\u0073\u0020\u0076\u0065\u0072\u0073\u0069\u006f\u006e\u0020\u0077\u0061\u0073\u0020\u0063\u0068\u0065\u0063\u006b\u0065\u0064\u0020\u0069\u006e\u002e",Name :"\u006d\u006f\u0064\u0069\u0066\u0079\u0044\u0061\u0074\u0065",ValueType :ValueTypeNameDate },{Category :PropertyCategoryInternal ,Description :"\u0054\u0068e\u0020\u0070\u0065\u0072s\u006f\u006e \u0077\u0068\u006f\u0020\u006d\u006f\u0064\u0069f\u0069\u0065\u0064\u0020\u0074\u0068\u0069\u0073\u0020\u0076\u0065\u0072s\u0069\u006f\u006e\u002e",Name :"\u006d\u006f\u0064\u0069\u0066\u0069\u0065\u0072",ValueType :ValueTypeNameProperName },{Category :PropertyCategoryInternal ,Description :"\u0054\u0068\u0065 n\u0065\u0077\u0020\u0076\u0065\u0072\u0073\u0069\u006f\u006e\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u002e",Name :"\u0076e\u0072\u0073\u0069\u006f\u006e",ValueType :ValueTypeNameText }},ValueType :nil }; + + +// AltOfValueTypeName gets the ValueTypeName of the alt of given value type names. +func AltOfValueTypeName (vt ValueTypeName )ValueTypeName {return "\u0061\u006c\u0074\u0020"+vt }; + +// GetSchema for provided namespace. +func GetSchema (namespaceURI string )(*Schema ,bool ){_gf .RLock ();defer _gf .RUnlock ();_cbd ,_ef :=_bec [namespaceURI ];return _cbd ,_ef ;}; + +// SyncModel implements xmp.Model interface. +func (_aec *Model )SyncModel (d *_fb .Document )error {return nil }; + +// SetTag implements xmp.Model interface. +func (_acf *Model )SetTag (tag ,value string )error {if _gcd :=_fb .SetNativeField (_acf ,tag ,value );_gcd !=nil {return _e .Errorf ("\u0025\u0073\u003a\u0020\u0025\u0076",Namespace .GetName (),_gcd );};return nil ;};const (PropertyCategoryUndefined PropertyCategory =iota ; +PropertyCategoryInternal ;PropertyCategoryExternal ;); + +// SyncFromXMP implements xmp.Model interface. +func (_ag *Model )SyncFromXMP (d *_fb .Document )error {return nil };func _ee (_gag _fb .Model ,_ca *_fb .Namespace ,_cad Property )bool {_cg :=_a .ValueOf (_gag ).Elem ();if _cg .Kind ()==_a .Ptr {_cg =_cg .Elem ();};_bfd :=_cg .Type ();for _aee :=0;_aee < _bfd .NumField (); +_aee ++{_gc :=_bfd .Field (_aee );_fgb :=_gc .Tag .Get ("\u0078\u006d\u0070");if _fgb ==""{continue ;};if !_b .HasPrefix (_fgb ,_ca .Name ){continue ;};_gg :=_b .IndexRune (_fgb ,':');if _gg ==-1{continue ;};_dbd :=_fgb [_gg +1:];if _dbd ==_cad .Name {_aed :=_cg .Field (_aee ); +return !_aed .IsZero ();};};return false ;}; + +// CanTag implements xmp.Model interface. +func (_ff *Model )CanTag (tag string )bool {_ ,_ac :=_fb .GetNativeField (_ff ,tag );return _ac ==nil }; + +// Properties is a list of properties. +type Properties []Property ;func (_bd Schemas )Typ ()_fb .ArrayType {return _fb .ArrayTypeUnordered }; + +// SetSchema sets the schema into given model. +func (_ad *Model )SetSchema (namespaceURI string ,s Schema ){for _aa :=0;_aa < len (_ad .Schemas );_aa ++{if _ad .Schemas [_aa ].NamespaceURI ==namespaceURI {_ad .Schemas [_aa ]=s ;return ;};};_ad .Schemas =append (_ad .Schemas ,s );}; + +// ValueTypes is the slice of field value types. +type ValueTypes []FieldValueType ; + +// UnmarshalText implements encoding.TextUnmarshaler interface. +func (_cga *PropertyCategory )UnmarshalText (in []byte )error {switch string (in ){case "\u0069\u006e\u0074\u0065\u0072\u006e\u0061\u006c":*_cga =PropertyCategoryInternal ;case "\u0065\u0078\u0074\u0065\u0072\u006e\u0061\u006c":*_cga =PropertyCategoryExternal ; +default:*_cga =PropertyCategoryUndefined ;};return nil ;};func init (){_bec =map[string ]*Schema {_ea .NsXmpMM .URI :&XmpMediaManagementSchema ,"\u0078\u006d\u0070\u0069\u0064\u0071":&XmpIDQualSchema ,_bf .NsPDF .URI :&PdfSchema ,"\u0073\u0074\u0045v\u0074":&FieldResourceEventSchema ,"\u0073\u0074\u0056e\u0072":&FieldVersionSchema }; +}; + +// Typ gets array type of the field value types. +func (_cgd ValueTypes )Typ ()_fb .ArrayType {return _fb .ArrayTypeOrdered };var (Namespace =_fb .NewNamespace ("\u0070\u0064\u0066\u0061\u0045\u0078\u0074\u0065\u006e\u0073\u0069\u006f\u006e","\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0077\u0077\u0077\u002e\u0061\u0069\u0069\u006d\u002e\u006f\u0072\u0067\u002f\u0070\u0064\u0066\u0061/\u006e\u0073\u002f\u0065\u0078t\u0065\u006es\u0069\u006f\u006e\u002f",NewModel ); +SchemaNS =_fb .NewNamespace ("\u0070\u0064\u0066\u0061\u0053\u0063\u0068\u0065\u006d\u0061","h\u0074\u0074\u0070\u003a\u002f\u002fw\u0077\u0077\u002e\u0061\u0069\u0069m\u002e\u006f\u0072\u0067\u002f\u0070\u0064f\u0061\u002f\u006e\u0073\u002f\u0073\u0063\u0068\u0065\u006da\u0023",nil ); +PropertyNS =_fb .NewNamespace ("\u0070\u0064\u0066a\u0050\u0072\u006f\u0070\u0065\u0072\u0074\u0079","\u0068\u0074t\u0070\u003a\u002f\u002fw\u0077\u0077.\u0061\u0069\u0069\u006d\u002e\u006f\u0072\u0067/\u0070\u0064\u0066\u0061\u002f\u006e\u0073\u002f\u0070\u0072\u006f\u0070e\u0072\u0074\u0079\u0023",nil ); +ValueTypeNS =_fb .NewNamespace ("\u0070\u0064\u0066\u0061\u0054\u0079\u0070\u0065","\u0068\u0074\u0074\u0070\u003a\u002f/\u0077\u0077\u0077\u002e\u0061\u0069\u0069\u006d\u002e\u006f\u0072\u0067\u002fp\u0064\u0066\u0061\u002f\u006e\u0073\u002ft\u0079\u0070\u0065\u0023",nil ); +FieldNS =_fb .NewNamespace ("\u0070d\u0066\u0061\u0046\u0069\u0065\u006cd","\u0068\u0074\u0074p:\u002f\u002f\u0077\u0077\u0077\u002e\u0061\u0069\u0069m\u002eo\u0072g\u002fp\u0064\u0066\u0061\u002f\u006e\u0073\u002f\u0066\u0069\u0065\u006c\u0064\u0023",nil ); +); + +// Schema is the pdfa extension schema. +type Schema struct{ + +// NamespaceURI is schema namespace URI. +NamespaceURI string `xmp:"pdfaSchema:namespaceURI"`; + +// Prefix is preferred schema namespace prefix. +Prefix string `xmp:"pdfaSchema:prefix"`; + +// Schema is optional description. +Schema string `xmp:"pdfaSchema:schema"`; + +// Property is description of schema properties. +Property Properties `xmp:"pdfaSchema:property"`; + +// ValueType is description of schema-specific value types. +ValueType ValueTypes `xmp:"pdfaSchema:valueType"`;}; + +// MarshalText implements encoding.TextMarshaler interface. +func (_fc PropertyCategory )MarshalText ()([]byte ,error ){switch _fc {case PropertyCategoryInternal :return []byte ("\u0069\u006e\u0074\u0065\u0072\u006e\u0061\u006c"),nil ;case PropertyCategoryExternal :return []byte ("\u0065\u0078\u0074\u0065\u0072\u006e\u0061\u006c"),nil ; +case PropertyCategoryUndefined :return []byte (""),nil ;default:return nil ,_e .Errorf ("\u0075\u006ed\u0065\u0066\u0069\u006ee\u0064\u0020p\u0072\u006f\u0070\u0065\u0072\u0074\u0079\u0020c\u0061\u0074\u0065\u0067\u006f\u0072\u0079\u0020\u0076\u0061\u006c\u0075e\u003a\u0020\u0025\u0076",_fc ); +};}; + +// Typ gets the array type of properties. +func (_bfe Properties )Typ ()_fb .ArrayType {return _fb .ArrayTypeOrdered };var (_bec =map[string ]*Schema {};_gf _f .RWMutex ;); + +// ClosedChoiceValueTypeName gets the closed choice of provided value type name. +func ClosedChoiceValueTypeName (vt ValueTypeName )ValueTypeName {return "\u0043\u006c\u006f\u0073\u0065\u0064\u0020\u0043\u0068\u006f\u0069\u0063e\u0020\u006f\u0066\u0020"+vt ;}; + +// Can implements xmp.Model interface. +func (_ab *Model )Can (nsName string )bool {return Namespace .GetName ()==nsName }; + +// SyncToXMP implements xmp.Model interface. +func (_aag *Model )SyncToXMP (d *_fb .Document )error {return nil }; + +// IsZero checks if the resources list has no entries. +func (_edf Schemas )IsZero ()bool {return len (_edf )==0}; + +// UnmarshalXMP implements xmp.Unmarshaler interface. +func (_bad *Schemas )UnmarshalXMP (d *_fb .Decoder ,node *_fb .Node ,m _fb .Model )error {return _fb .UnmarshalArray (d ,node ,_bad .Typ (),_bad );}; + +// BagOfValueTypeName gets the ValueTypeName of the bag of provided value type names. +func BagOfValueTypeName (vt ValueTypeName )ValueTypeName {return "\u0062\u0061\u0067\u0020"+vt }; + +// MarshalXMP implements xmp.Marshaler interface. +func (_eb Properties )MarshalXMP (e *_fb .Encoder ,node *_fb .Node ,m _fb .Model )error {return _fb .MarshalArray (e ,node ,_eb .Typ (),_eb );}; + +// RegisterSchema registers schema extension definition. +func RegisterSchema (ns *_fb .Namespace ,schema *Schema ){_gf .Lock ();defer _gf .Unlock ();_bec [ns .URI ]=schema ;};const (ValueTypeResourceEvent ValueTypeName ="\u0052\u0065\u0073\u006f\u0075\u0072\u0063\u0065\u0045\u0076\u0065\u006e\u0074";); + +// SeqOfValueTypeName gets a value type name of a sequence of input value type names. +func SeqOfValueTypeName (vt ValueTypeName )ValueTypeName {return "\u0073\u0065\u0071\u0020"+vt };var PdfSchema =Schema {NamespaceURI :"\u0068\u0074\u0074\u0070:\u002f\u002f\u006e\u0073\u002e\u0061\u0064\u006f\u0062\u0065.\u0063o\u006d\u002f\u0070\u0064\u0066\u002f\u0031.\u0033\u002f",Prefix :"\u0070\u0064\u0066",Schema :"\u0041\u0064o\u0062\u0065\u0020P\u0044\u0046\u0020\u0053\u0063\u0068\u0065\u006d\u0061",Property :Properties {{Category :PropertyCategoryInternal ,Description :"\u004b\u0065\u0079\u0077\u006f\u0072\u0064\u0073",Name :"\u004b\u0065\u0079\u0077\u006f\u0072\u0064\u0073",ValueType :ValueTypeNameText },{Category :PropertyCategoryInternal ,Description :"\u0054\u0068\u0065\u0020\u0050\u0044F\u0020\u0066\u0069l\u0065\u0020\u0076e\u0072\u0073\u0069\u006f\u006e\u0020\u0028\u0066\u006f\u0072 \u0065\u0078\u0061\u006d\u0070le\u003a\u0020\u0031\u002e\u0030\u002c\u0020\u0031\u002e\u0033\u002c\u0020\u0061\u006e\u0064\u0020\u0073\u006f\u0020\u006f\u006e\u0029\u002e",Name :"\u0050\u0044\u0046\u0056\u0065\u0072\u0073\u0069\u006f\u006e",ValueType :ValueTypeNameText },{Category :PropertyCategoryInternal ,Description :"\u0054\u0068\u0065\u0020\u006ea\u006d\u0065\u0020\u006f\u0066\u0020\u0074\u0068\u0065\u0020\u0074\u006f\u006fl\u0020\u0074\u0068\u0061\u0074\u0020\u0063\u0072\u0065\u0061\u0074\u0065\u0064\u0020\u0074\u0068\u0065\u0020\u0050\u0044\u0046\u0020\u0064\u006f\u0063\u0075\u006d\u0065\u006e\u0074.",Name :"\u0050\u0072\u006f\u0064\u0075\u0063\u0065\u0072",ValueType :ValueTypeNameAgentName },{Category :PropertyCategoryInternal ,Description :"\u0049\u006e\u0064\u0069\u0063\u0061\u0074\u0065\u0073\u0020\u0074\u0068\u0061\u0074\u0020\u0074\u0068\u0069s\u0020\u0069\u0073\u0020\u0061\u0020\u0072i\u0067\u0068\u0074\u0073\u002d\u006d\u0061\u006e\u0061\u0067\u0065d\u0020\u0072\u0065\u0073\u006f\u0075\u0072\u0063\u0065\u002e\u002e",Name :"\u004d\u0061\u0072\u006b\u0065\u0064",ValueType :ValueTypeNameBoolean }}}; + + +// ValueType is the pdfa extension value type schema. +type ValueType struct{Description string `xmp:"pdfaType:description"`;Field []FieldValueType `xmp:"pdfaType:field"`;NamespaceURI string `xmp:"pdfaType:namespaceURI"`;Prefix string `xmp:"pdfaType:prefix"`;Type string `xmp:"pdfaType:type"`;}; + +// MarshalXMP implements xmp.Marshaler interface. +func (_gga ValueTypes )MarshalXMP (e *_fb .Encoder ,node *_fb .Node ,m _fb .Model )error {return _fb .MarshalArray (e ,node ,_gga .Typ (),_gga );}; + +// UnmarshalXMP implements xmp.Unmarshaler interface. +func (_gd *Properties )UnmarshalXMP (d *_fb .Decoder ,node *_fb .Node ,m _fb .Model )error {return _fb .UnmarshalArray (d ,node ,_gd .Typ (),_gd );};var XmpIDQualSchema =Schema {NamespaceURI :"\u0068t\u0074\u0070:\u002f\u002f\u006e\u0073.\u0061\u0064\u006fb\u0065\u002e\u0063\u006f\u006d\u002f\u0078\u006d\u0070/I\u0064\u0065\u006et\u0069\u0066i\u0065\u0072\u002f\u0071\u0075\u0061l\u002f\u0031.\u0030\u002f",Prefix :"\u0078\u006d\u0070\u0069\u0064\u0071",Schema :"X\u004dP\u0020\u0078\u006d\u0070\u0069\u0064\u0071\u0020q\u0075\u0061\u006c\u0069fi\u0065\u0072",Property :[]Property {{Category :PropertyCategoryInternal ,Name :"\u0053\u0063\u0068\u0065\u006d\u0065",Description :"\u0041\u0020\u0071\u0075\u0061\u006c\u0069\u0066\u0069\u0065\u0072\u0020\u0070\u0072o\u0076\u0069\u0064i\u006e\u0067\u0020\u0074h\u0065\u0020\u006e\u0020\u0061\u006d\u0065\u0020\u006f\u0066\u0020\u0074\u0068\u0065\u0020\u0066\u006f\u0072\u006d\u0061\u006c \u0069\u0064\u0065n\u0074\u0069\u0066\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u0020\u0073\u0063\u0068\u0065\u006d\u0065\u0020\u0075\u0073ed\u0020\u0066\u006fr\u0020\u0061\u006e\u0020\u0069\u0074\u0065\u006d \u0069\u006e\u0020\u0074\u0068\u0065\u0020\u0078\u006d\u0070\u003a\u0049\u0064\u0065\u006e\u0074\u0069\u0066\u0069\u0065\u0072\u0020\u0061\u0072\u0072\u0061\u0079\u002e",ValueType :ValueTypeNameText }},ValueType :nil }; + + +// Property is a schema that describes single property. +type Property struct{ + +// Category is the property category. +Category PropertyCategory `xmp:"pdfaProperty:category"`; + +// Description of the property. +Description string `xmp:"pdfaProperty:description"`; + +// Name is a property name. +Name string `xmp:"pdfaProperty:name"`; + +// ValueType is the property value type. +ValueType ValueTypeName `xmp:"pdfaProperty:valueType"`;};const (ValueTypeNameBoolean ValueTypeName ="\u0042o\u006f\u006c\u0065\u0061\u006e";ValueTypeNameDate ValueTypeName ="\u0044\u0061\u0074\u0065";ValueTypeNameInteger ValueTypeName ="\u0049n\u0074\u0065\u0067\u0065\u0072"; +ValueTypeNameReal ValueTypeName ="\u0052\u0065\u0061\u006c";ValueTypeNameText ValueTypeName ="\u0054\u0065\u0078\u0074";ValueTypeNameAgentName ValueTypeName ="\u0041g\u0065\u006e\u0074\u004e\u0061\u006de";ValueTypeNameProperName ValueTypeName ="\u0050\u0072\u006f\u0070\u0065\u0072\u004e\u0061\u006d\u0065"; +ValueTypeNameXPath ValueTypeName ="\u0058\u0050\u0061t\u0068";ValueTypeNameGUID ValueTypeName ="\u0047\u0055\u0049\u0044";ValueTypeNameLocale ValueTypeName ="\u004c\u006f\u0063\u0061\u006c\u0065";ValueTypeNameMIMEType ValueTypeName ="\u004d\u0049\u004d\u0045\u0054\u0079\u0070\u0065"; +ValueTypeNameRenditionClass ValueTypeName ="\u0052\u0065\u006e\u0064\u0069\u0074\u0069\u006f\u006eC\u006c\u0061\u0073\u0073";ValueTypeNameResourceRef ValueTypeName ="R\u0065\u0073\u006f\u0075\u0072\u0063\u0065\u0052\u0065\u0066";ValueTypeNameURL ValueTypeName ="\u0055\u0052\u004c"; +ValueTypeNameURI ValueTypeName ="\u0055\u0052\u0049";ValueTypeNameVersion ValueTypeName ="\u0056e\u0072\u0073\u0069\u006f\u006e";); + +// NewModel creates a new pdfAExtension model. +func NewModel (name string )_fb .Model {return &Model {}}; + +// GetTag implements xmp.Model interface. +func (_gaa *Model )GetTag (tag string )(string ,error ){_ge ,_aad :=_fb .GetNativeField (_gaa ,tag );if _aad !=nil {return "",_e .Errorf ("\u0025\u0073\u003a\u0020\u0025\u0076",Namespace .GetName (),_aad );};return _ge ,nil ;}; + +// FillModel fills in the document XMP model. +func FillModel (d *_fb .Document ,extModel *Model )error {var _db []*_fb .Namespace ;for _ ,_dg :=range d .Namespaces (){_db =append (_db ,_dg );};_bc .Slice (_db ,func (_be ,_cd int )bool {return _db [_be ].Name < _db [_cd ].Name });for _ ,_bg :=range _db {switch _bg {case Namespace ,SchemaNS ,PropertyNS ,ValueTypeNS ,FieldNS ,_ga .NsXmp ,_g .NsDc :continue ; +default:_cf ,_da :=GetSchema (_bg .URI );if !_da {continue ;};_fd :=d .FindModel (_bg );_bcf :=*_cf ;_bcf .Property =Properties {};for _ ,_fda :=range _cf .Property {_ed :=_ee (_fd ,_bg ,_fda );if _ed {_bcf .Property =append (_bcf .Property ,_fda );};}; +if len (_bcf .Property )==0{continue ;};var _cb bool ;for _daa ,_dbf :=range extModel .Schemas {if _dbf .Schema ==_bcf .Schema {_cb =true ;extModel .Schemas [_daa ]=_bcf ;break ;};};if !_cb {extModel .Schemas =append (extModel .Schemas ,_bcf );};};};return nil ; +}; + +// UnmarshalXMP implements xmp.Unmarshaler interface. +func (_eaf *ValueTypes )UnmarshalXMP (d *_fb .Decoder ,node *_fb .Node ,m _fb .Model )error {return _fb .UnmarshalArray (d ,node ,_eaf .Typ (),_eaf );}; + +// FieldValueType is a schema that describes a field in a structured type. +type FieldValueType struct{Name string `xmp:"pdfaField:description"`;Description string `xmp:"pdfaField:name"`;ValueType ValueTypeName `xmp:"pdfaField:valueType"`;};var FieldResourceEventSchema =Schema {NamespaceURI :"\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u006es\u002e\u0061\u0064ob\u0065\u002e\u0063\u006f\u006d\u002fx\u0061\u0070\u002f\u0031\u002e\u0030\u002f\u0073\u0054\u0079\u0070\u0065\u002f\u0052\u0065s\u006f\u0075\u0072\u0063\u0065\u0045\u0076\u0065n\u0074\u0023",Prefix :"\u0073\u0074\u0045v\u0074",Schema :"\u0044e\u0066\u0069n\u0069\u0074\u0069\u006fn\u0020\u006f\u0066 \u0062\u0061\u0073\u0069\u0063\u0020\u0076\u0061\u006cue\u0020\u0074\u0079p\u0065\u0020R\u0065\u0073\u006f\u0075\u0072\u0063e\u0045\u0076e\u006e\u0074",Property :[]Property {{Category :PropertyCategoryInternal ,Description :"\u0054he\u0020a\u0063t\u0069\u006f\u006e\u0020\u0074\u0068a\u0074\u0020\u006f\u0063c\u0075\u0072\u0072\u0065\u0064\u002e\u0020\u0044\u0065\u0066\u0069\u006e\u0065d \u0076\u0061\u006c\u0075\u0065\u0073\u0020\u0061\u0072\u0065\u003a\u0020\u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0065d\u002c \u0063\u006f\u0070\u0069\u0065\u0064\u002c\u0020\u0063\u0072\u0065\u0061\u0074e\u0064\u002c \u0063\u0072\u006fp\u0070\u0065\u0064\u002c\u0020\u0065\u0064\u0069\u0074ed\u002c\u0020\u0066i\u006c\u002d\u0074\u0065r\u0065\u0064\u002c\u0020\u0066\u006fr\u006d\u0061t\u0074\u0065\u0064\u002c\u0020\u0076\u0065\u0072s\u0069\u006f\u006e\u005f\u0075\u0070\u0064\u0061\u0074\u0065\u0064\u002c\u0020\u0070\u0072\u0069\u006e\u0074\u0065\u0064\u002c\u0020\u0070ubli\u0073\u0068\u0065\u0064\u002c\u0020\u006d\u0061\u006e\u0061\u0067\u0065\u0064\u002c\u0020\u0070\u0072\u006f\u0064\u0075\u0063\u0065\u0064\u002c\u0020\u0072\u0065\u0073i\u007ae\u0064.\u004e\u0065\u0077\u0020\u0076\u0061\u006c\u0075\u0065\u0073\u0020\u0073\u0068\u006f\u0075\u006c\u0064\u0020\u0062\u0065 \u0076\u0065r\u0062\u0073 \u0069n\u0020\u0074\u0068\u0065\u0020\u0070a\u0073\u0074\u0020\u0074\u0065\u006e\u0073\u0065\u002e",Name :"\u0061\u0063\u0074\u0069\u006f\u006e",ValueType :"O\u0070\u0065\u006e\u0020\u0043\u0068\u006f\u0069\u0063\u0065"},{Category :PropertyCategoryInternal ,Description :"T\u0068\u0065\u0020\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0020\u0049\u0044\u0020\u006f\u0066\u0020t\u0068\u0065\u0020\u006d\u006f\u0064\u0069\u0066\u0069\u0065d \u0072\u0065\u0073o\u0075r\u0063\u0065",Name :"\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0049\u0044",ValueType :ValueTypeNameURI },{Category :PropertyCategoryInternal ,Description :"\u0041\u0064di\u0074\u0069\u006fn\u0061\u006c\u0020\u0064esc\u0072ip\u0074\u0069\u006f\u006e\u0020\u006f\u0066 t\u0068\u0065\u0020\u0061\u0063\u0074\u0069o\u006e",Name :"\u0070\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u0073",ValueType :ValueTypeNameText },{Category :PropertyCategoryInternal ,Description :"\u0054h\u0065\u0020s\u006f\u0066\u0074\u0077a\u0072\u0065\u0020a\u0067\u0065\u006e\u0074\u0020\u0074\u0068\u0061\u0074 p\u0065\u0072\u0066o\u0072\u006de\u0064\u0020\u0074\u0068\u0065\u0020a\u0063\u0074i\u006f\u006e",Name :"\u0073\u006f\u0066\u0074\u0077\u0061\u0072\u0065\u0041\u0067\u0065\u006e\u0074",ValueType :ValueTypeNameAgentName },{Category :PropertyCategoryInternal ,Description :"\u004f\u0070t\u0069\u006f\u006e\u0061\u006c\u0020\u0074\u0069\u006d\u0065\u0073\u0074\u0061\u006d\u0070\u0020\u006f\u0066\u0020\u0077\u0068\u0065\u006e\u0020\u0074\u0068\u0065\u0020\u0061\u0063\u0074\u0069\u006f\u006e\u0020\u006f\u0063\u0063\u0075\u0072\u0072\u0065\u0064",Name :"\u0077\u0068\u0065\u006e",ValueType :ValueTypeNameDate }},ValueType :nil }; + + +// MakeModel creates or gets a model from document. +func MakeModel (d *_fb .Document )(*Model ,error ){_df ,_fg :=d .MakeModel (Namespace );if _fg !=nil {return nil ,_fg ;};return _df .(*Model ),nil ;}; + +// MarshalXMP implements xmp.Marshaler interface. +func (_bfc Schemas )MarshalXMP (e *_fb .Encoder ,node *_fb .Node ,m _fb .Model )error {return _fb .MarshalArray (e ,node ,_bfc .Typ (),_bfc );}; + +// Model is the pdfa extension metadata model. +type Model struct{Schemas Schemas `xmp:"pdfaExtension:schemas"`;}; + +// ValueTypeName is the name of the value type. +type ValueTypeName string ; + +// Namespaces implements xmp.Model interface. +func (_fgd *Model )Namespaces ()_fb .NamespaceList {return _fb .NamespaceList {Namespace }}; + +// PropertyCategory is the property category enumerator. +type PropertyCategory int ;
\ No newline at end of file diff --git a/unipdf/model/xmputil/pdfaid/pdfaid.go b/unipdf/model/xmputil/pdfaid/pdfaid.go new file mode 100644 index 0000000..9a3d166 --- /dev/null +++ b/unipdf/model/xmputil/pdfaid/pdfaid.go @@ -0,0 +1,48 @@ +// +// Copyright 2020 FoxyUtils ehf. All rights reserved. +// +// This is a commercial product and requires a license to operate. +// A trial license can be obtained at https://unidoc.io +// +// DO NOT EDIT: generated by unitwist Go source code obfuscator. +// +// Use of this source code is governed by the UniDoc End User License Agreement +// terms that can be accessed at https://unidoc.io/eula/ + +package pdfaid ;import (_e "fmt";_ea "github.com/trimmer-io/go-xmp/xmp";_g "github.com/unidoc/unipdf/v4/model/xmputil/pdfaextension";); + +// SetTag implements xmp.Model interface. +func (_aa *Model )SetTag (tag ,value string )error {if _f :=_ea .SetNativeField (_aa ,tag ,value );_f !=nil {return _e .Errorf ("\u0025\u0073\u003a\u0020\u0025\u0076",Namespace .GetName (),_f );};return nil ;};func init (){_ea .Register (Namespace ,_ea .XmpMetadata ); +_g .RegisterSchema (Namespace ,&Schema )}; + +// MakeModel gets or create sa new model for PDF/A ID namespace. +func MakeModel (d *_ea .Document )(*Model ,error ){_gg ,_ef :=d .MakeModel (Namespace );if _ef !=nil {return nil ,_ef ;};return _gg .(*Model ),nil ;}; + +// Namespaces implements xmp.Model interface. +func (_eae *Model )Namespaces ()_ea .NamespaceList {return _ea .NamespaceList {Namespace }}; + +// SyncToXMP implements xmp.Model interface. +func (_cf *Model )SyncToXMP (d *_ea .Document )error {return nil }; + +// SyncModel implements xmp.Model interface. +func (_b *Model )SyncModel (d *_ea .Document )error {return nil };var Schema =_g .Schema {NamespaceURI :Namespace .URI ,Prefix :Namespace .Name ,Schema :"\u0050D\u0046/\u0041\u0020\u0049\u0044\u0020\u0053\u0063\u0068\u0065\u006d\u0061",Property :[]_g .Property {{Category :_g .PropertyCategoryInternal ,Description :"\u0050\u0061\u0072\u0074 o\u0066\u0020\u0050\u0044\u0046\u002f\u0041\u0020\u0073\u0074\u0061\u006e\u0064\u0061r\u0064",Name :"\u0070\u0061\u0072\u0074",ValueType :_g .ValueTypeNameInteger },{Category :_g .PropertyCategoryInternal ,Description :"A\u006d\u0065\u006e\u0064\u006d\u0065n\u0074\u0020\u006f\u0066\u0020\u0050\u0044\u0046\u002fA\u0020\u0073\u0074a\u006ed\u0061\u0072\u0064",Name :"\u0061\u006d\u0064",ValueType :_g .ValueTypeNameText },{Category :_g .PropertyCategoryInternal ,Description :"C\u006f\u006e\u0066\u006f\u0072\u006da\u006e\u0063\u0065\u0020\u006c\u0065v\u0065\u006c\u0020\u006f\u0066\u0020\u0050D\u0046\u002f\u0041\u0020\u0073\u0074\u0061\u006e\u0064\u0061r\u0064",Name :"c\u006f\u006e\u0066\u006f\u0072\u006d\u0061\u006e\u0063\u0065",ValueType :_g .ValueTypeNameText }},ValueType :nil }; + + +// Can implements xmp.Model interface. +func (_gc *Model )Can (nsName string )bool {return Namespace .GetName ()==nsName };var Namespace =_ea .NewNamespace ("\u0070\u0064\u0066\u0061\u0069\u0064","\u0068\u0074\u0074p\u003a\u002f\u002f\u0077w\u0077\u002e\u0061\u0069\u0069\u006d\u002eo\u0072\u0067\u002f\u0070\u0064\u0066\u0061\u002f\u006e\u0073\u002f\u0069\u0064\u002f",NewModel ); + + +// GetTag implements xmp.Model interface. +func (_ec *Model )GetTag (tag string )(string ,error ){_dee ,_cfg :=_ea .GetNativeField (_ec ,tag );if _cfg !=nil {return "",_e .Errorf ("\u0025\u0073\u003a\u0020\u0025\u0076",Namespace .GetName (),_cfg );};return _dee ,nil ;}; + +// NewModel creates a new model. +func NewModel (name string )_ea .Model {return &Model {}};var _ _ea .Model =(*Model )(nil ); + +// Model is the XMP model for the PdfA metadata. +type Model struct{Part int `xmp:"pdfaid:part"`;Conformance string `xmp:"pdfaid:conformance"`;}; + +// SyncFromXMP implements xmp.Model interface. +func (_cg *Model )SyncFromXMP (d *_ea .Document )error {return nil }; + +// CanTag implements xmp.Model interface. +func (_a *Model )CanTag (tag string )bool {_ ,_efb :=_ea .GetNativeField (_a ,tag );return _efb ==nil };
\ No newline at end of file diff --git a/unipdf/model/xmputil/xmputil.go b/unipdf/model/xmputil/xmputil.go new file mode 100644 index 0000000..fbc6bc3 --- /dev/null +++ b/unipdf/model/xmputil/xmputil.go @@ -0,0 +1,193 @@ +// +// Copyright 2020 FoxyUtils ehf. All rights reserved. +// +// This is a commercial product and requires a license to operate. +// A trial license can be obtained at https://unidoc.io +// +// DO NOT EDIT: generated by unitwist Go source code obfuscator. +// +// Use of this source code is governed by the UniDoc End User License Agreement +// terms that can be accessed at https://unidoc.io/eula/ + +// Package xmputil provides abstraction used by the pdf document XMP Metadata. +package xmputil ;import (_cc "errors";_af "fmt";_g "github.com/trimmer-io/go-xmp/models/pdf";_e "github.com/trimmer-io/go-xmp/models/xmp_base";_d "github.com/trimmer-io/go-xmp/models/xmp_mm";_a "github.com/trimmer-io/go-xmp/xmp";_bfg "github.com/unidoc/unipdf/v4/core"; +_fe "github.com/unidoc/unipdf/v4/internal/timeutils";_bf "github.com/unidoc/unipdf/v4/internal/uuid";_f "github.com/unidoc/unipdf/v4/model/xmputil/pdfaextension";_fa "github.com/unidoc/unipdf/v4/model/xmputil/pdfaid";_c "strconv";_bd "time";); + +// PdfInfoOptions are the options used for setting pdf info. +type PdfInfoOptions struct{InfoDict _bfg .PdfObject ;PdfVersion string ;Copyright string ;Marked bool ; + +// Overwrite if set to true, overwrites all values found in the current pdf info xmp model to the ones provided. +Overwrite bool ;}; + +// MediaManagementVersion is the version of the media management xmp metadata. +type MediaManagementVersion struct{VersionID string ;ModifyDate _bd .Time ;Comments string ;Modifier string ;}; + +// MarshalIndent the document into xml byte stream with predefined prefix and indent. +func (_gc *Document )MarshalIndent (prefix ,indent string )([]byte ,error ){if _gc ._df .IsDirty (){if _ad :=_gc ._df .SyncModels ();_ad !=nil {return nil ,_ad ;};};return _a .MarshalIndent (_gc ._df ,prefix ,indent );}; + +// NewDocument creates a new document without any previous xmp information. +func NewDocument ()*Document {_ee :=_a .NewDocument ();return &Document {_df :_ee }}; + +// SetMediaManagement sets up XMP media management metadata: namespace xmpMM. +func (_ef *Document )SetMediaManagement (options *MediaManagementOptions )error {_fg ,_ab :=_d .MakeModel (_ef ._df );if _ab !=nil {return _ab ;};if options ==nil {options =new (MediaManagementOptions );};_fee :=_d .ResourceRef {};switch {case options .DocumentID !="":_fg .DocumentID =_a .GUID (options .DocumentID ); +case options .NewDocumentID ||_fg .DocumentID .IsZero ():if !_fg .DocumentID .IsZero (){_fee .DocumentID =_fg .DocumentID ;};_ec ,_ac :=_bf .NewUUID ();if _ac !=nil {return _ac ;};_fg .DocumentID =_a .GUID (_ec .String ());};if !_fg .InstanceID .IsZero (){_fee .InstanceID =_fg .InstanceID ; +};_fg .InstanceID =_a .GUID (options .InstanceID );if _fg .InstanceID ==""{_eag ,_bdc :=_bf .NewUUID ();if _bdc !=nil {return _bdc ;};_fg .InstanceID =_a .GUID (_eag .String ());};if !_fee .IsZero (){_fg .DerivedFrom =&_fee ;};_ba :=options .VersionID ; +if _fg .VersionID !=""{_db ,_afd :=_c .Atoi (_fg .VersionID );if _afd !=nil {_ba =_c .Itoa (len (_fg .Versions )+1);}else {_ba =_c .Itoa (_db +1);};};if _ba ==""{_ba ="\u0031";};_fg .VersionID =_ba ;if _ab =_fg .SyncToXMP (_ef ._df );_ab !=nil {return _ab ; +};return nil ;}; + +// GetPdfaExtensionSchemas gets a pdfa extension schemas. +func (_eb *Document )GetPdfaExtensionSchemas ()([]_f .Schema ,error ){_cgb :=_eb ._df .FindModel (_f .Namespace );if _cgb ==nil {return nil ,nil ;};_eec ,_ae :=_cgb .(*_f .Model );if !_ae {return nil ,_af .Errorf ("\u0069\u006eva\u006c\u0069\u0064 \u006d\u006f\u0064\u0065l f\u006fr \u0070\u0064\u0066\u0061\u0045\u0078\u0074en\u0073\u0069\u006f\u006e\u0073\u003a\u0020%\u0054",_cgb ); +};return _eec .Schemas ,nil ;}; + +// MediaManagementDerivedFrom is a structure that contains references of identifiers and versions +// from which given document was derived. +type MediaManagementDerivedFrom struct{OriginalDocumentID GUID ;DocumentID GUID ;InstanceID GUID ;VersionID string ;}; + +// GetMediaManagement gets the media management metadata from provided xmp document. +func (_fgd *Document )GetMediaManagement ()(*MediaManagement ,bool ){_cd :=_d .FindModel (_fgd ._df );if _cd ==nil {return nil ,false ;};_gef :=make ([]MediaManagementVersion ,len (_cd .Versions ));for _bdg ,_abc :=range _cd .Versions {_gef [_bdg ]=MediaManagementVersion {VersionID :_abc .Version ,ModifyDate :_abc .ModifyDate .Value (),Comments :_abc .Comments ,Modifier :_abc .Modifier }; +};_dbb :=&MediaManagement {OriginalDocumentID :GUID (_cd .OriginalDocumentID .Value ()),DocumentID :GUID (_cd .DocumentID .Value ()),InstanceID :GUID (_cd .InstanceID .Value ()),VersionID :_cd .VersionID ,Versions :_gef };if _cd .DerivedFrom !=nil {_dbb .DerivedFrom =&MediaManagementDerivedFrom {OriginalDocumentID :GUID (_cd .DerivedFrom .OriginalDocumentID ),DocumentID :GUID (_cd .DerivedFrom .DocumentID ),InstanceID :GUID (_cd .DerivedFrom .InstanceID ),VersionID :_cd .DerivedFrom .VersionID }; +};return _dbb ,true ;}; + +// GetGoXmpDocument gets direct access to the go-xmp.Document. +// All changes done to specified document would result in change of this document 'd'. +func (_gd *Document )GetGoXmpDocument ()*_a .Document {return _gd ._df }; + +// MediaManagement are the values from the document media management metadata. +type MediaManagement struct{ + +// OriginalDocumentID as media is imported and projects is started, an original-document ID +// must be created to identify a new document. This identifies a document as a conceptual entity. +OriginalDocumentID GUID ; + +// DocumentID when a document is copied to a new file path or converted to a new format with +// Save As, another new document ID should usually be assigned. This identifies a general version or +// branch of a document. You can use it to track different versions or extracted portions of a document +// with the same original-document ID. +DocumentID GUID ; + +// InstanceID to track a document’s editing history, you must assign a new instance ID +// whenever a document is saved after any changes. This uniquely identifies an exact version of a +// document. It is used in resource references (to identify both the document or part itself and the +// referenced or referencing documents), and in document-history resource events (to identify the +// document instance that resulted from the change). +InstanceID GUID ; + +// DerivedFrom references the source document from which this one is derived, +// typically through a Save As operation that changes the file name or format. It is a minimal reference; +// missing components can be assumed to be unchanged. For example, a new version might only need +// to specify the instance ID and version number of the previous version, or a rendition might only need +// to specify the instance ID and rendition class of the original. +DerivedFrom *MediaManagementDerivedFrom ; + +// VersionID are meant to associate the document with a product version that is part of a release process. They can be useful in tracking the +// document history, but should not be used to identify a document uniquely in any context. +// Usually it simply works by incrementing integers 1,2,3... +VersionID string ; + +// Versions is the history of the document versions along with the comments, timestamps and issuers. +Versions []MediaManagementVersion ;}; + +// MediaManagementOptions are the options for the Media management xmp metadata. +type MediaManagementOptions struct{ + +// OriginalDocumentID as media is imported and projects is started, an original-document ID +// must be created to identify a new document. This identifies a document as a conceptual entity. +// By default, this value is generated. +OriginalDocumentID string ; + +// NewDocumentID is a flag which generates a new Document identifier while setting media management. +// This value should be set to true only if the document is stored and saved as new document. +// Otherwise, if the document is modified and overwrites previous file, it should be set to false. +NewDocumentID bool ; + +// DocumentID when a document is copied to a new file path or converted to a new format with +// Save As, another new document ID should usually be assigned. This identifies a general version or +// branch of a document. You can use it to track different versions or extracted portions of a document +// with the same original-document ID. +// By default, this value is generated if NewDocumentID is true or previous doesn't exist. +DocumentID string ; + +// InstanceID to track a document’s editing history, you must assign a new instance ID +// whenever a document is saved after any changes. This uniquely identifies an exact version of a +// document. It is used in resource references (to identify both the document or part itself and the +// referenced or referencing documents), and in document-history resource events (to identify the +// document instance that resulted from the change). +// By default, this value is generated. +InstanceID string ; + +// DerivedFrom references the source document from which this one is derived, +// typically through a Save As operation that changes the file name or format. It is a minimal reference; +// missing components can be assumed to be unchanged. For example, a new version might only need +// to specify the instance ID and version number of the previous version, or a rendition might only need +// to specify the instance ID and rendition class of the original. +// By default, the derived from structure is filled from previous XMP metadata (if exists). +DerivedFrom string ; + +// VersionID are meant to associate the document with a product version that is part of a release process. They can be useful in tracking the +// document history, but should not be used to identify a document uniquely in any context. +// Usually it simply works by incrementing integers 1,2,3... +// By default, this values is incremented or set to the next version number. +VersionID string ; + +// ModifyComment is a comment to given modification +ModifyComment string ; + +// ModifyDate is a custom modification date for the versions. +// By default, this would be set to time.Now(). +ModifyDate _bd .Time ; + +// Modifier is a person who did the modification. +Modifier string ;}; + +// Document is an implementation of the xmp document. +// It is a wrapper over go-xmp/xmp.Document that provides some Pdf predefined functionality. +type Document struct{_df *_a .Document }; + +// SetPdfAID sets up pdfaid xmp metadata. +// In example: Part: '1' Conformance: 'B' states for PDF/A 1B. +func (_aab *Document )SetPdfAID (part int ,conformance string )error {_cf ,_ff :=_fa .MakeModel (_aab ._df );if _ff !=nil {return _ff ;};_cf .Part =part ;_cf .Conformance =conformance ;if _gbd :=_cf .SyncToXMP (_aab ._df );_gbd !=nil {return _gbd ;};return nil ; +}; + +// GetPdfInfo gets the document pdf info. +func (_fd *Document )GetPdfInfo ()(*PdfInfo ,bool ){_dee :=PdfInfo {};var _egf *_bfg .PdfObjectDictionary ;_edg :=func (_dc string ,_fac _bfg .PdfObject ){if _egf ==nil {_egf =_bfg .MakeDict ();};_egf .Set (_bfg .PdfObjectName (_dc ),_fac );};_ea ,_ced :=_fd ._df .FindModel (_g .NsPDF ).(*_g .PDFInfo ); +if !_ced {_dfe ,_bb :=_fd ._df .FindModel (_e .NsXmp ).(*_e .XmpBase );if !_bb {return nil ,false ;};if _dfe .CreatorTool !=""{_edg ("\u0043r\u0065\u0061\u0074\u006f\u0072",_bfg .MakeString (string (_dfe .CreatorTool )));};if !_dfe .CreateDate .IsZero (){_edg ("\u0043\u0072\u0065a\u0074\u0069\u006f\u006e\u0044\u0061\u0074\u0065",_bfg .MakeString (_fe .FormatPdfTime (_dfe .CreateDate .Value ()))); +};if !_dfe .ModifyDate .IsZero (){_edg ("\u004do\u0064\u0044\u0061\u0074\u0065",_bfg .MakeString (_fe .FormatPdfTime (_dfe .ModifyDate .Value ())));};_dee .InfoDict =_egf ;return &_dee ,true ;};_dee .Copyright =_ea .Copyright ;_dee .PdfVersion =_ea .PDFVersion ; +_dee .Marked =bool (_ea .Marked );if len (_ea .Title )> 0{_edg ("\u0054\u0069\u0074l\u0065",_bfg .MakeString (_ea .Title .Default ()));};if len (_ea .Author )> 0{_edg ("\u0041\u0075\u0074\u0068\u006f\u0072",_bfg .MakeString (_ea .Author [0]));};if _ea .Keywords !=""{_edg ("\u004b\u0065\u0079\u0077\u006f\u0072\u0064\u0073",_bfg .MakeString (_ea .Keywords )); +};if len (_ea .Subject )> 0{_edg ("\u0053u\u0062\u006a\u0065\u0063\u0074",_bfg .MakeString (_ea .Subject .Default ()));};if _ea .Creator !=""{_edg ("\u0043r\u0065\u0061\u0074\u006f\u0072",_bfg .MakeString (string (_ea .Creator )));};if _ea .Producer !=""{_edg ("\u0050\u0072\u006f\u0064\u0075\u0063\u0065\u0072",_bfg .MakeString (string (_ea .Producer ))); +};if _ea .Trapped {_edg ("\u0054r\u0061\u0070\u0070\u0065\u0064",_bfg .MakeName ("\u0054\u0072\u0075\u0065"));};if !_ea .CreationDate .IsZero (){_edg ("\u0043\u0072\u0065a\u0074\u0069\u006f\u006e\u0044\u0061\u0074\u0065",_bfg .MakeString (_fe .FormatPdfTime (_ea .CreationDate .Value ()))); +};if !_ea .ModifyDate .IsZero (){_edg ("\u004do\u0064\u0044\u0061\u0074\u0065",_bfg .MakeString (_fe .FormatPdfTime (_ea .ModifyDate .Value ())));};_dee .InfoDict =_egf ;return &_dee ,true ;}; + +// PdfAID is the result of the XMP pdfaid metadata. +type PdfAID struct{Part int ;Conformance string ;}; + +// LoadDocument loads up the xmp document from provided input stream. +func LoadDocument (stream []byte )(*Document ,error ){_cg :=_a .NewDocument ();if _gb :=_a .Unmarshal (stream ,_cg );_gb !=nil {return nil ,_gb ;};return &Document {_df :_cg },nil ;}; + +// GUID is a string representing a globally unique identifier. +type GUID string ; + +// GetPdfAID gets the pdfaid xmp metadata model. +func (_geb *Document )GetPdfAID ()(*PdfAID ,bool ){_cea ,_daa :=_geb ._df .FindModel (_fa .Namespace ).(*_fa .Model );if !_daa {return nil ,false ;};return &PdfAID {Part :_cea .Part ,Conformance :_cea .Conformance },true ;}; + +// SetPdfInfo sets the pdf info into selected document. +func (_gde *Document )SetPdfInfo (options *PdfInfoOptions )error {if options ==nil {return _cc .New ("\u006ei\u006c\u0020\u0070\u0064\u0066\u0020\u006f\u0070\u0074\u0069\u006fn\u0073\u0020\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064");};_aa ,_ed :=_g .MakeModel (_gde ._df ); +if _ed !=nil {return _ed ;};if options .Overwrite {*_aa =_g .PDFInfo {};};if options .InfoDict !=nil {_fc ,_bc :=_bfg .GetDict (options .InfoDict );if !_bc {return _af .Errorf ("i\u006e\u0076\u0061\u006c\u0069\u0064 \u0070\u0064\u0066\u0020\u006f\u0062\u006a\u0065\u0063t\u0020\u0074\u0079p\u0065:\u0020\u0025\u0054",options .InfoDict ); +};var _cgg *_bfg .PdfObjectString ;for _ ,_ge :=range _fc .Keys (){switch _ge {case "\u0054\u0069\u0074l\u0065":_cgg ,_bc =_bfg .GetString (_fc .Get ("\u0054\u0069\u0074l\u0065"));if _bc {_aa .Title =_a .NewAltString (_cgg );};case "\u0041\u0075\u0074\u0068\u006f\u0072":_cgg ,_bc =_bfg .GetString (_fc .Get ("\u0041\u0075\u0074\u0068\u006f\u0072")); +if _bc {_aa .Author =_a .NewStringList (_cgg .String ());};case "\u004b\u0065\u0079\u0077\u006f\u0072\u0064\u0073":_cgg ,_bc =_bfg .GetString (_fc .Get ("\u004b\u0065\u0079\u0077\u006f\u0072\u0064\u0073"));if _bc {_aa .Keywords =_cgg .String ();};case "\u0043r\u0065\u0061\u0074\u006f\u0072":_cgg ,_bc =_bfg .GetString (_fc .Get ("\u0043r\u0065\u0061\u0074\u006f\u0072")); +if _bc {_aa .Creator =_a .AgentName (_cgg .String ());};case "\u0053u\u0062\u006a\u0065\u0063\u0074":_cgg ,_bc =_bfg .GetString (_fc .Get ("\u0053u\u0062\u006a\u0065\u0063\u0074"));if _bc {_aa .Subject =_a .NewAltString (_cgg .String ());};case "\u0050\u0072\u006f\u0064\u0075\u0063\u0065\u0072":_cgg ,_bc =_bfg .GetString (_fc .Get ("\u0050\u0072\u006f\u0064\u0075\u0063\u0065\u0072")); +if _bc {_aa .Producer =_a .AgentName (_cgg .String ());};case "\u0054r\u0061\u0070\u0070\u0065\u0064":_de ,_ggg :=_bfg .GetName (_fc .Get ("\u0054r\u0061\u0070\u0070\u0065\u0064"));if _ggg {switch _de .String (){case "\u0054\u0072\u0075\u0065":_aa .Trapped =true ; +case "\u0046\u0061\u006cs\u0065":_aa .Trapped =false ;default:_aa .Trapped =true ;};};case "\u0043\u0072\u0065a\u0074\u0069\u006f\u006e\u0044\u0061\u0074\u0065":if _ce ,_bg :=_bfg .GetString (_fc .Get ("\u0043\u0072\u0065a\u0074\u0069\u006f\u006e\u0044\u0061\u0074\u0065")); +_bg &&_ce .String ()!=""{_da ,_cggd :=_fe .ParsePdfTime (_ce .String ());if _cggd !=nil {return _af .Errorf ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0043\u0072e\u0061\u0074\u0069\u006f\u006e\u0044\u0061t\u0065\u0020\u0066\u0069\u0065\u006c\u0064\u003a\u0020\u0025\u0077",_cggd ); +};_aa .CreationDate =_a .NewDate (_da );};case "\u004do\u0064\u0044\u0061\u0074\u0065":if _ade ,_cgf :=_bfg .GetString (_fc .Get ("\u004do\u0064\u0044\u0061\u0074\u0065"));_cgf &&_ade .String ()!=""{_eg ,_dfdd :=_fe .ParsePdfTime (_ade .String ());if _dfdd !=nil {return _af .Errorf ("\u0069n\u0076\u0061\u006c\u0069d\u0020\u004d\u006f\u0064\u0044a\u0074e\u0020f\u0069\u0065\u006c\u0064\u003a\u0020\u0025w",_dfdd ); +};_aa .ModifyDate =_a .NewDate (_eg );};};};};if options .PdfVersion !=""{_aa .PDFVersion =options .PdfVersion ;};if options .Marked {_aa .Marked =_a .Bool (options .Marked );};if options .Copyright !=""{_aa .Copyright =options .Copyright ;};if _ed =_aa .SyncToXMP (_gde ._df ); +_ed !=nil {return _ed ;};return nil ;}; + +// PdfInfo is the xmp document pdf info. +type PdfInfo struct{InfoDict _bfg .PdfObject ;PdfVersion string ;Copyright string ;Marked bool ;}; + +// SetPdfAExtension sets the pdfaExtension XMP metadata. +func (_dfa *Document )SetPdfAExtension ()error {_dfd ,_ca :=_f .MakeModel (_dfa ._df );if _ca !=nil {return _ca ;};if _ca =_f .FillModel (_dfa ._df ,_dfd );_ca !=nil {return _ca ;};if _ca =_dfd .SyncToXMP (_dfa ._df );_ca !=nil {return _ca ;};return nil ; +}; + +// Marshal the document into xml byte stream. +func (_dg *Document )Marshal ()([]byte ,error ){if _dg ._df .IsDirty (){if _gg :=_dg ._df .SyncModels ();_gg !=nil {return nil ,_gg ;};};return _a .Marshal (_dg ._df );};
\ No newline at end of file |
