2021-09-23 22:37:42 +00:00

192 lines
14 KiB
Go

//
// 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 xmp ;import (_c "bytes";_f "encoding/hex";_cc "fmt";_cb "github.com/unidoc/unipdf/v3/common";_d "github.com/unidoc/unipdf/v3/core";_fa "github.com/unidoc/unipdf/v3/internal/timeutils";_gg "github.com/unidoc/unipdf/v3/internal/uuid";_gd "strconv";
_b "text/template";_a "time";);func (_cf Time )MarshalText ()([]byte ,error ){if _cf .IsZero (){return nil ,nil ;};return []byte (_cf .String ()),nil ;};func init (){var _dd error ;_fd ,_dd =_b .New ("").Parse (_ccf );if _dd !=nil {panic (_cc .Sprintf ("\u0045\u0072\u0072\u003a\u0020p\u0061\u0072\u0073\u0069\u006e\u0067\u0020\u006d\u0065\u0074\u0061\u0064\u0061t\u0061\u0020\u0074\u0065\u006d\u0070\u006c\u0061\u0074\u0065\u0020\u0066\u0061\u0069\u006c\u0065\u0064\u003a\u0020\u0025\u0076",_dd ));
};};type Metadata struct{DocumentID _gg .UUID ;UniPDFVersion string ;Title string ;Author []string ;Subject string ;Keywords string ;Creator string ;Producer string ;PDFVersion string ;CreationDate Time ;ModifyDate Time ;MetadataDate Time ;Trapped Bool ;
Copyright string ;Marked Bool ;PdfA *PdfA ;};const (True Bool =true ;False Bool =false ;);type Bool bool ;func WrapTime (t _a .Time )Time {return Time (t )};func (_ddc Bool )MarshalText ()([]byte ,error ){if _ddc {return []byte ("\u0054\u0072\u0075\u0065"),nil ;
};return []byte ("\u0046\u0061\u006cs\u0065"),nil ;};type Time _a .Time ;var _fd *_b .Template ;func NewMetadataFromPdfInfo (obj _d .PdfObject )(Metadata ,error ){_e ,_eb :=obj .(*_d .PdfObjectDictionary );if !_eb {return Metadata {},_cc .Errorf ("i\u006e\u0076\u0061\u006c\u0069\u0064 \u0070\u0064\u0066\u0020\u006f\u0062\u006a\u0065\u0063t\u0020\u0074\u0079p\u0065:\u0020\u0025\u0054",obj );
};_ae :=Metadata {};var _gdd *_d .PdfObjectString ;for _ ,_ab :=range _e .Keys (){switch _ab {case "\u0054\u0069\u0074l\u0065":_gdd ,_eb =_d .GetString (_e .Get ("\u0054\u0069\u0074l\u0065"));if !_eb {continue ;};_ae .Title =_gdd .String ();case "\u0041\u0075\u0074\u0068\u006f\u0072":_gdd ,_eb =_d .GetString (_e .Get ("\u0041\u0075\u0074\u0068\u006f\u0072"));
if !_eb {continue ;};_ae .Author =[]string {_gdd .String ()};case "\u0053u\u0062\u006a\u0065\u0063\u0074":_gdd ,_eb =_d .GetString (_e .Get ("\u0053u\u0062\u006a\u0065\u0063\u0074"));if !_eb {continue ;};_ae .Subject =_gdd .String ();case "\u004b\u0065\u0079\u0077\u006f\u0072\u0064\u0073":_gdd ,_eb =_d .GetString (_e .Get ("\u004b\u0065\u0079\u0077\u006f\u0072\u0064\u0073"));
if !_eb {continue ;};_ae .Keywords =_gdd .String ();case "\u0043r\u0065\u0061\u0074\u006f\u0072":_gdd ,_eb =_d .GetString (_e .Get ("\u0043r\u0065\u0061\u0074\u006f\u0072"));if !_eb {continue ;};_ae .Creator =_gdd .String ();case "\u0050\u0072\u006f\u0064\u0075\u0063\u0065\u0072":_gdd ,_eb =_d .GetString (_e .Get ("\u0050\u0072\u006f\u0064\u0075\u0063\u0065\u0072"));
if !_eb {continue ;};_ae .Producer =_gdd .String ();case "\u0054r\u0061\u0070\u0070\u0065\u0064":_ ,_bb :=_d .GetName (_e .Get ("\u0054r\u0061\u0070\u0070\u0065\u0064"));if !_bb {continue ;};_ae .Trapped =true ;case "\u0043\u0072\u0065a\u0074\u0069\u006f\u006e\u0044\u0061\u0074\u0065":if _ef ,_bbf :=_d .GetString (_e .Get ("\u0043\u0072\u0065a\u0074\u0069\u006f\u006e\u0044\u0061\u0074\u0065"));
_bbf &&_ef .String ()!=""{_gb ,_eff :=_fa .ParsePdfTime (_ef .String ());if _eff !=nil {return _ae ,_cc .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",_eff );
};_ae .CreationDate =WrapTime (_gb );};case "\u004do\u0064\u0044\u0061\u0074\u0065":if _fb ,_ce :=_d .GetString (_e .Get ("\u004do\u0064\u0044\u0061\u0074\u0065"));_ce &&_fb .String ()!=""{_ec ,_ba :=_fa .ParsePdfTime (_fb .String ());if _ba !=nil {return _ae ,_cc .Errorf ("\u0069n\u0076\u0061\u006c\u0069d\u0020\u004d\u006f\u0064\u0044a\u0074e\u0020f\u0069\u0065\u006c\u0064\u003a\u0020\u0025w",_ba );
};_ae .ModifyDate =WrapTime (_ec );};};};_ae .UniPDFVersion =_cb .Version ;return _ae ,nil ;};func (_fe *Bool )UnmarshalText (data []byte )error {_cef ,_gc :=_gd .ParseBool (string (data ));if _gc !=nil {return _cc .Errorf ("\u0078\u006d\u0070\u003a \u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0062\u006fo\u006c \u0076\u0061\u006c\u0075\u0065\u0020\u0027%\u0073\u0027",string (data ));
};*_fe =Bool (_cef );return nil ;};func (_bf Bool )Value ()bool {return bool (_bf )};func Now ()Time {return Time (_a .Now ())};type PdfA struct{Part int ;Conformance string ;};func (_efg Time )String ()string {return _a .Time (_efg ).Format (_a .RFC3339 )};
func (_ecb Time )IsZero ()bool {return _a .Time (_ecb ).IsZero ()};func (_ad *Metadata )MarshalXMP ()([]byte ,error ){var _de _c .Buffer ;type wrapper struct{Metadata ;XPacketID string ;DocumentID _gg .UUID ;InstanceID _gg .UUID ;};_baa :=_ad .DocumentID ;
if _baa ==_gg .Nil {var _ee error ;_baa ,_ee =_gg .NewUUID ();if _ee !=nil {return nil ,_ee ;};};_fbb :=*_ad ;_da :=wrapper {Metadata :_fbb ,XPacketID :_f .EncodeToString (_baa [:]),DocumentID :_baa ,InstanceID :_baa };_de .WriteString ("\u003c\u003f\u0078\u0070\u0061\u0063\u006b\u0065\u0074\u0020\u0062\u0065g\u0069\u006e\u003d\u0022");
_de .WriteRune ('\uFEFF');_de .WriteString ("\u0022\u0020\u0069\u0064\u003d\u0022");_de .WriteString (_f .EncodeToString (_baa [:]));_de .WriteString ("\u0022\u003f\u003e");if _ge :=_fd .Execute (&_de ,_da );_ge !=nil {return nil ,_ge ;};return _de .Bytes (),nil ;
};const _ccf =`
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="{{.UniPDFVersion}}{{if not .MetadataDate.IsZero -}}, {{.MetadataDate.String}}{{end}}">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:xmp="http://ns.adobe.com/xap/1.0/"
xmlns:pdf="http://ns.adobe.com/pdf/1.3/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/"
xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#"
{{if .PdfA -}}
xmlns:pdfaid="http://www.aiim.org/pdfa/ns/id/"
xmlns:pdfaExtension="http://www.aiim.org/pdfa/ns/extension/"
xmlns:pdfaSchema="http://www.aiim.org/pdfa/ns/schema#"
xmlns:pdfaProperty="http://www.aiim.org/pdfa/ns/property#">
{{end -}}
<xmp:CreatorTool>{{.Creator}}</xmp:CreatorTool>
{{if not .CreationDate.IsZero -}}
<xmp:CreateDate>{{.CreationDate}}</xmp:CreateDate>
{{end -}}
{{if not .ModifyDate.IsZero -}}
<xmp:ModifyDate>{{.ModifyDate}}</xmp:ModifyDate>
{{end -}}
{{if not .MetadataDate.IsZero -}}
<xmp:MetadataDate>{{.MetadataDate}}</xmp:MetadataDate>
{{end -}}
{{if .Producer -}}<pdf:Producer>{{.Producer}}</pdf:Producer>
{{end -}}
{{if .Keywords -}}<pdf:Keywords>{{.Keywords }}</pdf:Keywords>
{{end -}}
{{if .PDFVersion -}}<pdf:PDFVersion>{{.PDFVersion}}</pdf:PDFVersion>
{{end -}}
{{if .Trapped -}}<pdf:Trapped>{{.Trapped}}</pdf:Trapped>
{{end -}}
{{if .Copyright -}}<pdf:Copyright>{{.Copyright}}</pdf:Copyright>
{{end -}}
{{if .Marked -}}<pdf:Marked>{{.Marked}}</pdf:Marked>
{{end -}}
<dc:format>application/pdf</dc:format>
{{if .Title -}}<dc:title>
<rdf:Alt>
<rdf:li xml:lang="x-default">{{.Title}}</rdf:li>
</rdf:Alt>
</dc:title>
{{end -}}
{{if .Author -}}<dc:creator>
<rdf:Seq>{{- range $author := .Author}}
<rdf:li>{{$author}}</rdf:li>
{{- end}}
</rdf:Seq>
</dc:creator>
{{end -}}
{{if .Subject -}}<dc:description>
<rdf:Alt>
<rdf:li xml:lang="x-default">{{.Subject}}</rdf:li>
</rdf:Alt>
</dc:description>
{{end -}}
{{if .Copyright -}}<dc:rights>
<rdf:Alt>
<rdf:li xml:lang="x-default">{{.Copyright}}</rdf:li>
</rdf:Alt>
</dc:rights>
{{end -}}
<xmpMM:DocumentID>uuid:{{.DocumentID}}</xmpMM:DocumentID>
<xmpMM:InstanceID>uuid:{{.InstanceID}}</xmpMM:InstanceID>
<xmpMM:RenditionClass>default</xmpMM:RenditionClass>
<xmpMM:VersionID>1</xmpMM:VersionID>
{{if .PdfA -}}<pdfaid:part>{{.PdfA.Part}}</pdfaid:part>
<pdfaid:conformance>{{.PdfA.Conformance}}</pdfaid:conformance>
{{end -}}
<pdfaExtension:schemas>
<rdf:Bag>
<rdf:li rdf:parseType="Resource">
<pdfaSchema:namespaceURI>http://ns.adobe.com/pdf/1.3/</pdfaSchema:namespaceURI>
<pdfaSchema:prefix>pdf</pdfaSchema:prefix>
<pdfaSchema:schema>Adobe PDF Schema</pdfaSchema:schema>
<pdfaSchema:property>
<rdf:Seq>
{{if .Trapped -}}<rdf:li rdf:parseType="Resource">
<pdfaProperty:category>internal</pdfaProperty:category>
<pdfaProperty:description>A name object indicating whether the document has been modified to include trapping information</pdfaProperty:description>
<pdfaProperty:name>Trapped</pdfaProperty:name>
<pdfaProperty:valueType>Text</pdfaProperty:valueType>
</rdf:li>
{{end -}}
{{if .Producer -}}<rdf:li rdf:parseType="Resource">
<pdfaProperty:category>internal</pdfaProperty:category>
<pdfaProperty:description>The name of the tool that created the PDF document.</pdfaProperty:description>
<pdfaProperty:name>Producer</pdfaProperty:name>
<pdfaProperty:valueType>AgentName</pdfaProperty:valueType>
</rdf:li>
{{end -}}
{{if .Keywords -}}<rdf:li rdf:parseType="Resource">
<pdfaProperty:category>internal</pdfaProperty:category>
<pdfaProperty:description>Keywords.</pdfaProperty:description>
<pdfaProperty:name>Keywords</pdfaProperty:name>
<pdfaProperty:valueType>Text</pdfaProperty:valueType>
</rdf:li>
{{end -}}
{{if .PDFVersion -}}<rdf:li rdf:parseType="Resource">
<pdfaProperty:category>internal</pdfaProperty:category>
<pdfaProperty:description>The PDF file version (for example: 1.0, 1.3, and so on).</pdfaProperty:description>
<pdfaProperty:name>PDFVersion</pdfaProperty:name>
<pdfaProperty:valueType>Text</pdfaProperty:valueType>
</rdf:li>
{{end -}}
</rdf:Seq>
</pdfaSchema:property>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<pdfaSchema:namespaceURI>http://ns.adobe.com/xap/1.0/mm/</pdfaSchema:namespaceURI>
<pdfaSchema:prefix>xmpMM</pdfaSchema:prefix>
<pdfaSchema:schema>XMP Media Management Schema</pdfaSchema:schema>
<pdfaSchema:property>
<rdf:Seq>
<rdf:li rdf:parseType="Resource">
<pdfaProperty:category>internal</pdfaProperty:category>
<pdfaProperty:description>UUID based identifier for specific incarnation of a document</pdfaProperty:description>
<pdfaProperty:name>InstanceID</pdfaProperty:name>
<pdfaProperty:valueType>URI</pdfaProperty:valueType>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<pdfaProperty:category>internal</pdfaProperty:category>
<pdfaProperty:description>The common identifier for all versions and renditions of a document.</pdfaProperty:description>
<pdfaProperty:name>OriginalDocumentID</pdfaProperty:name>
<pdfaProperty:valueType>URI</pdfaProperty:valueType>
</rdf:li>
</rdf:Seq>
</pdfaSchema:property>
</rdf:li>
{{if .PdfA -}}<rdf:li rdf:parseType="Resource">
<pdfaSchema:namespaceURI>http://www.aiim.org/pdfa/ns/id/</pdfaSchema:namespaceURI>
<pdfaSchema:prefix>pdfaid</pdfaSchema:prefix>
<pdfaSchema:schema>PDF/A ID Schema</pdfaSchema:schema>
<pdfaSchema:property>
<rdf:Seq>
<rdf:li rdf:parseType="Resource">
<pdfaProperty:category>internal</pdfaProperty:category>
<pdfaProperty:description>Part of PDF/A standard</pdfaProperty:description>
<pdfaProperty:name>part</pdfaProperty:name>
<pdfaProperty:valueType>Integer</pdfaProperty:valueType>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<pdfaProperty:category>internal</pdfaProperty:category>
<pdfaProperty:description>Amendment of PDF/A standard</pdfaProperty:description>
<pdfaProperty:name>amd</pdfaProperty:name>
<pdfaProperty:valueType>Text</pdfaProperty:valueType>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<pdfaProperty:category>internal</pdfaProperty:category>
<pdfaProperty:description>Conformance level of PDF/A standard</pdfaProperty:description>
<pdfaProperty:name>conformance</pdfaProperty:name>
<pdfaProperty:valueType>Text</pdfaProperty:valueType>
</rdf:li>
</rdf:Seq>
</pdfaSchema:property>
</rdf:li>
{{end -}}
</rdf:Bag>
</pdfaExtension:schemas>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end="w"?>`;