Free Support Forum - aspose.com

Exception occurs while adding image in XPS document using Aspose.Page for Java

public class ImageWaterMark {
public static void test(){
getLicense(“C:\PrintHub\license\Aspose.Total.Product.Family.lic”);
String dataDir =“C:\PrintHub\docs\2019\7\9\”;
com.aspose.xps.XpsDocument doc = null;
try {
doc = new com.aspose.xps.XpsDocument(dataDir + “b71863d8-71d1-4e6e-8c79-d1a8a8a96003.xps”);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
long time1 = System.currentTimeMillis();
com.aspose.xps.XpsPath path = doc.addPath(doc.createPathGeometry(“M 30,20 l 258.24,0 0,56.64 -258.24,0 Z”));
// Creating a matrix is optional, it can be used for proper positioning
path.setRenderTransform(doc.createMatrix(0.7f, 0f, 0f, 0.7f, 0f, 20f));
// Create Image Brush
path.setFill(doc.createImageBrush(dataDir + “1.png”, new java.awt.geom.Rectangle2D.Double(0f, 0f, 258.24f, 56.64f), new java.awt.geom.Rectangle2D.Double(50f, 20f, 193.68f, 42.48f)));
// Save resultant XPS document
try {
doc.save(dataDir + “AddImage_out2.xps”);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
long time2 = System.currentTimeMillis();
System.out.println("加水印时间: "+(time2 - time1));

}

}
————————

Invalid Offset property value: GradientStop
com.aspose.xps.XpsGradientStop.ll(Unknown Source)
com.aspose.xps.XpsGradientStop.lIf(Unknown Source)
com.aspose.xps.XpsGradientStop.(Unknown Source)
com.aspose.xps.XpsGradientBrush.ll(Unknown Source)
com.aspose.xps.XpsGradientBrush.lif(Unknown Source)
com.aspose.xps.XpsLinearGradientBrush.lif(Unknown Source)
com.aspose.xps.XpsLinearGradientBrush.(Unknown Source)
com.aspose.xps.XpsBrush.lif(Unknown Source)
com.aspose.xps.XpsBrush.lif(Unknown Source)
com.aspose.xps.I81.lif(Unknown Source)
com.aspose.xps.I81.lif(Unknown Source)
com.aspose.xps.XpsPath.lif(Unknown Source)
com.aspose.xps.XpsPath.(Unknown Source)
com.aspose.xps.I10I.lif(Unknown Source)
com.aspose.xps.XpsElement.lif(Unknown Source)
com.aspose.xps.I10I.lif(Unknown Source)
com.aspose.xps.XpsElement.lif(Unknown Source)
com.aspose.xps.I10I.lif(Unknown Source)
com.aspose.xps.XpsElement.lif(Unknown Source)
com.aspose.xps.XpsPage.lif(Unknown Source)
com.aspose.xps.I1l.lif(Unknown Source)
com.aspose.xps.I1l.lif(Unknown Source)
com.aspose.xps.XpsDocument.liF(Unknown Source)
com.aspose.xps.XpsDocument.selectActivePage(Unknown Source)
com.aspose.xps.I10l.lf(Unknown Source)
com.aspose.xps.I10l.ll(Unknown Source)
com.aspose.xps.I4I.liF(Unknown Source)
com.aspose.xps.XpsDocument.ll(Unknown Source)
com.aspose.xps.XpsDocument.lif(Unknown Source)
com.aspose.xps.XpsDocument$I7.lif(Unknown Source)
com.aspose.page.internal.l421.Il.lif(Unknown Source)
com.aspose.page.internal.l421.II.lif(Unknown Source)
com.aspose.xps.XpsDocument.save(Unknown Source)
com.aspose.xps.XpsDocument.save(Unknown Source)
com.insolu.ImageWaterMark.test(ImageWaterMark.java:25)
com.insolu.OcrDemo.main(OcrDemo.java:13)
Exception in thread “main” class com.aspose.page.internal.l16l.I0l: Invalid Offset property value: GradientStop
com.aspose.xps.XpsGradientStop.ll(Unknown Source)
com.aspose.xps.XpsGradientStop.lIf(Unknown Source)
com.aspose.xps.XpsGradientStop.(Unknown Source)
com.aspose.xps.XpsGradientBrush.ll(Unknown Source)
com.aspose.xps.XpsGradientBrush.lif(Unknown Source)
com.aspose.xps.XpsLinearGradientBrush.lif(Unknown Source)
com.aspose.xps.XpsLinearGradientBrush.(Unknown Source)
com.aspose.xps.XpsBrush.lif(Unknown Source)
com.aspose.xps.XpsBrush.lif(Unknown Source)
com.aspose.xps.I81.lif(Unknown Source)
com.aspose.xps.I81.lif(Unknown Source)
com.aspose.xps.XpsPath.lif(Unknown Source)
com.aspose.xps.XpsPath.(Unknown Source)
com.aspose.xps.I10I.lif(Unknown Source)
com.aspose.xps.XpsElement.lif(Unknown Source)
com.aspose.xps.I10I.lif(Unknown Source)
com.aspose.xps.XpsElement.lif(Unknown Source)
com.aspose.xps.I10I.lif(Unknown Source)
com.aspose.xps.XpsElement.lif(Unknown Source)
com.aspose.xps.XpsPage.lif(Unknown Source)
com.aspose.xps.I1l.lif(Unknown Source)
com.aspose.xps.I1l.lif(Unknown Source)
com.aspose.xps.XpsDocument.liF(Unknown Source)
com.aspose.xps.XpsDocument.selectActivePage(Unknown Source)
com.aspose.xps.I10l.lf(Unknown Source)
com.aspose.xps.I10l.ll(Unknown Source)
com.aspose.xps.I4I.liF(Unknown Source)
com.aspose.xps.XpsDocument.ll(Unknown Source)
com.aspose.xps.XpsDocument.lif(Unknown Source)
com.aspose.xps.XpsDocument$I7.lif(Unknown Source)
com.aspose.page.internal.l421.Il.lif(Unknown Source)
com.aspose.page.internal.l421.II.lif(Unknown Source)
com.aspose.xps.XpsDocument.save(Unknown Source)
com.aspose.xps.XpsDocument.save(Unknown Source)
com.insolu.ImageWaterMark.test(ImageWaterMark.java:25)
com.insolu.OcrDemo.main(OcrDemo.java:13)
at com.aspose.xps.XpsGradientStop.ll(Unknown Source)
at com.aspose.xps.XpsGradientStop.lIf(Unknown Source)
at com.aspose.xps.XpsGradientStop.(Unknown Source)
at com.aspose.xps.XpsGradientBrush.ll(Unknown Source)
at com.aspose.xps.XpsGradientBrush.lif(Unknown Source)
at com.aspose.xps.XpsLinearGradientBrush.lif(Unknown Source)
at com.aspose.xps.XpsLinearGradientBrush.(Unknown Source)
at com.aspose.xps.XpsBrush.lif(Unknown Source)
at com.aspose.xps.XpsBrush.lif(Unknown Source)
at com.aspose.xps.I81.lif(Unknown Source)
at com.aspose.xps.I81.lif(Unknown Source)
at com.aspose.xps.XpsPath.lif(Unknown Source)
at com.aspose.xps.XpsPath.(Unknown Source)
at com.aspose.xps.I10I.lif(Unknown Source)
at com.aspose.xps.XpsElement.lif(Unknown Source)
at com.aspose.xps.I10I.lif(Unknown Source)
at com.aspose.xps.XpsElement.lif(Unknown Source)
at com.aspose.xps.I10I.lif(Unknown Source)
at com.aspose.xps.XpsElement.lif(Unknown Source)
at com.aspose.xps.XpsPage.lif(Unknown Source)
at com.aspose.xps.I1l.lif(Unknown Source)
at com.aspose.xps.I1l.lif(Unknown Source)
at com.aspose.xps.XpsDocument.liF(Unknown Source)
at com.aspose.xps.XpsDocument.selectActivePage(Unknown Source)
at com.aspose.xps.I10l.lf(Unknown Source)
at com.aspose.xps.I10l.ll(Unknown Source)
at com.aspose.xps.I4I.liF(Unknown Source)
at com.aspose.xps.XpsDocument.ll(Unknown Source)
at com.aspose.xps.XpsDocument.lif(Unknown Source)
at com.aspose.xps.XpsDocument$I7.lif(Unknown Source)
at com.aspose.page.internal.l421.Il.lif(Unknown Source)
at com.aspose.page.internal.l421.II.lif(Unknown Source)
at com.aspose.xps.XpsDocument.save(Unknown Source)
at com.aspose.xps.XpsDocument.save(Unknown Source)
at com.insolu.ImageWaterMark.test(ImageWaterMark.java:25)
at com.insolu.OcrDemo.main(OcrDemo.java:13)

1.png (163.3 KB)

https://1drv.ms/u/s!AncXAOrkBW5Pzx5vF91ZSHx366gb?e=tVfTX3[quote=“wanyangye, post:1, topic:206967, full:true”]
public class ImageWaterMark {
public static void test(){
getLicense(“C:\PrintHub\license\Aspose.Total.Product.Family.lic”);
String dataDir =“C:\PrintHub\docs\2019\7\9\”;
com.aspose.xps.XpsDocument doc = null;
try {
doc = new com.aspose.xps.XpsDocument(dataDir + “b71863d8-71d1-4e6e-8c79-d1a8a8a96003.xps”);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
long time1 = System.currentTimeMillis();
com.aspose.xps.XpsPath path = doc.addPath(doc.createPathGeometry(“M 30,20 l 258.24,0 0,56.64 -258.24,0 Z”));
// Creating a matrix is optional, it can be used for proper positioning
path.setRenderTransform(doc.createMatrix(0.7f, 0f, 0f, 0.7f, 0f, 20f));
// Create Image Brush
path.setFill(doc.createImageBrush(dataDir + “1.png”, new java.awt.geom.Rectangle2D.Double(0f, 0f, 258.24f, 56.64f), new java.awt.geom.Rectangle2D.Double(50f, 20f, 193.68f, 42.48f)));
// Save resultant XPS document
try {
doc.save(dataDir + “AddImage_out2.xps”);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
long time2 = System.currentTimeMillis();
System.out.println("加水印时间: "+(time2 - time1));

}

}
————————

Invalid Offset property value: GradientStop
com.aspose.xps.XpsGradientStop.ll(Unknown Source)
com.aspose.xps.XpsGradientStop.lIf(Unknown Source)
com.aspose.xps.XpsGradientStop.(Unknown Source)
com.aspose.xps.XpsGradientBrush.ll(Unknown Source)
com.aspose.xps.XpsGradientBrush.lif(Unknown Source)
com.aspose.xps.XpsLinearGradientBrush.lif(Unknown Source)
com.aspose.xps.XpsLinearGradientBrush.(Unknown Source)
com.aspose.xps.XpsBrush.lif(Unknown Source)
com.aspose.xps.XpsBrush.lif(Unknown Source)
com.aspose.xps.I81.lif(Unknown Source)
com.aspose.xps.I81.lif(Unknown Source)
com.aspose.xps.XpsPath.lif(Unknown Source)
com.aspose.xps.XpsPath.(Unknown Source)
com.aspose.xps.I10I.lif(Unknown Source)
com.aspose.xps.XpsElement.lif(Unknown Source)
com.aspose.xps.I10I.lif(Unknown Source)
com.aspose.xps.XpsElement.lif(Unknown Source)
com.aspose.xps.I10I.lif(Unknown Source)
com.aspose.xps.XpsElement.lif(Unknown Source)
com.aspose.xps.XpsPage.lif(Unknown Source)
com.aspose.xps.I1l.lif(Unknown Source)
com.aspose.xps.I1l.lif(Unknown Source)
com.aspose.xps.XpsDocument.liF(Unknown Source)
com.aspose.xps.XpsDocument.selectActivePage(Unknown Source)
com.aspose.xps.I10l.lf(Unknown Source)
com.aspose.xps.I10l.ll(Unknown Source)
com.aspose.xps.I4I.liF(Unknown Source)
com.aspose.xps.XpsDocument.ll(Unknown Source)
com.aspose.xps.XpsDocument.lif(Unknown Source)
com.aspose.xps.XpsDocument$I7.lif(Unknown Source)
com.aspose.page.internal.l421.Il.lif(Unknown Source)
com.aspose.page.internal.l421.II.lif(Unknown Source)
com.aspose.xps.XpsDocument.save(Unknown Source)
com.aspose.xps.XpsDocument.save(Unknown Source)
com.insolu.ImageWaterMark.test(ImageWaterMark.java:25)
com.insolu.OcrDemo.main(OcrDemo.java:13)
Exception in thread “main” class com.aspose.page.internal.l16l.I0l: Invalid Offset property value: GradientStop
com.aspose.xps.XpsGradientStop.ll(Unknown Source)
com.aspose.xps.XpsGradientStop.lIf(Unknown Source)
com.aspose.xps.XpsGradientStop.(Unknown Source)
com.aspose.xps.XpsGradientBrush.ll(Unknown Source)
com.aspose.xps.XpsGradientBrush.lif(Unknown Source)
com.aspose.xps.XpsLinearGradientBrush.lif(Unknown Source)
com.aspose.xps.XpsLinearGradientBrush.(Unknown Source)
com.aspose.xps.XpsBrush.lif(Unknown Source)
com.aspose.xps.XpsBrush.lif(Unknown Source)
com.aspose.xps.I81.lif(Unknown Source)
com.aspose.xps.I81.lif(Unknown Source)
com.aspose.xps.XpsPath.lif(Unknown Source)
com.aspose.xps.XpsPath.(Unknown Source)
com.aspose.xps.I10I.lif(Unknown Source)
com.aspose.xps.XpsElement.lif(Unknown Source)
com.aspose.xps.I10I.lif(Unknown Source)
com.aspose.xps.XpsElement.lif(Unknown Source)
com.aspose.xps.I10I.lif(Unknown Source)
com.aspose.xps.XpsElement.lif(Unknown Source)
com.aspose.xps.XpsPage.lif(Unknown Source)
com.aspose.xps.I1l.lif(Unknown Source)
com.aspose.xps.I1l.lif(Unknown Source)
com.aspose.xps.XpsDocument.liF(Unknown Source)
com.aspose.xps.XpsDocument.selectActivePage(Unknown Source)
com.aspose.xps.I10l.lf(Unknown Source)
com.aspose.xps.I10l.ll(Unknown Source)
com.aspose.xps.I4I.liF(Unknown Source)
com.aspose.xps.XpsDocument.ll(Unknown Source)
com.aspose.xps.XpsDocument.lif(Unknown Source)
com.aspose.xps.XpsDocument$I7.lif(Unknown Source)
com.aspose.page.internal.l421.Il.lif(Unknown Source)
com.aspose.page.internal.l421.II.lif(Unknown Source)
com.aspose.xps.XpsDocument.save(Unknown Source)
com.aspose.xps.XpsDocument.save(Unknown Source)
com.insolu.ImageWaterMark.test(ImageWaterMark.java:25)
com.insolu.OcrDemo.main(OcrDemo.java:13)
at com.aspose.xps.XpsGradientStop.ll(Unknown Source)
at com.aspose.xps.XpsGradientStop.lIf(Unknown Source)
at com.aspose.xps.XpsGradientStop.(Unknown Source)
at com.aspose.xps.XpsGradientBrush.ll(Unknown Source)
at com.aspose.xps.XpsGradientBrush.lif(Unknown Source)
at com.aspose.xps.XpsLinearGradientBrush.lif(Unknown Source)
at com.aspose.xps.XpsLinearGradientBrush.(Unknown Source)
at com.aspose.xps.XpsBrush.lif(Unknown Source)
at com.aspose.xps.XpsBrush.lif(Unknown Source)
at com.aspose.xps.I81.lif(Unknown Source)
at com.aspose.xps.I81.lif(Unknown Source)
at com.aspose.xps.XpsPath.lif(Unknown Source)
at com.aspose.xps.XpsPath.(Unknown Source)
at com.aspose.xps.I10I.lif(Unknown Source)
at com.aspose.xps.XpsElement.lif(Unknown Source)
at com.aspose.xps.I10I.lif(Unknown Source)
at com.aspose.xps.XpsElement.lif(Unknown Source)
at com.aspose.xps.I10I.lif(Unknown Source)
at com.aspose.xps.XpsElement.lif(Unknown Source)
at com.aspose.xps.XpsPage.lif(Unknown Source)
at com.aspose.xps.I1l.lif(Unknown Source)
at com.aspose.xps.I1l.lif(Unknown Source)
at com.aspose.xps.XpsDocument.liF(Unknown Source)
at com.aspose.xps.XpsDocument.selectActivePage(Unknown Source)
at com.aspose.xps.I10l.lf(Unknown Source)
at com.aspose.xps.I10l.ll(Unknown Source)
at com.aspose.xps.I4I.liF(Unknown Source)
at com.aspose.xps.XpsDocument.ll(Unknown Source)
at com.aspose.xps.XpsDocument.lif(Unknown Source)
at com.aspose.xps.XpsDocument$I7.lif(Unknown Source)
at com.aspose.page.internal.l421.Il.lif(Unknown Source)
at com.aspose.page.internal.l421.II.lif(Unknown Source)
at com.aspose.xps.XpsDocument.save(Unknown Source)
at com.aspose.xps.XpsDocument.save(Unknown Source)
at com.insolu.ImageWaterMark.test(ImageWaterMark.java:25)
at com.insolu.OcrDemo.main(OcrDemo.java:13)
[/quote]

file download link,Already sent [Adnan.Ahmad]

@wanyangye

We were able to replicate the issue in our environment and logged it as PAGEJAVA-85 in our issue tracking system. We will further look into details of this issue and keep you posted with the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.

The issues you have found earlier (filed as PAGEJAVA-85) have been fixed in Aspose.Page for Java 20.1.

I encountered the same problem again, the file is attached…

@wanyangye

There are 3 files over the link you shared. Are you facing issue with all files?

yes, Can the program output the log to a file after the program reports an error? The detailed content is, for example, the file name of the processing error, the corresponding error content, so that we can find the problem.

@wanyangye

We have tested the scenario in our environment with your all 3 files and noticed that program kept running and did not end with any result. Hence we have logged following issues in our issue tracking system:

  • PAGEJAVA-91 (915eb1e6-6c95-43fb-b9a3-023eb3e5774d.xps)
  • PAGEJAVA-92 (d353c367-7054-4c81-ab88-6f19e6efd5f9.xps)
  • PAGEJAVA-93 (a2e022c4-48db-4c31-88df-f90a8e791fdc.xps)

We have also mentioned your above concerns along with the logged tickets and will share updates with you as soon as we have some regarding their resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

  • PAGEJAVA-91 (915eb1e6-6c95-43fb-b9a3-023eb3e5774d.xps)
  • PAGEJAVA-92 (d353c367-7054-4c81-ab88-6f19e6efd5f9.xps)
  • PAGEJAVA-93 (a2e022c4-48db-4c31-88df-f90a8e791fdc.xps)
    Will cause out of memory。

338ed76a-7a1c-421b-a4dc-18a2fef86f06.xps、e7d934a7-12d4-4418-b3bc-ea47ee7f8c0e.xps,Handle watermark error 。。

@wanyangye

We again tried the scenario and noticed that out of memory exception occurs after 30 mins of code running. We have updated the issue information accordingly.

We tried to download the files but it gave 404 Not Found error. Would you please share the correct link to download the files.

The issues you have found earlier (filed as PAGEJAVA-91,PAGEJAVA-92,PAGEJAVA-93) have been fixed in Aspose.Page for Java 20.4.

@wanyangye

Adding more to notification of bug fixes, you might have noticed that the sample files are somewhat irregular XPS documents, since they contain no real text. All the glyphs are rendered into paths. It seems like these files are the result of printing some document with Mircosoft XPS document writer. This is the reason why these file are quite large, although not consisting of any enormous number of pages.

Instead, they contain the very large amount of paths (order of several millions) and points (a few times more than paths).

So, basically, there is no wonder why JVM hangs or gets crushed, since due to particular reasons we have to load the entire document into memory before we start to save it. One reason is that we have to handle internal hyperlinks, if they are present in a document.

Nevertheless, this time it was possible to reduce memory consumption to some extent. But how effective this fix is depends on a specific environment. Anyway, we must keep in mind that if it will work fine with these sample files, there’s absolutely no guarantee that it will work with similar documents with, say, 700, 800 or 1000 pages.

We have also received another link to 2 XPS files from you. Would you please share if you are facing similar issue with them?

338ed76a-7a1c-421b-a4dc-18a2fef86f06.xps、e7d934a7-12d4-4418-b3bc-ea47ee7f8c0e.xps

Are these two files?

  1. Two XPS files report error when processing watermarks. They are 338ed76a-7a1c-421b-a4dc-18a2fef86f06.xps.e7d934a7-12d4-4418-b3bc-ea47ee7f8c0e.xps. 2. Is Ver 20.4 optimized as you mentioned above.

@wanyangye

20.4 version of the API includes fixes against the above issues which were logged for out of memory exception. For the files (338ed76a-7a1c-421b-a4dc-18a2fef86f06.xps.e7d934a7-12d4-4418-b3bc-ea47ee7f8c0e.xps), separate issues have been logged in our issue tracking system as following:

  • PAGEJAVA-107 e7d934a7-12d4-4418-b3bc-ea47ee7f8c0e.xps
  • PAGEJAVA-108 338ed76a-7a1c-421b-a4dc-18a2fef86f06.xps

We will surely inform you as soon as they are resolved. Please spare us some time.