groupdocs-free-consulting / projects

0 stars 0 forks source link

pptx waterMark for java sdk error #9

Closed 19940308cai closed 3 years ago

19940308cai commented 3 years ago

code: `

public static void pptWaterMark(String inFilePath, String outFilePath, String WaterText) {

    PresentationLoadOptions loadOptions = new PresentationLoadOptions();

    // Constants.InPresentationPptx is an absolute or relative path to your document. Ex: "C:\\Docs\\presentation.pptx"
    Watermarker watermarker = new Watermarker(inFilePath, loadOptions);

    // Add text watermark to the first slide
    TextWatermark textWatermark = new TextWatermark(WaterText, new Font("Segoe UI", 19));

    textWatermark.setHorizontalAlignment(HorizontalAlignment.Center);

    textWatermark.setVerticalAlignment(VerticalAlignment.Center);

    textWatermark.setRotateAngle(45);

    textWatermark.setSizingType(SizingType.ScaleToParentDimensions);

    textWatermark.setScaleFactor(0.5);

    textWatermark.setOpacity(0.5);

    // Add watermark to all headers of the first section
    WordProcessingWatermarkSectionOptions options = new WordProcessingWatermarkSectionOptions();

    watermarker.add(textWatermark, options);

    watermarker.save(outFilePath);

    watermarker.close();

}

`

java.lang.RuntimeException: com.groupdocs.watermark.internalx.c.a.w.bS: The document appears to be corrupted and cannot be loaded. at com.groupdocs.watermark.internal.cj.eq(Unknown Source) at com.groupdocs.watermark.internal.cj.c(Unknown Source) at com.groupdocs.watermark.internal.p.a(Unknown Source) at com.groupdocs.watermark.internal.E.a(Unknown Source) at com.groupdocs.watermark.internal.E.a(Unknown Source) at com.groupdocs.watermark.Watermarker.(Unknown Source) at com.groupdocs.watermark.Watermarker.(Unknown Source) at com.jingtian.share.util.GroupDocUtils.pptWaterMark(GroupDocUtils.java:35) at com.jingtian.share.controller.ShareMarkController.pptDispatcher(ShareMarkController.java:71) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:114) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) at javax.servlet.http.HttpServlet.service(HttpServlet.java:648) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:89) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) Caused by: com.groupdocs.watermark.internalx.c.a.w.bS: The document appears to be corrupted and cannot be loaded. at com.groupdocs.watermark.internalx.c.a.w.bU.f(Unknown Source) at com.groupdocs.watermark.internalx.c.a.w.bU.b(Unknown Source) at com.groupdocs.watermark.internalx.c.a.w.bU.W(Unknown Source) ... 63 more Caused by: java.util.zip.ZipException: invalid LOC header (bad signature) at java.util.zip.ZipFile.read(Native Method) at java.util.zip.ZipFile.access$1400(ZipFile.java:60) at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:734) at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:434) at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158) at com.groupdocs.watermark.internalx.c.a.w.internal.uR.a(Unknown Source) at com.groupdocs.watermark.internalx.c.a.w.internal.bL.g(Unknown Source) at com.groupdocs.watermark.internalx.c.a.w.internal.bH.g(Unknown Source) at com.groupdocs.watermark.internalx.c.a.w.internal.bI.hCz(Unknown Source) at com.groupdocs.watermark.internalx.c.a.w.internal.bH.hCz(Unknown Source) at com.groupdocs.watermark.internalx.c.a.w.zz02.zzZt6(Unknown Source) at com.groupdocs.watermark.internalx.c.a.w.zz02.zzY(Unknown Source) ... 65 more

atirtahirgroupdocs commented 3 years ago

@19940308cai

We couldn't reproduce this issue at our end using the provided code and API version 20.5. Have a look at this screenshot.

screenshot Please share following details and we'll look into this issue:

However, from the exception below, it seems that the issue is more related to the source file. Either the file is corrupt or not loaded properly.

The document appears to be corrupted and cannot be loaded.

19940308cai commented 3 years ago

update problem description !

that problem Show up at the RESET API

I go through the client call that function result is success

atirtahirgroupdocs commented 3 years ago

@19940308cai

I go through the client call that function result is success

Do you mean that the issue is resolved? Can you please share more details. Did you create your own REST API using this JAR?

19940308cai commented 3 years ago

Thank you. I have found the reason. The high probability is the problem of the file itself

19940308cai commented 3 years ago

By the way, I have a new problem here. I hope you can help me solve it.

Let me briefly describe the problem: I introduced the JAR package into the Springboot project and then built it through Maven. Finally, there was an error when I used Java-jar XXx. jar. I couldn't find the problem for a long time, and the specific error code is as follows WechatIMG2699 pom

19940308cai commented 3 years ago

I wanted to integrate the water library into my project, then ran java-jar XXx.jar after building the project through Maven and reported an error, as shown in the figure above.

Is there something special about this water bank?

atirtahirgroupdocs commented 3 years ago

@19940308cai

Can you please share a sample project here and we'll investigate this scenario.

19940308cai commented 3 years ago

hi~ my project gitee, you can download that : https://gitee.com/caijiang/group.git

19940308cai commented 3 years ago

step 1: update pom dependecy for com.groupdocs version

step 2: mvn clean package

step 3: java -jar target/xxx.jar

Tips: web port: 14000 server.servlet-path=/open

atirtahirgroupdocs commented 3 years ago

@19940308cai

Please create a thread regarding this issue here or share your email address and we'll create a new thread on your behalf. We'll further investigate this issue and update you on forum.

19940308cai commented 3 years ago

my email q152625424@sina.com

atirtahirgroupdocs commented 3 years ago

@19940308cai

We changed the version of Spring Boot to 2.3.4.RELEASE and the application started working.

shahzad-latif commented 3 years ago

@19940308cai

Please use our free support forums to get help with such issues. We'll be able to help you more quickly and appropriately via our support forums. Thanks for understanding.