Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. InputStream is = null;
  2. ByteArrayOutputStream memoryStream=null;
  3. ContentReader oWORDContent=null;
  4.  
  5. WordprocessingMLPackage wordMLPackage=null;
  6.  
  7. try {
  8.  
  9. memoryStream = new ByteArrayOutputStream();
  10.  
  11. // Get the document from the repo
  12. NodeRef oNodeRef = new NodeRef("workspace","SpacesStore",docRef);
  13.  
  14. oWORDContent = getReader(oNodeRef);
  15.  
  16. // Get content into InputStream
  17. is = oWORDContent.getContentInputStream();
  18.  
  19. try {
  20.  
  21. wordMLPackage = WordprocessingMLPackage.load(is);
  22.  
  23.  
  24. //custom properties
  25. org.docx4j.openpackaging.parts.DocPropsCustomPart docPropsCustomPart = wordMLPackage.getDocPropsCustomPart();
  26.  
  27. // DO things here regarding the properties...
  28.  
  29.  
  30. System.out.println("before save");
  31.  
  32. // save to a memory stream
  33. wordMLPackage.save(memoryStream);
  34.  
  35. System.out.println("after save");
  36.  
  37. }
  38. catch (Docx4JException e) {
  39.  
  40. System.out.println("error1" );
  41.  
  42. } catch (Exception e) {
  43. System.out.println("error2" );
  44.  
  45. }
  46.  
  47. // do something here with bytearray... cant reach this
  48.  
  49. }
  50.  
  51. catch (IOException e)
  52. {
  53. System.out.println("error3");
  54.  
  55.  
  56. }
  57. catch(Exception e){
  58. System.out.println("error4");
  59.  
  60. }
  61.  
  62. finally
  63. {
  64. System.out.println("I reach this...");
  65. }
  66.  
  67.  
  68. I can load and get the properties of the document.
  69.  
  70. debug info: I have an error but it doesnt seems to have to do with the save method, because I can reach "before save" after.
  71.  
  72. ERROR [docx4j.jaxb.NamespacePrefixMapperUtils] [http-apr-8080-exec-9] name: com.sun.xml.internal.bind.namespacePrefixMapper value: org.docx4j.jaxb.NamespacePrefixMapperSunInternal@3332d32c .. trying RI.
  73.  
  74. before save
  75. I reach this...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement