Hi Tvk,
Thanks for your inquiry, As suggested in your
referenced post, on non-windows OSs issue caused due to font folder path setting. For example, at my machine
Ubuntu 13.10 I have installed Microsoft fonts and setting font path as following. You need to set font folder path according to your machine setting.
sudo apt-get install ttf-mscorefonts-installer
// Set font folder path
String path = “/usr/share/fonts/truetype/msttcorefonts/”;
// Adding a single font directory
// com.aspose.pdf.Document.addLocalFontPath(path);
// seting the user list for standard font directories
java.util.List list = com.aspose.pdf.Document.getLocalFontPaths();
list.add(path);
com.aspose.pdf.Document.setLocalFontPaths(list);
…
…
Please feel free to contact us for any further assistance.
Best Regards,
Hi Ahmad,
Thanks for your quick reply. I understand that the path would be different for linux systems, but my concern was more of what method to be used for com.aspose.pdf.facades.Form class.
I’m not using com.aspose.pdf.Document in my code.
My code is like this:
…
…
ByteArrayOutputStream bout = new ByteArrayOutputStream(rawData.length);
Form pdfForm = new Form(new ByteArrayInputStream(rawData), bout);
pdfForm.fillField(fieldName, fieldValue);
pdfForm.save();
return bout.toByteArray()
…
…
I don’t think the code you mentioned is applicable here. If its applicable then can you please give an example with the above code snippet?
Thanks,
Tvk Reddy
Hi Tvk,
Thanks for your inquiry. Same method will be used for Facades as well. it uses same font settings.
Moreover please note now input and output is dealt separately in Facades package using bindPdf() and save() method, please check following code for reference. Moreover, if you want you can use Document object in bindPdf() constructor as it accepts Document object as well.
// Set font folder path<o:p></o:p>
String path = "/usr/share/fonts/truetype/msttcorefonts/";
// Adding a single font directory
//
com.aspose.pdf.Document.addLocalFontPath(path);
// setting the user list for
standard font directories
java.util.List list =
com.aspose.pdf.Document.getLocalFontPaths();
list.add(path);
com.aspose.pdf.Document.setLocalFontPaths(list);
InputStream is = new
ByteArrayInputStream(rawData);
com.aspose.pdf.Document pdfDocument = new
com.aspose.pdf.Document(is);
ByteArrayOutputStream bout = new
ByteArrayOutputStream(rawData.length);
Form pdfForm= new Form();
pdfForm.bindPdf(pdfDocument);
//Form pdfForm = new Form(new
ByteArrayInputStream(rawData), bout);
pdfForm.fillField(fieldName, fieldValue);
pdfForm.save(bout);
return bout.toByteArray()
Please feel free to contact us for any further assistance.
Best Regards,
Hi Tvk,
Thanks for your feedback. It is good to know that code snippet worked for your to accomplish the task.
Please keep using Aspose API and feel free to asks any question or concern. We will be glad to extend our support.
Best Regards,
Hi Ahmed,
Using the code snippets provided by you we have run into another problem. The form.fillField method does add the values to the fields but when the value size is too large it gets reduced to such small font which is unreadable. Even if we try to zoom in the whole pdf expands but the value does not.
For example when the value is “Raj” it works absolutely fine. If we change the value to “qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq” a straight line is shown. It seems the length of the output to be displayed remains the same irrespective of the length of the value. Thus whether the value is “A” or “Raj” or “qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq” it tries to squeeze the display in the same length.
Could you help here as to what can be done to adjust the font for the values to be updated in the PDFs.
Regards,
TVK
Hi TVK,
Thanks for your inquiry. While testing the scenario with latest version of Aspose.Pdf for Java 9.7.0, we have managed to notice the font size issue and logged an investigation ticket PDFNEWJAVA-34632 in our issue tracking system for further investigation and resolution. We will notify you as soon as it is resolved.
We are sorry for the inconvenience caused.
Best Regards,