25-09-2023
This commit is contained in:
parent
0533ccef63
commit
8c5f2f3d38
@ -26,9 +26,7 @@
|
||||
Public Shared Function GetEnvelopeURL(pHost As String, pEnvelopeUuid As String, pReceiverSignature As String) As String
|
||||
|
||||
Dim oEnvelopeUserReference As String = EncodeEnvelopeReceiverId(pEnvelopeUuid, pReceiverSignature)
|
||||
|
||||
Dim oURL As String = ""
|
||||
oURL = String.Format("{0}/EnvelopeKey/{1}", pHost.Trim(), oEnvelopeUserReference)
|
||||
Dim oURL As String = String.Format("{0}/EnvelopeKey/{1}", pHost.Trim(), oEnvelopeUserReference)
|
||||
Return oURL
|
||||
|
||||
End Function
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
using EnvelopeGenerator.Common;
|
||||
using EnvelopeGenerator.Common.My.Resources;
|
||||
using EnvelopeGenerator.Web.Services;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
|
||||
namespace EnvelopeGenerator.Web.Handler
|
||||
{
|
||||
@ -7,6 +9,7 @@ namespace EnvelopeGenerator.Web.Handler
|
||||
{
|
||||
public async static Task<IResult> HandleFile(HttpContext ctx, DatabaseService database, LoggingService logging)
|
||||
{
|
||||
|
||||
var logger = logging.LogConfig.GetLogger("FileHandler");
|
||||
string envelopeKey = (string)ctx.Request.RouteValues["envelopeKey"];
|
||||
|
||||
@ -22,13 +25,53 @@ namespace EnvelopeGenerator.Web.Handler
|
||||
logger.Info("Contains [{0}] documents", envelope.Documents.Count);
|
||||
logger.Info("Contains [{0}] receivers", envelope.Receivers.Count);
|
||||
|
||||
var document = envelope.Documents.First();
|
||||
int documentId = getDocumentIndex(ctx);
|
||||
var document = getDocument(envelope, documentId);
|
||||
|
||||
try
|
||||
{
|
||||
var bytes = await File.ReadAllBytesAsync(document.Filepath);
|
||||
logger.Info("Serving file, size: [{0}]", bytes.Length);
|
||||
|
||||
return Results.File(bytes);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.Error(e);
|
||||
return Results.Problem();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static int getDocumentIndex(HttpContext ctx)
|
||||
{
|
||||
int documentId = 0;
|
||||
StringValues documentIndexString;
|
||||
if (ctx.Request.Query.TryGetValue("index", out documentIndexString))
|
||||
{
|
||||
int.TryParse(documentIndexString.First(), out documentId);
|
||||
}
|
||||
|
||||
return documentId;
|
||||
}
|
||||
|
||||
private static EnvelopeDocument getDocument(Common.Envelope envelope, int documentId)
|
||||
{
|
||||
var document = envelope.Documents.First();
|
||||
if (documentId > 0)
|
||||
{
|
||||
var documentById = envelope.Documents.
|
||||
Where(d => d.Id == documentId).
|
||||
FirstOrDefault();
|
||||
|
||||
if (documentById != null)
|
||||
{
|
||||
document = documentById;
|
||||
}
|
||||
}
|
||||
|
||||
return document;
|
||||
}
|
||||
|
||||
public static Task<IResult> HandleGetData(HttpContext ctx, DatabaseService database, LoggingService logging)
|
||||
{
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import PSPDFKitType, { AnnotationsUnion } from "./index";
|
||||
import { Instance, WidgetAnnotation, ToolbarItem } from "./index";
|
||||
import { EnvelopeResponse, Envelope, User, Element, Document } from "./interfaces";
|
||||
|
||||
declare const PSPDFKit: typeof PSPDFKitType
|
||||
|
||||
@ -9,22 +10,7 @@ const { SignatureFormField } = PSPDFKit.FormFields;
|
||||
const { DRAW, TYPE } = PSPDFKit.ElectronicSignatureCreationMode;
|
||||
const { DISABLED } = PSPDFKit.AutoSaveMode;
|
||||
|
||||
interface EnvelopeResponse {
|
||||
receiverId: number;
|
||||
envelope: Envelope;
|
||||
}
|
||||
|
||||
interface Envelope {
|
||||
id: number;
|
||||
userId: number;
|
||||
title: string;
|
||||
contractType: number;
|
||||
status: number;
|
||||
uuid: string;
|
||||
}
|
||||
|
||||
class Settings {
|
||||
public static allowedToolbarItems: string[] = [
|
||||
const allowedToolbarItems: string[] = [
|
||||
"sidebar-thumbnails",
|
||||
"sidebar-document-ouline",
|
||||
"sidebar-bookmarks",
|
||||
@ -36,36 +22,55 @@ class Settings {
|
||||
"spacer",
|
||||
"search"
|
||||
]
|
||||
}
|
||||
|
||||
export class App {
|
||||
public static Instance: Instance;
|
||||
public static currentDocument
|
||||
|
||||
// This function will be called in the ShowEnvelope.razor page
|
||||
// and will trigger loading of the Editor Interface
|
||||
public static async loadPDFFromUrl (container: string, envelopeKey: string) {
|
||||
console.debug("Loading PSPDFKit..");
|
||||
|
||||
const arrayBuffer = await App.loadDocument(`/api/download/${envelopeKey}`);
|
||||
const envelopeObject: EnvelopeResponse = await App.loadData(`/api/get-data/${envelopeKey}`);
|
||||
const document: Document = envelopeObject.envelope.documents[0];
|
||||
|
||||
let arrayBuffer
|
||||
try {
|
||||
arrayBuffer = await App.loadDocument(`/api/download/${envelopeKey}?id=${document.id}`);
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
|
||||
App.Instance = await App.loadPSPDFKit(arrayBuffer, container)
|
||||
App.configurePSPDFKit(this.Instance)
|
||||
|
||||
console.debug(envelopeObject.envelope.id);
|
||||
console.debug(envelopeObject.envelope);
|
||||
console.debug("PSPDFKit configured!");
|
||||
|
||||
const annotations: any[] = [];
|
||||
|
||||
document.elements.forEach(function (element: Element) {
|
||||
console.log("Loading element")
|
||||
console.debug("Page", element.page)
|
||||
console.debug("Width / Height", element.width, element.height)
|
||||
console.debug("Top / Left", element.top, element.left)
|
||||
|
||||
const id = PSPDFKit.generateInstantId()
|
||||
const annotation: WidgetAnnotation = App.createSignatureAnnotation(id, 150, 50, 50, 50, 0)
|
||||
const annotation: WidgetAnnotation = App.createSignatureAnnotation(id, element.width, element.height, element.top, element.left, element.page)
|
||||
|
||||
const formField = new SignatureFormField({
|
||||
name: id,
|
||||
annotationIds: List([annotation.id])
|
||||
})
|
||||
|
||||
console.debug("Annotation created.")
|
||||
annotations.push(annotation);
|
||||
annotations.push(formField);
|
||||
|
||||
const [createdAnnotation] = await App.Instance.create([annotation, formField])
|
||||
console.debug("Annotation created.")
|
||||
})
|
||||
|
||||
const [createdAnnotation] = await App.Instance.create(annotations)
|
||||
|
||||
console.debug(createdAnnotation)
|
||||
}
|
||||
@ -117,7 +122,8 @@ export class App {
|
||||
})
|
||||
|
||||
const filteredItems: Array<ToolbarItem> = instance.toolbarItems
|
||||
.filter((item) => Settings.allowedToolbarItems.includes(item.type))
|
||||
.filter((item) => allowedToolbarItems.includes(item.type))
|
||||
|
||||
|
||||
const customItems: ToolbarItem[] = [
|
||||
{
|
||||
@ -171,17 +177,12 @@ export class App {
|
||||
}
|
||||
|
||||
|
||||
private static createSignatureAnnotation(id: string, x: number, y: number, top: number, left: number, pageIndex: number): WidgetAnnotation {
|
||||
private static createSignatureAnnotation(id: string, width: number, height: number, top: number, left: number, pageIndex: number): WidgetAnnotation {
|
||||
const annotation = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||
id: id,
|
||||
pageIndex: pageIndex,
|
||||
formFieldName: id,
|
||||
boundingBox: new Rect({
|
||||
width: x,
|
||||
height: y,
|
||||
top: top,
|
||||
left: left
|
||||
})
|
||||
boundingBox: new Rect({ width, height, top, left })
|
||||
})
|
||||
|
||||
return annotation
|
||||
|
||||
47
EnvelopeGenerator.Web/Scripts/interfaces.ts
Normal file
47
EnvelopeGenerator.Web/Scripts/interfaces.ts
Normal file
@ -0,0 +1,47 @@
|
||||
interface EnvelopeResponse {
|
||||
receiverId: number;
|
||||
envelope: Envelope;
|
||||
}
|
||||
|
||||
interface Envelope {
|
||||
id: number;
|
||||
userId: number;
|
||||
title: string;
|
||||
status: number;
|
||||
statusTranslated: string;
|
||||
contractType: number;
|
||||
contractTypeTranslated: string;
|
||||
subject: string;
|
||||
uuid: string;
|
||||
user: User;
|
||||
documents: Document[];
|
||||
}
|
||||
|
||||
interface Document {
|
||||
id: number;
|
||||
filepath: string;
|
||||
filename: string;
|
||||
elements: Element[];
|
||||
}
|
||||
|
||||
interface Element {
|
||||
id: number;
|
||||
left: number;
|
||||
top: number;
|
||||
width: number;
|
||||
height: number;
|
||||
page: number;
|
||||
readOnly: boolean;
|
||||
}
|
||||
|
||||
interface User {
|
||||
id: number;
|
||||
email: string;
|
||||
name: string;
|
||||
prename: string;
|
||||
username: string;
|
||||
language: string;
|
||||
fullName: string;
|
||||
}
|
||||
|
||||
export { EnvelopeResponse, Envelope, Document, Element, User }
|
||||
20
EnvelopeGenerator.Web/tsconfig.original.json
Normal file
20
EnvelopeGenerator.Web/tsconfig.original.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"compileOnSave": true,
|
||||
"compilerOptions": {
|
||||
"noEmitOnError": true,
|
||||
"noImplicitAny": false,
|
||||
"outDir": "wwwroot/js",
|
||||
"removeComments": false,
|
||||
"module": "ES2015",
|
||||
"moduleResolution": "Classic",
|
||||
"sourceMap": true,
|
||||
"target": "es5",
|
||||
"lib": ["ES2016", "DOM"]
|
||||
},
|
||||
"include": [
|
||||
"Scripts/**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
@ -39,10 +39,7 @@ var Rect = PSPDFKit.Geometry.Rect;
|
||||
var SignatureFormField = PSPDFKit.FormFields.SignatureFormField;
|
||||
var _a = PSPDFKit.ElectronicSignatureCreationMode, DRAW = _a.DRAW, TYPE = _a.TYPE;
|
||||
var DISABLED = PSPDFKit.AutoSaveMode.DISABLED;
|
||||
var Settings = /** @class */ (function () {
|
||||
function Settings() {
|
||||
}
|
||||
Settings.allowedToolbarItems = [
|
||||
var allowedToolbarItems = [
|
||||
"sidebar-thumbnails",
|
||||
"sidebar-document-ouline",
|
||||
"sidebar-bookmarks",
|
||||
@ -54,8 +51,6 @@ var Settings = /** @class */ (function () {
|
||||
"spacer",
|
||||
"search"
|
||||
];
|
||||
return Settings;
|
||||
}());
|
||||
var App = /** @class */ (function () {
|
||||
function App() {
|
||||
}
|
||||
@ -63,33 +58,52 @@ var App = /** @class */ (function () {
|
||||
// and will trigger loading of the Editor Interface
|
||||
App.loadPDFFromUrl = function (container, envelopeKey) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var arrayBuffer, envelopeObject, _a, id, annotation, formField, createdAnnotation;
|
||||
var envelopeObject, document, arrayBuffer, e_1, _a, annotations, createdAnnotation;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
console.debug("Loading PSPDFKit..");
|
||||
return [4 /*yield*/, App.loadDocument("/api/download/".concat(envelopeKey))];
|
||||
case 1:
|
||||
arrayBuffer = _b.sent();
|
||||
return [4 /*yield*/, App.loadData("/api/get-data/".concat(envelopeKey))];
|
||||
case 2:
|
||||
case 1:
|
||||
envelopeObject = _b.sent();
|
||||
document = envelopeObject.envelope.documents[0];
|
||||
_b.label = 2;
|
||||
case 2:
|
||||
_b.trys.push([2, 4, , 5]);
|
||||
return [4 /*yield*/, App.loadDocument("/api/download/".concat(envelopeKey, "?id=").concat(document.id))];
|
||||
case 3:
|
||||
arrayBuffer = _b.sent();
|
||||
return [3 /*break*/, 5];
|
||||
case 4:
|
||||
e_1 = _b.sent();
|
||||
console.error(e_1);
|
||||
return [3 /*break*/, 5];
|
||||
case 5:
|
||||
_a = App;
|
||||
return [4 /*yield*/, App.loadPSPDFKit(arrayBuffer, container)];
|
||||
case 3:
|
||||
case 6:
|
||||
_a.Instance = _b.sent();
|
||||
App.configurePSPDFKit(this.Instance);
|
||||
console.debug(envelopeObject.envelope.id);
|
||||
console.debug(envelopeObject.envelope);
|
||||
console.debug("PSPDFKit configured!");
|
||||
id = PSPDFKit.generateInstantId();
|
||||
annotation = App.createSignatureAnnotation(id, 150, 50, 50, 50, 0);
|
||||
formField = new SignatureFormField({
|
||||
annotations = [];
|
||||
document.elements.forEach(function (element) {
|
||||
console.log("Loading element");
|
||||
console.debug("Page", element.page);
|
||||
console.debug("Width / Height", element.width, element.height);
|
||||
console.debug("Top / Left", element.top, element.left);
|
||||
var id = PSPDFKit.generateInstantId();
|
||||
var annotation = App.createSignatureAnnotation(id, element.width, element.height, element.top, element.left, element.page);
|
||||
var formField = new SignatureFormField({
|
||||
name: id,
|
||||
annotationIds: List([annotation.id])
|
||||
});
|
||||
annotations.push(annotation);
|
||||
annotations.push(formField);
|
||||
console.debug("Annotation created.");
|
||||
return [4 /*yield*/, App.Instance.create([annotation, formField])];
|
||||
case 4:
|
||||
});
|
||||
return [4 /*yield*/, App.Instance.create(annotations)];
|
||||
case 7:
|
||||
createdAnnotation = (_b.sent())[0];
|
||||
console.debug(createdAnnotation);
|
||||
return [2 /*return*/];
|
||||
@ -137,12 +151,12 @@ var App = /** @class */ (function () {
|
||||
console.log("annotations created", createdAnnotations.toJS());
|
||||
});
|
||||
var filteredItems = instance.toolbarItems
|
||||
.filter(function (item) { return Settings.allowedToolbarItems.includes(item.type); });
|
||||
.filter(function (item) { return allowedToolbarItems.includes(item.type); });
|
||||
var customItems = [
|
||||
{
|
||||
type: "custom",
|
||||
id: "button-finish",
|
||||
title: "Abschließen",
|
||||
title: "Abschlie<EFBFBD>en",
|
||||
icon: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" fill=\"currentColor\" class=\"bi bi-check2-circle\" viewBox=\"0 0 16 16\">\n <path d=\"M2.5 8a5.5 5.5 0 0 1 8.25-4.764.5.5 0 0 0 .5-.866A6.5 6.5 0 1 0 14.5 8a.5.5 0 0 0-1 0 5.5 5.5 0 1 1-11 0z\"/>\n <path d=\"M15.354 3.354a.5.5 0 0 0-.708-.708L8 9.293 5.354 6.646a.5.5 0 1 0-.708.708l3 3a.5.5 0 0 0 .708 0l7-7z\" />\n </svg>",
|
||||
onPress: this.handleFinish
|
||||
}
|
||||
@ -201,17 +215,12 @@ var App = /** @class */ (function () {
|
||||
});
|
||||
});
|
||||
};
|
||||
App.createSignatureAnnotation = function (id, x, y, top, left, pageIndex) {
|
||||
App.createSignatureAnnotation = function (id, width, height, top, left, pageIndex) {
|
||||
var annotation = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||
id: id,
|
||||
pageIndex: pageIndex,
|
||||
formFieldName: id,
|
||||
boundingBox: new Rect({
|
||||
width: x,
|
||||
height: y,
|
||||
top: top,
|
||||
left: left
|
||||
})
|
||||
boundingBox: new Rect({ width: width, height: height, top: top, left: left })
|
||||
});
|
||||
return annotation;
|
||||
};
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
EnvelopeGenerator.Web/wwwroot/js/interfaces.js
Normal file
2
EnvelopeGenerator.Web/wwwroot/js/interfaces.js
Normal file
@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=interfaces.js.map
|
||||
1
EnvelopeGenerator.Web/wwwroot/js/interfaces.js.map
Normal file
1
EnvelopeGenerator.Web/wwwroot/js/interfaces.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../Scripts/interfaces.ts"],"names":[],"mappings":""}
|
||||
@ -1 +1,14 @@
|
||||
const allowedToolbarItems = [
|
||||
"sidebar-thumbnails",
|
||||
"sidebar-document-ouline",
|
||||
"sidebar-bookmarks",
|
||||
"pager",
|
||||
"pan",
|
||||
"zoom-out",
|
||||
"zoom-in",
|
||||
"zoom-mode",
|
||||
"spacer",
|
||||
"search"
|
||||
];
|
||||
export { allowedToolbarItems };
|
||||
//# sourceMappingURL=settings.js.map
|
||||
@ -1 +1 @@
|
||||
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../Scripts/settings.ts"],"names":[],"mappings":""}
|
||||
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../Scripts/settings.ts"],"names":[],"mappings":"AAAA,MAAM,mBAAmB,GAAa;IAClC,oBAAoB;IACpB,yBAAyB;IACzB,mBAAmB;IACnB,OAAO;IACP,KAAK;IACL,UAAU;IACV,SAAS;IACT,WAAW;IACX,QAAQ;IACR,QAAQ;CACX,CAAA;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
|
||||
Loading…
x
Reference in New Issue
Block a user