Free Support Forum - aspose.com

How to get TextAutofitTypeEx?

Hi,

I am a new user of Aspose.slides Java and i am trying to access the TextAutofitTypeEx of a text frame. But there is no accessor method in TextFrameEx to do so.

Question: How can i access the TextAutofitTypeEx property of a text frame ?

Kind regards,

Micky

Hi Micky,


Thanks for inquiring Aspose.Slides.

I have observed the requirements shared by you and like to share that during coming week we are going to share the latest version of Aspose.Slides for Java 3.0.0. This version does have methods for setting and getting TextAutofitEx. The following code snippet will be used to serve the purpose.

public static void AddTextFrame() throws Exception
{
//Instantiate PresentationEx
PresentationEx pres = new PresentationEx();

//Get the first slide
SlideEx sld = pres.getSlides().get_Item(0);

//Add an AutoShape of Rectangle type
int idx = sld.getShapes().addAutoShape(ShapeTypeEx.Rectangle, 150, 75,150 , 50);
AutoShapeEx ashp = (AutoShapeEx)sld.getShapes().get_Item(idx);

//Add TextFrame to the Rectangle
ashp.addTextFrame(“Aspose TextBox”);
TextFrameEx txt=ashp.getTextFrame();
byte type=txt.getAutofitType();
txt.setAutofitType(TextAutofitTypeEx.Shape);
//Write the presentation to disk
pres.write(“d:\pptx\TextBox.pptx”);
}


Many Thanks,

Hi Mudassir,

Has the new Aspose.Slides Java been released yet ?

At this moment I cannot download Aspose.Slides from the site.

Regards, Micky

Hi Micky,


Please visit this link for downloading the latest release of Aspose.Slides for Java 3.0.0 on your end.

Many Thanks,

Hi Mudassir,

Thanks for the update. I have some questions about the new release:

- There are deprecated methods and classes, is there documentation on how to replace them ?

- Some of the naming convention looks more like .NET rather than Java (for example get_Item). Will there be another release that has Java naming convention ? (we don't want to alter lots of code if the situation is temporary)

Regards, Micky

Hi Micky,


I like to share that Aspose.Slides for Java 3.0.0 is the maiden release that has been developed by auto porting features from Aspose.Slides for .NET. In fact, you will find it more similar to Aspose.Slides for .NET as compared to older version of Aspose.Slides for Java. This has in fact brought uniformity in both API’s. Please visit this documentation link for your kind reference about migrating from older product version to newer one.

Many Thanks,

Hi Mudassir,

We migrated from Aspose.Slides Java 2.9.1 to 3.0.0 but opening a pptx now results in an error:

java.lang.UnsupportedOperationException: Culture "English" is a neutral culture. It can not be used in formatting and parsing and therefore cannot be set as the thread's current culture.

Regards, Micky

Hi Micky,


Can you please share the source presentation along with sample code snippet. Please also share the generated corrupted presentation as well for reference.

Many Thanks,

Hi Mudassir,

Attached is the pptx that could not be read. The exception is thrown when instantiating the PresentationEx. The code snippet is:

static PresentationEx createPptxFromFile(String templateFile) {
try {
InputStream in = getResource(templateFile);
PresentationEx pptxPresentation = new PresentationEx(in);
return pptxPresentation;
} catch (Exception e) {
throw new TechnicalException("Could not read template file", e);
}
}

protected static InputStream getResource(String resourceName) {
return Renderer.class.getResourceAsStream(resourceName);
}

Hi Micky,


I have modified your code snippet to get things going on my end and have been able to generate the PDF without any issue using Aspose.Slides for Java 3.0.0 without any issue. For your kind reference, I have shared the used code snippet and generated PDF. I have used JDK 1.6_27 installed on Windows 7 x64 on my end.

public static PresentationEx createPptxFromFile(String templateFile)
{
try
{
java.io.InputStream in = getResource(templateFile);
PresentationEx pptxPresentation = new PresentationEx(in);
return pptxPresentation;
} catch (Exception e)
{
//throw new TechnicalException(“Could not read template file”, e);
e.printStackTrace();
return null;
}
}

protected static java.io.InputStream getResource(String resourceName) throws Exception
{
return new java.io.FileInputStream(new java.io.File(resourceName));
}
//Function Calls
PresentationEx pres=createPptxFromFile(path+“report_template.pptx”) ;
pres.save(path+“testbardiag.pdf”,com.aspose.slides.SaveFormat.Pdf);


Many Thanks,

Hi Mudassir,

Apparently you could not reproduce the exception, which is :

java.lang.UnsupportedOperationException: Culture "English" is a neutral culture. It can not be used in formatting and parsing and therefore cannot be set as the thread's current culture.

The fix you had to make is for finding the file (because you don't have the Renderer class), but is not the solution to our problem.

We run on a Websphere v6.1 JRE (J2SE 1.5).

Regards, Micky

Hi Micky,


I doubt that you may be using wrong jar file for your implementation. For JDK 1.4 and 1.5, you need to use aspose.slides-3.0.0-jdk14.jar. For JDK 1.6 and above, you need to use aspose.slides-3.0.0.jar. If you are using the wrong jar file then please use the correct jar file. If there is still an issue then kindly share your feedback and I will create the issue for this as I have not been able to reproduce the issue on my end using JDK 1.6 installed on Windows 7.

Many Thanks,

Hi Mudassir,

Can you tell me where to find aspose.slides-3.0.0-jdk14.jar ?

Because in the downloads section i can only find the standard aspose.slides-3.0.0.jar

Regards, Micky

Hi Micky,


You can find the aspose.slides-3.0.0-jdk14.jar inside the lib folder of extracted Aspose.Slides for Java 3.0.0 package. Please share, if I may help you further in this regard.

Many Thanks,

Hi Mudassir,

I ran my code now with the aspose.slides-3.0.0-jdk14 jar file, but I still get:

java.lang.UnsupportedOperationException: Culture "English" is a neutral culture. It can not be used in formatting and parsing and therefore cannot be set as the thread's current culture.

Regards, Micky

Hi Micky,


I have created an issue with ID SLIDESJAVA-33580 in our issue tracking system to further investigate the issue shared in Websphere v6.1 with J2SE 1.5. This thread has been linked with the issue so that you may be automatically notified once the issue will be resolved.

We are sorry for your inconvenience,

The issues you have found earlier (filed as SLIDESJAVA-33580) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.