英文水印没有什么问题,只要是中文都会出错
my code
textStamp = new TextStamp(“你好 aspose.pdf”);
Document document = new Document(“test.pdf”);
document.Pages[1].AddStamp(textStamp);
出现的异常是
System.NullReferenceException: Object reference not set to an instance of an object.
at Aspose.Pdf.Text.Font…ctor(#=z$suuRT1fkyC6o7sLZOgoVCo= #=zrItU44g=)
at #=z7bI4GhXHbP5a$tKtZ8fm06BHoRC_OkCVFa6LJsOBCZxTOHyiI6BH0LE=.#=znXZO1csT5yQ2yNa9pEqJE_znjCyF(String #=z1bLSgdQ=, Font #=zrItU44g=, Font& #=zSrZU8_e94X$Wu1iac49Oz2U=)
at Aspose.Pdf.Text.TextSegment.set_Text(String value)
at Aspose.Pdf.Text.TextFragment.set_Text(String value)
at Aspose.Pdf.TextStamp.Put(Page page)
at Aspose.Pdf.Page.AddStamp(Stamp stamp)
at convertapi.Controllers.IndexController.Post(Args args) in G:\dotnet\convertapi\Controllers\IndexController.cs:line 227
at lambda_method(Closure , Object , Object[] )
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
— End of stack trace from previous location where exception was thrown —
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
— End of stack trace from previous location where exception was thrown —
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)