# Java Class not Found after import : com.spire.doc.Document

**URL:** <https://forums.pega.com/t/java-class-not-found-after-import-com-spire-doc-document/8276>\
**Category:** User Experience\
**Tags:** financial-services, 8-6-2, user-experience, data-integration, senior-system-architect, case-management\
**Created:** [September 16, 2024, 11:22am UTC](https://forums.pega.com/t/java-class-not-found-after-import-com-spire-doc-document/8276 "2024-09-16T11:22:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SANTOSHKUAMR\_V](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@SANTOSHKUAMR\_V](https://forums.pega.com/u/SANTOSHKUAMR_V)\
**Post date:** [September 16, 2024, 11:22am UTC](https://forums.pega.com/t/java-class-not-found-after-import-com-spire-doc-document/8276/1 "2024-09-16T11:22:56Z")

</div>

Hi All,

I imported Spire.Doc Java library for my requirement of Convert Docx stream to PDf stream by using this library. all the clsses are imported and able to access but Below class also deployed but not able to locate it in Pega.

Class: com.spire.doc.Document

Error: Failed to retrieve Java class location

If i use this class references in my function, I am not getting compilation errors but the code is not executing.

Example code:

try{  
byte DocBytes2 = Base64.getDecoder().decode(DocStream);  
ByteArrayInputStream instream = new ByteArrayInputStream(DocBytes2);  
ByteArrayOutputStream pdfstream = new ByteArrayOutputStream();

Document document = new Document();  
document.loadFromStream(instream, FileFormat.Docx);  
document.saveToStream(pdfstream, FileFormat.PDF);

return pdfstream;  
}  
catch (Exception e) {

String Error = e.toString();

return Error;  
}

---

<div class="post-metadata">

**Author:** ![MarijeSchillern](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/marijeschillern/32/23321_2.png) [@MarijeSchillern](https://forums.pega.com/u/MarijeSchillern)\
**Post date:** [October 7, 2024, 7:35pm UTC](https://forums.pega.com/t/java-class-not-found-after-import-com-spire-doc-document/8276/2 "2024-10-07T19:35:00Z")

</div>

@SANTOSHKUAMR V It seems like you are facing an issue with locating the com.spire.doc.Document class in Pega after importing the Spire.Doc Java library. This issue might be similar to the one discussed in the context where users faced issues with imported jars not being recognized in Pega. One suggested approach is to create a Library declare the packages and classes to import and then create a Function to do what you need. Once the Function is compiled you should be able to use it. This method has been found to work for similar issues.

⚠ This is a GenAI-powered tool. All generated answers require validation against the provided references.

[Unable to use imported Jar in java step in an activity](https://support.pega.com/question/unable-use-imported-jar-java-step-activity)

---

<div class="post-metadata">

**Author:** ![SANTOSHKUAMR\_V](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@SANTOSHKUAMR\_V](https://forums.pega.com/u/SANTOSHKUAMR_V)\
**Post date:** [October 22, 2024, 6:33am UTC](https://forums.pega.com/t/java-class-not-found-after-import-com-spire-doc-document/8276/3 "2024-10-22T06:33:19Z")

</div>

@MarijeSchillern , As suggested I tried that option. Function and library complied successfully, But runtime that line of code in the function is not executing. No errors in the logs as well. Completely strange behavior.

We also tried another Java package, but there also facing issue - conversion was sucessful but FONT getting changed.

Looks like Pega don’t have solution to convert the DOCx document to PDF document. We may have to go for another approach which is out of Pega.

---

<div class="post-metadata">

**Author:** ![MarijeSchillern](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/marijeschillern/32/23321_2.png) [@MarijeSchillern](https://forums.pega.com/u/MarijeSchillern)\
**Post date:** [October 22, 2024, 8:51am UTC](https://forums.pega.com/t/java-class-not-found-after-import-com-spire-doc-document/8276/4 "2024-10-22T08:51:08Z")

</div>

@SANTOSHKUAMR V Pega does not currently provide an out of the box (OOTB) solution to convert DOCx documents to PDF. However there are discussions about this feature being evaluated for future releases. Users have shared experiences with using Java code to implement conversions but these approaches may have limitations. For example one user mentioned using a base64 stream to convert Word documents to PDF in Pega 8.4.3. Additionally while Pega Robotics can save Word documents as PDFs it does not have a specific component for direct PDF creation from text or HTML content.

⚠ This is a GenAI-powered tool. All generated answers require validation against the provided references.

[Convert Docx (Word document) to PDF in 8.1 and above](https://support.pega.com/discussion/convert-docx-word-document-pdf-81-and-above)

[Ask the Expert - Pega and PDFs with Rahul Bojanapally and Sangeeta Kottilinga](https://support.pega.com/discussion/ask-expert-pega-and-pdfs-rahul-bojanapally-and-sangeeta-kottilinga)

@SangeetaKottilinga I am trying to attach an official Product Enhancement Request work ID to this question but have not found a single entity that encompasses the considered work.

Based on your answer in the above **Ask the Expert** session, please can you provide the active FDBK/ US?

There is no information why the following items were recently closed with no action:

FDBK-25889 ( _Amyuni Word to PDF converter replacement_)

FDBK-26944 (_Enhancement request - docx to PDF conversion service_)

US-363406 (_Converting platform generated DOCX to PDF_)

What is the ID of an open AS item?
