Free Support Forum - aspose.com

Getting started with evaluating aspose

hi,

i am a newbie at java programming. i have been tasked with evaluating the aspose.word for java. i downloaded the demo zip file. i have tried to add some of the .java files to a new java project that i created just for testing the aspose evaluation version.

can your demo version be used in this way?

i would like to manipulate the existing data in our database and output it in a doc, html, and pdf format.

do you have any more detailed documentation on how i can start doing this? also, where do i get the models/beans for document.java and documentbuilder.java?

thanks for your help on getting started,
sharon


This message was posted using Aspose.Live 2 Forum

Hello <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />Sharon.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for your interest in Aspose products.

Please be more specific in what you are going to do. Application data manipulation is not what Aspose.Words intended for. But you really can populate data into a word document using Mail Merge techniques or many other useful features. If you explain the task we can give more advice how to solve it. Once you have downloaded the distribution you can study from the demo application bundled with it.

You can refer to this page with Java package documentation:

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/com/aspose/words/package-summary.html

Please feel free to ask any questions, propose improvements and other share your experience. We’ll be glad to help you further.

Regards,

Hi,

Thank you for your response. I have created a Java web application, where users can enter and edit data. The users can also output the data into a report (MS Word document) by clicking a submit button (very similar to your "Generate" button on http://www.aspose.com:8081/aspose.words.demos.web/).

We would like to be able to output the data in italics, Rich Text Format, and HTML hyperlinks. We would also like to output an image to the report.

Is it possible to test this out? Do you have any documentation on how I can integrate this into my Java application?

Thanks!

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. You can use DocumentBuilder to build a Word document. See the following link for more information.

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/com/aspose/words/documentbuilder.html

Also see the following code.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

//Insert italic text

builder.setItalic(true);

builder.writeln("this is italic text");

//Clease text formating

builder.clearRunAttrs();

//Change text color

builder.getFont().setColor(new Color(0, 0, 255));

//Set underline

builder.setUnderline(Underline.SINGLE);

//Insert hyperlink

builder.insertHyperlink("Aspose", "http://www.aspose.com", false);

//Insert image into the document

builder.insertImage("C:\\Temp\\test.jpg");

doc.save("out.doc");

Unfortunately Aspose.Words for java doesn’t support RTF format. This feature will be implemented later hopefully in second half of this year.

Best regards.

Thanks! I was able to output to a Word document. However, I had to comment out the line "builder.getFont().setColor(new Color(0, 0, 255));". I get the following error when I leave this line in:

cannot find symbol
[javac] symbol : class Color
[javac] location: class com.aspose.web.action.StartAction
[javac] builder.getFont().setColor(new Color(0, 0, 255));
[javac] ^

What am I missing?

Thanks!

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Try adding

import java.awt.*;

or use

new java.awt.Color(0,0,255)

Best regards.

Thank you! Your solution worked.

Now, I am trying to remove borders and shading to a table.

I used a work-around to get rid of the shading: builder.getCellFormat().getShading().setBackgroundPatternColor(Color.WHITE);

I get errors when trying to remove the borders:
builder.getParagraphFormat().getBorders().clearFormatting();

No compile errors, but doesn't remove borders:
builder.getCellFormat().clearFormatting();

Also, we would like to output the report in PDF too. Would I just use the method Doc2PdfConverter?

Also, we have image files stored in a database as BLOBs, is there a way to output these images to a Word Document and PDF?

Thanks for your help!

(I am using Aspose.Words for Java.)

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request.

1. Borders are disabled by default. When you open the generated document using MS Word you should select “Hide Gridlines” from “Table” menu. You can’t hide gridlines using Aspose.Words because “Table / Hide Gridlines” is option of MSWord.

2. Unfortunately, java version of Aspose.Words doesn’t support PDF format yet. We are planning the complete reengineering of PDF module in .Net baseline. Only after the reengineering PDF module will be ported to Java.

Best regards.

Hi,

Thanks for your response.

What does the "Doc2PdfConverter" class do? Is this available in the Aspose.Words Java version? I noticed that it is called in the DemoGui.java file:

Doc2PdfConverter d2p = new Doc2PdfConverter(new FileOutputStream(dstFileName + ".pdf"));
doc.accept(d2p);

I added it to my code get the following error:

cannot find symbol
[javac] symbol : class Doc2PdfConverter
[javac] location: package com.aspose.model
[javac] import com.aspose.model.Doc2PdfConverter;
[javac] ^

Also, we have image files stored in a database as BLOBs, is there a way to output these images to a Word Document?

Thanks for your help!

(I am using Aspose.Words for Java.)

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Doc2Pdf demo just shows how Aspose.Words document model can be used to generate documents in arbitrary formats. It uses iText third-parity library to generate simplistic PDF from Aspose.Words document model. iText (and PDF!) was chosen randomly – it’s can be any other format and library.

So. If you need in real PDF (with images, accurate formatting and so one) you have to wait about a year or half a year when PDF module will be reengineered and ported to java.

Best regards,