Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by oxa89 · Nov 20, 2014 at 01:21 AM · androidpathfindingpdf

Create iTextSharp PDF in Android

I am making a report in Unity3D with iTextSharp. When I start app from Unity it creates PDF and works perfect. But when I build App on Android device, I have a problem with creating font. Here is what I do:

 BaseFont bf = BaseFont.CreateFont(System.IO.Path.Combine(Application.streamingAssetsPath, "ADOBEARABIC-BOLD_0.OTF"), BaseFont.IDENTITY_H, false);

As I have seen, the first parameter for font creation is the path to the font. My font is in

/Assets/StreamingAssets/

folder.

When I try to load it with WWW class, it can find it, but when I give just the path to the creator it won't work.

Any idea what should I do? Or is there any other way to create a font that supports Arabic characters?

EDIT:

Ok, I have somehow managed to get to the font. First I copy font from Assets to the root of the APP:

 IEnumerator CopyFiles()
     {
         string fromPath = Application.streamingAssetsPath + "/";
         string toPath = Application.persistentDataPath + "/";
         string filesNamesToCopy = "ADOBEARABIC-BOLD_0.OTF";
         WWW www1 = new WWW(fromPath + filesNamesToCopy);
             yield return www1;
         File.WriteAllBytes(toPath + filesNamesToCopy , www1.bytes);
     }


And then I make BaseFont:

 BaseFont bf = BaseFont.CreateFont(System.IO.Path.Combine(Application.persistentDataPath, "ADOBEARABIC-BOLD_0.OTF"), BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

Now I get new error when try to build on Android device:

ArgumentException: Encoding name 'windows-1252' not supported Parameter: name

Comment
Add comment · Show 5
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Kjurek · May 07, 2015 at 07:39 AM 0
Share

Hi, oxa89. Did you found the solution for your problem? I have the same problem with accessing font on android. I cant figure it out how to use a custom font with itextsharp on android. The path in Editor works with no problem. But when I export it for Android, it cant be used.

J.

avatar image oxa89 · May 07, 2015 at 09:32 AM 0
Share

Nope, I couldn't solve the problem.

avatar image Kjurek · May 07, 2015 at 09:48 AM 0
Share

Its strange issue. I really don't know why android cant handle custom font file. The path is O$$anonymous$$. Its just how android is handling fonts. What about giving a try with different ttf? On this site they are exposing that some ttf fonts are not suitable to work on android. I will try with some other ttf if this will give me some positive feed back.

http://www.androidguys.com/2008/08/18/fun-with-fonts/

avatar image oxa89 · May 08, 2015 at 08:33 AM 0
Share

Please tell me if it works.

avatar image Kjurek · May 08, 2015 at 08:42 AM 0
Share

I opened another ticket regarding the problem and user Dibbie commented that Android cant handle fonts that are not installed on the system. That makes sense in your example and $$anonymous$$e. So there must be some workaround where system font would be used. $$anonymous$$aybe with FontFactory register method, where you look for system fonts installed on the system and you pick one from the list. I will try that.. But there is another concern, what if unity3d cant handle system fonts? :/

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Kjurek · May 08, 2015 at 06:15 PM

Here is solution to my problem:

http://answers.unity3d.com/answers/962657/view.html

Did you tried to copy DLL to project folder as it is written in this post?

http://answers.unity3d.com/questions/42955/codepage-1252-not-supported-works-in-editor-but-no.html

Because I don't need custom font, only font that can post special characters, I load it from system font directory directly on android device. Maybe, you will get a font that suits to your need in that directory also. After that I register it with FontFactory and it works!

Hope you will get some help from my solution.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

iOS can't open local file with Application.OpenURL() 1 Answer

Opening a PDF on Android 1 Answer

How to generate pdf for android? 2 Answers

Add a pdf file 0 Answers

Argument out of Range Exception Error - Parameter Name: Index 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges