When trying to add text to the fragment the application is crashing
textBuilder.appendText(textFrag);
This works fine when running on my PC but when it’s applied to the iSeries the same code fails. And the exception error is null
When trying to add text to the fragment the application is crashing
textBuilder.appendText(textFrag);
This works fine when running on my PC but when it’s applied to the iSeries the same code fails. And the exception error is null
@nickba,
Kindly send the complete details of the use case, including source PDF, code, JDK version, Java IDE and iSeries (edition and name). We will investigate and share our findings with you.
Hi Sorry about the delay.
Source
package blu.test;
import java.io.*;
import java.util.List;
import java.awt.*;
import com.aspose.pdf.*;
import com.aspose.pdf.Color;
import com.aspose.pdf.Font;
class Printfile
{
public static void main( String args[] ) throws Exception{
// Load the license
String fonts[] =
GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
for ( int i = 0; i < fonts.length; i++ )
{
System.out.println(fonts[i]);
}
Font font = null;
License licPdf = new License();
licPdf.setLicense(new FileInputStream("/java/bins/Aspose.Pdf.lic"));
// Always use this font for basic printing as spacing and alignment is automatically implemented
List<String> fontPaths = com.aspose.pdf.Document.getLocalFontPaths();
fontPaths.add("/java/fonts/");
com.aspose.pdf.Document.setLocalFontPaths(fontPaths);
font = FontRepository.openFont("/java/fonts/lucon.ttf");
if ( font == null)
System.out.println("font failed");
Document pdfDoc = new Document();
Page pdfPage = pdfDoc.getPages().add();
TextBuilder textBuilder = new TextBuilder(pdfPage);
String data = "Test print facility";
try{
TextFragment textFrag = new TextFragment(data);
textFrag.setPosition(new Position(3, 500));
textFrag.getTextState().setFont(font);
textFrag.getTextState().setFontSize(12);
textFrag.getTextState().setForegroundColor(Color.getBlack());
// create TextBuilder object
// append the text fragment to the PDF page
textBuilder.appendText(textFrag);
}
catch ( Exception er)
{
System.out.println(er.getMessage());
}
pdfDoc.save("/pdf/delcontract.pdf");
System.exit(0);
}
}
JDK Version : QIBM/ProdData/JavaVM/jdk80/64bit
Was created in Eclipse but compiled directly on IBMi,
Iseries V7R2M0
Output from the is
Courier Symbols
Dialog
DialogInput
Helvetica Symbols
Lucida Bright
Lucida Sans
Lucida Sans Typewriter
Monospaced
SansSerif
Serif
Times New Roman Symbols
WT Sans
WT Sans HK
WT Sans HK EA
WT Sans IN
WT Sans J
WT Sans J EA
WT Sans K
WT Sans K EA
WT Sans ME
WT Sans SC
WT Sans SC EA
WT Sans SEA
WT Sans TW
WT Sans TW EA
WT SansDuo
WT SansDuo HK
WT SansDuo HK EA
WT SansDuo IN
WT SansDuo J
WT SansDuo J EA
WT SansDuo K
WT SansDuo K EA
WT SansDuo ME
WT SansDuo SC
WT SansDuo SC EA
WT SansDuo SC xB
WT SansDuo SEA
WT SansDuo TW
WT SansDuo TW EA
WT Serif
WT Serif HK
WT Serif HK EA
WT Serif IN
WT Serif J
WT Serif J EA
WT Serif K
WT Serif K EA
WT Serif ME
WT Serif SC
WT Serif SC EA
WT Serif SEA
WT Serif TW
WT Serif TW EA
WT SerifDuo
WT SerifDuo HK
WT SerifDuo HK EA
WT SerifDuo IN
WT SerifDuo J
WT SerifDuo J EA
WT SerifDuo K
WT SerifDuo K EA
WT SerifDuo ME
WT SerifDuo SC
WT SerifDuo SC EA
WT SerifDuo SEA
WT SerifDuo TW
WT SerifDuo TW EA
**This is the exception error when doing the “textFrag.getTextState().setFont(font);” **
null
Java program completed
Please let me know if you need anything else. It’s clearly only occurring when trying to do the setfont. If I don’t try and set the font the application completes normally.
Thanks
Hi I’ve made another change to try something else
package blu.test;
import java.io.*;
import java.util.Iterator;
import java.util.List;
import com.aspose.pdf.*;
import com.aspose.pdf.Color;
import com.aspose.pdf.Font;
import com.aspose.pdf.internal.p229.z150;
import com.aspose.pdf.text.FontSourceCollection;
class Printfile
{
public static void main( String args[] ) throws Exception{
Font font = null;
License licPdf = new License();
licPdf.setLicense(new FileInputStream("/java/bins/Aspose.Pdf.lic"));
// Always use this font for basic printing as spacing and alignment is automatically implemented
List<String> fontPaths = com.aspose.pdf.Document.getLocalFontPaths();
fontPaths.add("/java/fonts/");
com.aspose.pdf.Document.setLocalFontPaths(fontPaths);
FontRepository.loadFonts();
FontSourceCollection fontCol = FontRepository.getSources();
Iterator tr = fontCol.iterator();
while(tr.hasNext())
{
com.aspose.pdf.SystemFontSource i = (SystemFontSource) tr.next();
z150 fonts1[] = i.getFontDefinitions();
for ( z150 t : fonts1)
{
System.out.println(t.m1() + " " + t.m3() );
}
System.out.println(i.getFontDefinitions());
}
font = FontRepository.findFont("Calibri");
if ( font == null)
System.out.println("font failed");
Document pdfDoc = new Document();
Page pdfPage = pdfDoc.getPages().add();
TextBuilder textBuilder = new TextBuilder(pdfPage);
String data = "Test print facility";
try{
TextFragment textFrag = new TextFragment(data);
textFrag.setPosition(new Position(3, 500));
textFrag.getTextState().setFont(font);
textFrag.getTextState().setFontSize(12);
textFrag.getTextState().setForegroundColor(Color.getBlack());
// create TextBuilder object
// append the text fragment to the PDF page
textBuilder.appendText(textFrag);
}
catch ( Exception er)
{
System.out.println(er.getMessage());
}
pdfDoc.save("/pdf/delcontract.pdf");
System.exit(0);
}
}
Still throws the same error even though it does have the font in the list
Segoe Setup Semilight SegoeSetup-Semilight
Shruti Shruti
Microsoft YaHei UI MicrosoftYaHeiUI
Microsoft JhengHei UI MicrosoftJhengHeiUIRegular
Meiryo UI MeiryoUI
Malgun Gothic MalgunGothicRegular
Segoe UI Semibold SegoeUI-Semibold
Calibri Bold Calibri-Bold
Calibri Bold Italic Calibri-BoldItalic
Calibri Calibri
Calibri Italic Calibri-Italic
Cambria Bold Italic Cambria-BoldItalic
Cambria Bold Cambria-Bold
Cambria Italic Cambria-Italic
Cambria Cambria
Candara Bold Italic Candara-BoldItalic
Candara Bold Candara-Bold
Candara Italic Candara-Italic
Candara Candara
Leelawadee Bold Leelawadee-Bold
Leelawadee Leelawadee
Leelawadee UI Bold LeelawadeeUI-Bold
Latha Bold Latha-Bold
Latha Latha
Lao UI Bold LaoUI-Bold
Lao UI LaoUI
kor_boot kor_boot
Mangal Mangal
Segoe UI SegoeUI
Constantia Bold Constantia-Bold
Constantia Test Italic Constantia-BoldItalic
Courier New Bold CourierNewPS-BoldMT
Courier New CourierNewPSMT
Consolas Consolas
Leelawadee UI LeelawadeeUI
cht_boot cht_boot
Lucida Console LucidaConsole
Microsoft New Tai Lue MicrosoftNewTaiLue
Microsoft JhengHei Boot MicrosoftJhengHeiBoot
Shruti Bold Shruti-Bold
chs_boot chs_boot
Times New Roman Italic TimesNewRomanPS-ItalicMT
Times New Roman Bold Italic TimesNewRomanPS-BoldItalicMT
Times New Roman Bold TimesNewRomanPS-BoldMT
Times New Roman TimesNewRomanPSMT
Khmer UI Bold KhmerUI-Bold
Segoe UI Semilight SegoeUI-Semilight
Segoe UI Light SegoeUI-Light
Microsoft Tai Le Bold MicrosoftTaiLe-Bold
Microsoft Tai Le MicrosoftTaiLe
Gautami Bold Gautami-Bold
Segoe Boot Semilight SegoeBoot-Semilight
Segoe Boot Semilight SegoeBoot-Semilight
Gautami Gautami
Gadugi Bold Gadugi-Bold
Khmer UI KhmerUI
Gadugi Gadugi
Segoe Mono Boot SegoeMonoBoot
Kartika Bold Kartika-Bold
Tahoma Bold Tahoma-Bold
Arial Italic Arial-ItalicMT
Arial Bold Italic Arial-BoldItalicMT
Kartika Kartika
Arial Bold Arial-BoldMT
Kalinga Bold Kalinga-Bold
Euphemia EuphemiaCAS
Estrangelo Edessa EstrangeloEdessa
Kalinga Kalinga
Arial Black Arial-Black
Raavi Bold Raavi-Bold
Raavi Raavi
jpn_boot jpn_boot
Iskoola Pota Bold IskoolaPota-Bold
Javanese Text JavaneseText
Iskoola Pota IskoolaPota
Nyala Nyala-Regular
Corbel Corbel
wgl4_boot wgl4_boot
Corbel Italic Corbel-Italic
Corbel Test Bold Corbel-Bold
Corbel Test Bold Italic Corbel-BoldItalic
Ebrima Bold Ebrima-Bold
Ebrima Ebrima
Microsoft New Tai Lue Bold MicrosoftNewTaiLue-Bold
Microsoft Himalaya MicrosoftHimalaya
Tahoma Tahoma
Malgun Gothic Boot MalgunGothicBoot
Myanmar Text MyanmarText
Microsoft Sans Serif MicrosoftSansSerif
Meiryo Boot MeiryoBoot
Meiryo Boot MeiryoBoot
Mangal Bold Mangal-Bold
Marlett Marlett
Arial Narrow Bold Italic ArialNarrow-BoldItalic
Arial Narrow ArialNarrow
Arial Narrow Bold ArialNarrow-Bold
Arial Narrow Italic ArialNarrow-Italic
Baskerville Old Face BaskOldFace
Algerian Algerian
Britannic Bold BritannicBold
Arial ArialMT
[Lcom.aspose.pdf.internal.p229.z150;@e97c3df9
null
@nickba,
Kindly send us your font file lucon.ttf which you are using in your code. Your response is awaited.
@nickba,
Based on the initial investigation, we could not replicate this error in our environment. Please let us know which Aspose.Pdf for Java API version you are using. If you are not using the latest version 17.8, then we would recommend you please try the latest version 17.8 of Aspose.Pdf for Java API, and then let us know how that goes into your environment.
@nickba,
Kindly create a small eclipse project, which reproduces this error in your environment, and then share the Zip of this project. We will investigate and share our findings with you.
@nickba,
We have logged an investigation under the ticket ID PDFNET-43447 in our bug tracking system and linked your post to this ticket. We will keep you informed regarding any available updates. Furthermore, we have published the new version 17.9, kindly download and try the latest version 17.9 in your iSeries machine and let us know how that goes into your environment.
@nickba,
Thank you for the confirmation. We will let you know once the linked ticket ID PDFNET-43447 is resolved.