How to convert from doc to pdf

I m using
code…
public class DOCToPDF { public static void main(String[] args) throws Exception { // The path to the documents directory. String dataDir = Utils.getDataDir(DOCToPDF.class); // Instantiate PDF object Pdf pdf1 = new Pdf(); // bind the source PCL file with Pdf object pdf1.bindPCL(dataDir + “letterlegal5.doc”); // save the resultant PDF document pdf1.save(dataDir + “converted.pdf”); System.out.println(“PCL to PDF conversion performed successfully!”); } }
it giving :-Error: Could not find or load main class com.aspose.pdf.examples.asposepdf.conversion.DOCToPDF

Could u help me.how to convert doc to pdf file.

Hi there,

Thanks for your inquiry. Please read following article about converting Word document to Pdf.
https://docs.aspose.com/words/java/convert-a-document-to-pdf/

Please let us know if you have any more queries.

Hi

Your link is too short.Please check in my queries and embed your code and rectify this.

Thanks
Ganesh kumar sharma
TrilaSoft Solutions Pvt Ltd.

Hi there,

Thanks for your inquiry. If you want to convert MS Word document to Pdf, you need to use Aspose.Words for Java. Please check following code example of Aspose.Words for Java to convert Word document to Pdf.

com.aspose.words.Document doc = **new** com.aspose.words.Document(*MyDir* + "Document.doc");
doc.save(*MyDir* + "Document.Doc2PdfSave Out.pdf");
//Instantiate LoadOption object using PCL load option
com.aspose.pdf.PclLoadOptions loadoptions = **new** com.aspose.pdf.PclLoadOptions();
//Create Document object
com.aspose.pdf.Document doc = **new** com.aspose.pdf.Document(*MyDir* + "in.pcl",loadoptions);
//Save the resultant PDF document
doc.save(*MyDir* + "Output.pdf");

Hope this helps you. If you still face problem, please share some more detail about your requirements. We will then provide you more information about your query along with code.

Hi Manzoor
I am using your code but some problem has been occurred.Could you give me com.aspose.words class code.so I can easily used.

Please check this Url for472284 in reply to 395305:-
Error trying to save a .doc to a pdf file
I have showing same Exception.Like this.
Exception in thread “main” class com.aspose.pdf.exceptions.InvalidPdfFileFormatException: Startxref not found

Hi there,

Thanks for your inquiry. Could you please share some detail about your requirement what exact you want to achieve using Aspose.Words and/or Aspose.Pdf? We will then provide you more information about your query along with code.

Please note that com.aspose.words.Document is used for Word Document and com.aspose.pdf.Document is used for Pdf Document.

I have word doc and I want to convert pdf file from doc file.Please if you have code then please share with me asap.

Hi there,

Thanks for sharing the detail. Please download latest version of Aspose.Words for Java 15.9.0 from here:
https://releases.aspose.com/words/java

Please use following code example to convert Word document to Pdf.

com.aspose.words.Document doc = new com.aspose.words.Document(MyDir + "input.docx");
doc.save(MyDir + "Out.pdf");

Please let us know if you have any more queries.

Hi **Manzoor

you have already given code for that:-

com.aspose.words.Document doc = new com.aspose.words.Document(MyDir + "input.docx");
doc.save(MyDir + "Out.pdf");

But I want to whole class code.How to use this code in class.

Hi there,

Thanks for your inquiry. Please note that Aspose.Words for Java
is a class library and with it you can programmatically generate,
modify, convert, render and print documents without utilizing Microsoft
Word®. The code of Aspose.Words APIs is not public/open source.

You can download Aspose.Words Jar file from here and use it in your application. Please read about Aspose.Words documentation from here:
https://docs.aspose.com/words/java/

Hi Manzoor
Thanks It is working.Could you Elaborate How much charges for paid.

Hi there,

Thanks for your inquiry. Please read about pricing information from here:
https://purchase.aspose.com/temporary-license

If you have any further query about purchasing license, please post your query in Aspose.Purchase forum.