Free Support Forum - aspose.com

PPT to PDF splits text in a text box

The attached pptx slide splits the word “Premium” when rendered to PDF. Is there an option I can use to make sure the text fits?


I am using aspose.slides-15.1.0-jdk16.jar

Here is the conversion code:

protected void saveAsPdf( AssetTypeBean assetType, File pptFile, String fn ) throws Exception {
PerformanceMonitor.start( PerformanceMonitor.DOC_CONV_CATEGORY, “PPT saveAsPdf” );

Presentation ppt = null;
try {
int maxPages = SystemConfig.getIntegerProperty( “MaxPdfPages”, 200 );
ppt = new Presentation( pptFile.getAbsolutePath() );
int numSlides = ppt.getSlides().size();
if ( numSlides > maxPages ) {
l4j.debug( “The power point document has " + numSlides + " slides, truncating the PDF part to "
+ maxPages + " pages.” );
// Strange!
int[] slidePositions = new int[maxPages];
for ( int pos = 0; pos < maxPages; ++pos ) {
slidePositions[pos] = pos + 1;
}
ppt.save( fn, slidePositions, SaveFormat.Pdf );
} else {
l4j.debug( “The power point document has " + numSlides
+ " slides, the PDF part will contain the entire document.” );
ppt.save( fn, SaveFormat.Pdf );
}
} finally {
try {
if ( ppt != null ) {
// Releases all resources used by this Aspose.Slides.Pptx.PrentationEx object
ppt.dispose();
}
} catch ( Throwable t ) {
// ignore.
}
PerformanceMonitor.stop( PerformanceMonitor.DOC_CONV_CATEGORY, “PPT saveAsPdf” );
}
}

Hi Bob,

I have worked with the presentation file shared by you and have been able to observe the issue specified. An issue with ID SLIDESJAVA-34764 has been created in our issue tracking system to further investigate and resolve the issue. 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,

Hi Bob,

Our development team has investigated the issue on their end. Actually, the change in font happened owing to JDK issue with Calibri font rendering. This problem occurs if used JDK 1.6.0_45, but this version of JDK has problems with rendering Calibri font. Word “Premium” draws well if used a different version of JDK, for example 1.6.0_39. Please share with us if you are using any other JDK version on your end. Also, please try using Aspose.Slides for Java 15.2.0 on your end.

PS: The Calibri font bug exists in JDK 1.6_45
and JDK 1.7_21. There is no issue in JDK 1.6_38, JDK 1.6_39, JDK 1.6_41,
JDK 1.6_43, JDK 1.7_17, JDK 1.7_25.


Many Thanks,

Hi Mudassir,


Thank you for the information. I changed my application to use JDK 1.6_43 and the slide rendered correctly.

Do you have any idea how IBM J9 compilers map to these Oracle versions? Our client is using this java compiler and is having similar issues.

[wasadmin@lxcosfntmd bin]$ ./java -version java version
"1.6.0"Java™ SE Runtime Environment (build
pxa6460_26sr8ifix-20140630_01(SR8+IX90144+IV62044))

IBM J9 VM (build 2.6, JRE 1.6.0 Linux amd64-64 Compressed
References

<o:p></o:p>

20140409_195736 (JIT enabled, AOT enabled) J9VM - R26_Java626_SR8_20140409_1526_B195736

JIT - r11.b06_20140409_61252

GC - R26_Java626_SR8_20140409_1526_B195736_CMPRSS

J9CL - 20140409_195736)

JCL - 20140406_01

Hi Bob,


I have observed your inquiry concerning to IBM J9 compiler mapping to Oracle JDK versions and regret to share that I may only help you w.r.t Aspose.Slides. I request you to please consult Oracle support team in this regard for further guidance. You are always more than welcome for inquiries concerning to Aspose.Slides.

Many Thanks,

Thanks for your help. I understand.

My support colleague has told me that they also see this issue on a Linux system while the java bug you mentioned is for Windows only so they may be another issue. He ran an Aspose recommended test program (see below) to verify the fonts installed and found that the <span style=“font-size:11.0pt;font-family:“Calibri”,sans-serif;
mso-fareast-font-family:“MS Mincho”;mso-fareast-theme-font:minor-fareast;
mso-bidi-font-family:“Times New Roman”;color:#1F497D;mso-ansi-language:EN-US;
mso-fareast-language:JA;mso-bidi-language:AR-SA”>Calibri and Cambria fonts are not installed on that system.

<span style=“font-size:11.0pt;font-family:“Calibri”,sans-serif;
mso-fareast-font-family:“MS Mincho”;mso-fareast-theme-font:minor-fareast;
mso-bidi-font-family:“Times New Roman”;color:#1F497D;mso-ansi-language:EN-US;
mso-fareast-language:JA;mso-bidi-language:AR-SA”>
<span style=“font-size:11.0pt;font-family:“Calibri”,sans-serif;
mso-fareast-font-family:“MS Mincho”;mso-fareast-theme-font:minor-fareast;
mso-bidi-font-family:“Times New Roman”;color:#1F497D;mso-ansi-language:EN-US;
mso-fareast-language:JA;mso-bidi-language:AR-SA”>He mentions this from Aspose Words:

<span style=“font-size:11.0pt;font-family:“Calibri”,sans-serif;
color:#1F497D”>Aspose has this to say about installing those fonts manually: http://www.aspose.com/docs/display/wordsjava/How+to++Install+True+Type+Fonts+on+Linux<o:p></o:p>

An easy and quick way is to copy .TTF and .TTC files from the C:\Windows\Fonts directory on a Windows machine to some directory on your Linux machine. You do not need to install or register these fonts on Linux in any way, you just need to specify the location of the fonts using the FontSettingsclass in Aspose.Words.”

I do not see a FontSettings class for Aspose Slides. If I copy the TTF and TTC settings to the Linux system is there a way to tell slides they are there? and will this help?

Regards,

Bob Hastings


Here is the Font Settings test source code and output:

final java.awt.GraphicsEnvironment gEnv =

java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment();

final String envfonts[] = gEnv.getAvailableFontFamilyNames();

for(String font : envfonts) {

final String txt = "Test";

final java.text.AttributedString str = new java.text.AttributedString(txt);

str.addAttribute(java.awt.font.TextAttribute.FAMILY, font, 0, txt.length());

str.addAttribute(java.awt.font.TextAttribute.SIZE, (float) 14.0);

str.addAttribute(java.awt.font.TextAttribute.WEIGHT, java.awt.font.TextAttribute.WEIGHT_BOLD, 0, txt.length());

final java.awt.font.FontRenderContext fontRenderContext = new java.awt.font.FontRenderContext(null, true, true);

final java.awt.font.TextLayout layout = new java.awt.font.TextLayout(str.getIterator(), fontRenderContext);

System.out.println(font + " : " + layout.getBounds().getWidth());

}

Output:

Abyssinica SIL : 28.4677734375

AR PL UMing CN : 30.4375

AR PL UMing HK : 30.4375

AR PL UMing TW : 30.4375

AR PL UMing TW MBE : 30.4375

Bitstream Charter : 26.789520263671875

Caladea : 27.324722290039062

Carlito : 24.095703125

Century Schoolbook L : 30.59893798828125

Courier 10 Pitch : 32.504486083984375

Cursor : 0.0

DejaVu Sans : 33.6904296875

DejaVu Sans Condensed : 30.30859375

DejaVu Sans Light : 32.3076171875

DejaVu Sans Mono : 32.0048828125

DejaVu Serif : 33.45703125

DejaVu Serif Condensed : 30.08203125

Dialog : 30.7626953125

DialogInput : 32.666015625

Dingbats : 0.0

Hershey : 28.486541748046875

Jomolhari : 29.90625

Khmer OS : 29.9140625

Khmer OS Content : 29.9140625

Khmer OS System : 29.9140625

Liberation Mono : 31.8603515625

Liberation Sans : 28.4521484375

Liberation Serif : 25.375

LKLUG : 0.0

Lohit Assamese : 57.904510498046875

Lohit Bengali : 57.904510498046875

Lohit Devanagari : 57.916015625

Lohit Gujarati : 53.716339111328125

Lohit Kannada : 44.3125

Lohit Oriya : 44.3125

Lohit Punjabi : 57.904510498046875

Lohit Tamil : 53.693359375

Lohit Telugu : 22.35546875

Lucida Bright : 30.009765625

Lucida Sans : 30.7626953125

Lucida Sans Typewriter : 32.666015625

Madan2 : 0.0

Meera : 22.4248046875

Monospaced : 32.666015625

Nimbus Mono L : 31.9986572265625

Nimbus Roman No9 L : 26.19158935546875

Nimbus Sans L : 23.161758422851562

Padauk : 25.23046875

PakTypeNaqsh : 33.8935546875

PakTypeTehreer : 29.5673828125

SansSerif : 30.7626953125

Serif : 30.009765625

Standard Symbols L : 0.0

STIXGeneral : 25.19158935546875

Tibetan Machine Uni : 31.728515625

UnDotum : 29.339859008789062

Unikurd Web : 30.1083984375

URW Bookman L : 31.4830322265625

URW Chancery L : 21.9029541015625

URW Gothic L : 24.91033935546875

URW Palladio L : 26.838485717773438

Utopia : 27.249404907226562

VL Gothic : 29.484695434570312

Waree : 33.6904296875

WenQuanYi Zen Hei : 29.2890625

WenQuanYi Zen Hei Mono : 29.484375

WenQuanYi Zen Hei Sharp : 29.2890625


I found this: http://docs.aspose.com:8082/docs/display/slidesjava/Using+Custom+Fonts+without+Installing+them


Is this what is needed?

String[] _fontDir = new String[] { “D:\Sample Fonts” };
<span class="code-comment" style="color: rgb(128, 128, 128); background-color: inherit;">//Load the custom font directory fonts

FontsLoader.loadExternalFonts(_fontDir);

Hi Bob,


The link shared by you is the right link for your case. I also suggest you to clear the loaded fonts cache once you have used them.

FontsLoader.clearCache();

Many Thanks,

Thanks for your help. I have implemented the solution using the FontsLoader and the problem has been resolved.

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


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.