mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-29 17:27:08 +08:00
This commit is contained in:
1 parent
3927929822
commit
e3908c1149
8 files changed
+317
-145
No files matched your search
+45
-2
@@ -498,6 +498,15 @@ func renderPage(args []js.Value) (any, error) {
|
||||
dpi = args[2].Float()
|
||||
}
|
||||
raster := len(args) > 3 && args[3].Bool()
|
||||
if currentEditor != nil {
|
||||
page, err := currentEditor.Page(args[0].Int())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := syncEditorPageIDs(args[0].Int(), page); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
page, err := currentSession.RenderPage(args[0].Int(), backend, dpi, raster)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -569,7 +578,7 @@ func renderPage(args []js.Value) (any, error) {
|
||||
}
|
||||
|
||||
// pageTextString 提取OFD页面原文
|
||||
// 入参: args 浏览器参数
|
||||
// 入参: args 页面索引
|
||||
// 返回: any 页面原文, error 错误信息
|
||||
func pageTextString(args []js.Value) (any, error) {
|
||||
if currentSession == nil {
|
||||
@@ -2906,7 +2915,7 @@ func updateInfo(args []js.Value) (any, error) {
|
||||
}
|
||||
|
||||
// editDocument 将已打开文档接入编辑器,沿用页面、资源及字体配置
|
||||
// 入参: args 浏览器参数
|
||||
// 入参: args 当前页索引,省略时使用首页
|
||||
// 返回: any 编辑状态, error 错误信息
|
||||
func editDocument(args []js.Value) (any, error) {
|
||||
if currentSession == nil {
|
||||
@@ -2924,6 +2933,17 @@ func editDocument(args []js.Value) (any, error) {
|
||||
editor.SetFontFS(currentSession.fontFS)
|
||||
}
|
||||
editor.SetRenderBackends(currentSession.Renderer.Backends())
|
||||
page := 0
|
||||
if len(args) != 0 {
|
||||
page = args[0].Int()
|
||||
}
|
||||
content, err := editor.Page(page)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := syncEditorPageIDs(page, content); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
currentEditor = editor
|
||||
currentSession.editing = true
|
||||
copiedObjects = nil
|
||||
@@ -2931,6 +2951,29 @@ func editDocument(args []js.Value) (any, error) {
|
||||
return editorSummary(), nil
|
||||
}
|
||||
|
||||
// syncEditorPageIDs 同步编辑副本的对象编号,不改变原渲染属性或丢弃正常页面缓存
|
||||
// 入参: index 页面索引, content 编辑页面
|
||||
// 返回: error 页面读取错误
|
||||
func syncEditorPageIDs(index int, content *ofdgo.PageContent) error {
|
||||
page, err := currentSession.pageContent(index)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for i, layer := range content.Content.Layer {
|
||||
for j, object := range layer.Objects {
|
||||
before := &page.Content.Layer[i].Objects[j]
|
||||
if before.TextObject.ID != object.TextObject.ID || before.PathObject.ID != object.PathObject.ID || before.ImageObject.ID != object.ImageObject.ID || before.CompositeGraphicUnit.ID != object.CompositeGraphicUnit.ID {
|
||||
before.TextObject.ID = object.TextObject.ID
|
||||
before.PathObject.ID = object.PathObject.ID
|
||||
before.ImageObject.ID = object.ImageObject.ID
|
||||
before.CompositeGraphicUnit.ID = object.CompositeGraphicUnit.ID
|
||||
delete(currentSession.textCache, index)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// previewEditor 通过内存快照更新预览,不生成中间压缩包
|
||||
// 入参: editor 编辑文档, annotations 是否显示注解
|
||||
// 返回: editorInfo 文档信息, error 错误信息
|
||||
|
||||
+86
-86
@@ -43,65 +43,65 @@ type FontInfo = ofdgo.FontInfo
|
||||
type SignatureInfo struct {
|
||||
DocIndex int `json:"docIndex"`
|
||||
DocRoot string `json:"docRoot,omitempty"`
|
||||
ID string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Status string `json:"status"`
|
||||
IntegrityValid bool `json:"integrityValid"`
|
||||
TrustedValid bool `json:"trustedValid"`
|
||||
PolicyChecked bool `json:"policyChecked"`
|
||||
PolicyOK bool `json:"policyOK"`
|
||||
PolicyError string `json:"policyError,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
Signer string `json:"signer,omitempty"`
|
||||
SignatureDateTime string `json:"signatureDateTime,omitempty"`
|
||||
SealName string `json:"sealName,omitempty"`
|
||||
Provider string `json:"provider,omitempty"`
|
||||
Company string `json:"company,omitempty"`
|
||||
SealType string `json:"sealType,omitempty"`
|
||||
SealID string `json:"sealId,omitempty"`
|
||||
SealVendor string `json:"sealVendor,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
SignSubject string `json:"signSubject,omitempty"`
|
||||
SignIssuer string `json:"signIssuer,omitempty"`
|
||||
SignSerial string `json:"signSerial,omitempty"`
|
||||
SealSubject string `json:"sealSubject,omitempty"`
|
||||
SignatureMethod string `json:"signatureMethod,omitempty"`
|
||||
DigestMethod string `json:"digestMethod,omitempty"`
|
||||
ReferenceCount int `json:"referenceCount"`
|
||||
ReferenceChecked int `json:"referenceChecked"`
|
||||
ReferencePassed int `json:"referencePassed"`
|
||||
Stamps []SignatureStampInfo `json:"stamps,omitempty"`
|
||||
DataHashChecked bool `json:"dataHashChecked"`
|
||||
DataHashOK bool `json:"dataHashOK"`
|
||||
SignedValueChecked bool `json:"signedValueChecked"`
|
||||
SignedValueOK bool `json:"signedValueOK"`
|
||||
CertChecked bool `json:"certChecked"`
|
||||
CertOK bool `json:"certOK"`
|
||||
CertTimeChecked bool `json:"certTimeChecked,omitempty"`
|
||||
CertTimeOK bool `json:"certTimeOK,omitempty"`
|
||||
CertTrustChecked bool `json:"certTrustChecked,omitempty"`
|
||||
CertTrustOK bool `json:"certTrustOK,omitempty"`
|
||||
CertTrustError string `json:"certTrustError,omitempty"`
|
||||
SignatureTimeChecked bool `json:"signatureTimeChecked,omitempty"`
|
||||
SignatureTimeOK bool `json:"signatureTimeOK,omitempty"`
|
||||
SealChecked bool `json:"sealChecked"`
|
||||
SealOK bool `json:"sealOK"`
|
||||
SealMatchChecked bool `json:"sealMatchChecked"`
|
||||
SealMatchOK bool `json:"sealMatchOK"`
|
||||
SealTimeChecked bool `json:"sealTimeChecked,omitempty"`
|
||||
SealTimeOK bool `json:"sealTimeOK,omitempty"`
|
||||
SealCertTimeChecked bool `json:"sealCertTimeChecked,omitempty"`
|
||||
SealCertTimeOK bool `json:"sealCertTimeOK,omitempty"`
|
||||
CoverageChecked bool `json:"coverageChecked"`
|
||||
CoverageOK bool `json:"coverageOK"`
|
||||
CoverageError string `json:"coverageError,omitempty"`
|
||||
UncoveredFiles []string `json:"uncoveredFiles,omitempty"`
|
||||
PolicyChecked bool `json:"policyChecked"`
|
||||
PolicyOK bool `json:"policyOK"`
|
||||
PolicyError string `json:"policyError,omitempty"`
|
||||
TimestampChecked bool `json:"timestampChecked"`
|
||||
TimestampOK bool `json:"timestampOK"`
|
||||
Timestamps []TimestampInfo `json:"timestamps,omitempty"`
|
||||
RevocationChecked bool `json:"revocationChecked"`
|
||||
RevocationOK bool `json:"revocationOK"`
|
||||
Revocations []RevocationInfo `json:"revocations,omitempty"`
|
||||
ID string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Status string `json:"status"`
|
||||
Version string `json:"version,omitempty"`
|
||||
SealType string `json:"sealType,omitempty"`
|
||||
SealID string `json:"sealId,omitempty"`
|
||||
SealName string `json:"sealName,omitempty"`
|
||||
SealVendor string `json:"sealVendor,omitempty"`
|
||||
Signer string `json:"signer,omitempty"`
|
||||
SignatureDateTime string `json:"signatureDateTime,omitempty"`
|
||||
Provider string `json:"provider,omitempty"`
|
||||
Company string `json:"company,omitempty"`
|
||||
DataHashChecked bool `json:"dataHashChecked"`
|
||||
DataHashOK bool `json:"dataHashOK"`
|
||||
SignedValueChecked bool `json:"signedValueChecked"`
|
||||
SignedValueOK bool `json:"signedValueOK"`
|
||||
SealChecked bool `json:"sealChecked"`
|
||||
SealOK bool `json:"sealOK"`
|
||||
SealMatchChecked bool `json:"sealMatchChecked"`
|
||||
SealMatchOK bool `json:"sealMatchOK"`
|
||||
CertChecked bool `json:"certChecked"`
|
||||
CertOK bool `json:"certOK"`
|
||||
SignatureTimeChecked bool `json:"signatureTimeChecked,omitempty"`
|
||||
SignatureTimeOK bool `json:"signatureTimeOK,omitempty"`
|
||||
SealTimeChecked bool `json:"sealTimeChecked,omitempty"`
|
||||
SealTimeOK bool `json:"sealTimeOK,omitempty"`
|
||||
SealCertTimeChecked bool `json:"sealCertTimeChecked,omitempty"`
|
||||
SealCertTimeOK bool `json:"sealCertTimeOK,omitempty"`
|
||||
CertTimeChecked bool `json:"certTimeChecked,omitempty"`
|
||||
CertTimeOK bool `json:"certTimeOK,omitempty"`
|
||||
CertTrustChecked bool `json:"certTrustChecked,omitempty"`
|
||||
CertTrustOK bool `json:"certTrustOK,omitempty"`
|
||||
CertTrustError string `json:"certTrustError,omitempty"`
|
||||
ReferenceCount int `json:"referenceCount"`
|
||||
ReferenceChecked int `json:"referenceChecked"`
|
||||
ReferencePassed int `json:"referencePassed"`
|
||||
SignatureMethod string `json:"signatureMethod,omitempty"`
|
||||
DigestMethod string `json:"digestMethod,omitempty"`
|
||||
SignSerial string `json:"signSerial,omitempty"`
|
||||
SignSubject string `json:"signSubject,omitempty"`
|
||||
SignIssuer string `json:"signIssuer,omitempty"`
|
||||
SealSubject string `json:"sealSubject,omitempty"`
|
||||
Stamps []SignatureStampInfo `json:"stamps,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
// TimestampInfo 独立展示时间戳绑定、签名、信任和证书时效
|
||||
@@ -681,63 +681,63 @@ func signatureInfo(report ofdgo.SignatureVerifyReport) SignatureInfo {
|
||||
info := SignatureInfo{
|
||||
DocIndex: report.DocIndex,
|
||||
DocRoot: report.DocRoot,
|
||||
IntegrityValid: report.IntegrityValid(),
|
||||
TrustedValid: report.TrustedValid(),
|
||||
PolicyChecked: report.PolicyChecked,
|
||||
PolicyOK: report.PolicyOK,
|
||||
PolicyError: report.PolicyError,
|
||||
CoverageChecked: report.CoverageChecked,
|
||||
CoverageOK: report.CoverageOK,
|
||||
CoverageError: report.CoverageError,
|
||||
UncoveredFiles: report.UncoveredFiles,
|
||||
TimestampChecked: report.TimestampChecked,
|
||||
TimestampOK: report.TimestampOK,
|
||||
RevocationChecked: report.RevocationChecked,
|
||||
RevocationOK: report.RevocationOK,
|
||||
ID: report.ID,
|
||||
Type: string(report.Type),
|
||||
Status: status,
|
||||
Version: report.Provider.Version,
|
||||
SealType: report.SealType,
|
||||
SealID: report.SealInfo.ID,
|
||||
SealName: report.SealInfo.Name,
|
||||
SealVendor: report.SealInfo.VendorID,
|
||||
IntegrityValid: report.IntegrityValid(),
|
||||
TrustedValid: report.TrustedValid(),
|
||||
Error: signatureReportError(report),
|
||||
Signer: signatureSigner(report),
|
||||
SignatureDateTime: dateTime,
|
||||
SealName: report.SealInfo.Name,
|
||||
Provider: report.Provider.ProviderName,
|
||||
Company: report.Provider.Company,
|
||||
SealType: report.SealType,
|
||||
SealID: report.SealInfo.ID,
|
||||
SealVendor: report.SealInfo.VendorID,
|
||||
Version: report.Provider.Version,
|
||||
SignSubject: report.SignCert.Subject,
|
||||
SignIssuer: report.SignCert.Issuer,
|
||||
SignSerial: report.SignCert.SerialNumber,
|
||||
SealSubject: report.SealCert.Subject,
|
||||
SignatureMethod: report.SignatureMethod,
|
||||
DigestMethod: report.DigestMethod,
|
||||
ReferenceCount: len(report.References),
|
||||
ReferenceChecked: checked,
|
||||
ReferencePassed: passed,
|
||||
Stamps: signatureStampInfos(report.StampPositions),
|
||||
DataHashChecked: report.DataHashChecked,
|
||||
DataHashOK: report.DataHashOK,
|
||||
SignedValueChecked: report.SignedValueChecked,
|
||||
SignedValueOK: report.SignedValueOK,
|
||||
SealChecked: report.SealChecked,
|
||||
SealOK: report.SealOK,
|
||||
SealMatchChecked: report.SealMatchChecked,
|
||||
SealMatchOK: report.SealMatchOK,
|
||||
CertChecked: report.CertChecked,
|
||||
CertOK: report.CertOK,
|
||||
SignatureTimeChecked: report.SignatureTimeChecked,
|
||||
SignatureTimeOK: report.SignatureTimeOK,
|
||||
SealTimeChecked: report.SealTimeChecked,
|
||||
SealTimeOK: report.SealTimeOK,
|
||||
SealCertTimeChecked: report.SealCertTimeChecked,
|
||||
SealCertTimeOK: report.SealCertTimeOK,
|
||||
CertTimeChecked: report.CertTimeChecked,
|
||||
CertTimeOK: report.CertTimeOK,
|
||||
CertTrustChecked: report.CertTrustChecked,
|
||||
CertTrustOK: report.CertTrustOK,
|
||||
CertTrustError: report.CertTrustError,
|
||||
ReferenceCount: len(report.References),
|
||||
ReferenceChecked: checked,
|
||||
ReferencePassed: passed,
|
||||
SignatureMethod: report.SignatureMethod,
|
||||
DigestMethod: report.DigestMethod,
|
||||
SignSerial: report.SignCert.SerialNumber,
|
||||
SignSubject: report.SignCert.Subject,
|
||||
SignIssuer: report.SignCert.Issuer,
|
||||
SealSubject: report.SealCert.Subject,
|
||||
Stamps: signatureStampInfos(report.StampPositions),
|
||||
Error: signatureReportError(report),
|
||||
SignatureTimeChecked: report.SignatureTimeChecked,
|
||||
SignatureTimeOK: report.SignatureTimeOK,
|
||||
SealChecked: report.SealChecked,
|
||||
SealOK: report.SealOK,
|
||||
SealMatchChecked: report.SealMatchChecked,
|
||||
SealMatchOK: report.SealMatchOK,
|
||||
SealTimeChecked: report.SealTimeChecked,
|
||||
SealTimeOK: report.SealTimeOK,
|
||||
SealCertTimeChecked: report.SealCertTimeChecked,
|
||||
SealCertTimeOK: report.SealCertTimeOK,
|
||||
CoverageChecked: report.CoverageChecked,
|
||||
CoverageOK: report.CoverageOK,
|
||||
CoverageError: report.CoverageError,
|
||||
UncoveredFiles: report.UncoveredFiles,
|
||||
PolicyChecked: report.PolicyChecked,
|
||||
PolicyOK: report.PolicyOK,
|
||||
PolicyError: report.PolicyError,
|
||||
TimestampChecked: report.TimestampChecked,
|
||||
TimestampOK: report.TimestampOK,
|
||||
RevocationChecked: report.RevocationChecked,
|
||||
RevocationOK: report.RevocationOK,
|
||||
}
|
||||
for _, stamp := range report.Timestamps {
|
||||
info.Timestamps = append(info.Timestamps, TimestampInfo{
|
||||
|
||||
Reference in new issue
Block a user