- Posts: 37
- Thank you received: 1
Microsoft Windows Phone 8.1 support ends (13 Jul 2017)
Microsoft has ended support for Windows Phone 8.1
Questions about Android development and PDF
How to Copy Page Content
IP: 192.168.0.71
8 years 10 months ago - 8 years 10 months ago #12336
by ashughes
How to Copy Page Content was created by ashughes
Question:
Is there a way to copy PageContent, specifically Text (including any embedded fonts), from one page to another?
Background information:
Our application displays text by drawing to an Android Canvas using drawText(). This uses the Android system fonts, including any fallback fonts, to make sure the text is displayed. There isn't any way to determine which fonts are used by the system to display a particular text.
When we export a note to a PDF that contains text as described above, we have to specify which font to use. As I mentioned above, this is not something that can be queried. If we use Roboto, and the text is Japanese characters, then the PDF will display tofu (font squares) for the text.
A workaround for this we discovered is using the PDF support that is built into Android starting in API 19: developer.android.com/reference/android/...pdf/PdfDocument.html
Using the Android PdfDocument, we can create a PDF with a single page that contains the text displayed the exact same way it is displayed in the app. The Android PdfDocument determines which fonts are used by the text and embeds them into the PDF. It is able to do this because it uses the same Canvas API that's used for drawing to the screen (and therefore it knows which fonts to use at that low level).
Once we have created the PDF that contains the text as described above, we would like to open this PDF using the Radaee SDK and copy this text object (including the embedded fonts) to another PDF.
For clarification, we're dealing with PDF content, not Annotations. There appears to be a way to get an Annotation and move it to another page, but I do not see a way to get a content object and make a copy of it or move it to another page (or another PDF).
If it is not currently possible to get and copy page content, can this be added?
Thanks,
Andrew
Is there a way to copy PageContent, specifically Text (including any embedded fonts), from one page to another?
Background information:
Our application displays text by drawing to an Android Canvas using drawText(). This uses the Android system fonts, including any fallback fonts, to make sure the text is displayed. There isn't any way to determine which fonts are used by the system to display a particular text.
When we export a note to a PDF that contains text as described above, we have to specify which font to use. As I mentioned above, this is not something that can be queried. If we use Roboto, and the text is Japanese characters, then the PDF will display tofu (font squares) for the text.
A workaround for this we discovered is using the PDF support that is built into Android starting in API 19: developer.android.com/reference/android/...pdf/PdfDocument.html
Using the Android PdfDocument, we can create a PDF with a single page that contains the text displayed the exact same way it is displayed in the app. The Android PdfDocument determines which fonts are used by the text and embeds them into the PDF. It is able to do this because it uses the same Canvas API that's used for drawing to the screen (and therefore it knows which fonts to use at that low level).
Once we have created the PDF that contains the text as described above, we would like to open this PDF using the Radaee SDK and copy this text object (including the embedded fonts) to another PDF.
For clarification, we're dealing with PDF content, not Annotations. There appears to be a way to get an Annotation and move it to another page, but I do not see a way to get a content object and make a copy of it or move it to another page (or another PDF).
If it is not currently possible to get and copy page content, can this be added?
Thanks,
Andrew
Last edit: 8 years 10 months ago by ashughes.
IP: 192.168.0.71
8 years 10 months ago #12344
by nermeen
Replied by nermeen on topic How to Copy Page Content
Dear Andrew,
You can use the below APIs to get each char, get its rectangle (to get position and size), and get its font name.
For embedded fonts, they cannot be copied (license violation motives), importing a whole page with its resources is ok, but copying a part like font no.
So if the font is free or has an equivalent free type, it can be added using Font rendering problem
www.radaeepdf.com/documentation/javadocs...l#ObjsGetCharCount--
You can use the below APIs to get each char, get its rectangle (to get position and size), and get its font name.
For embedded fonts, they cannot be copied (license violation motives), importing a whole page with its resources is ok, but copying a part like font no.
So if the font is free or has an equivalent free type, it can be added using Font rendering problem
Code:
ObjsGetCharCount
ObjsGetCharFontName
ObjsGetCharIndex
ObjsGetCharRect
ObjsStart
ObjsGetString
IP: 192.168.0.71
8 years 10 months ago #12369
by ashughes
Replied by ashughes on topic How to Copy Page Content
If it's not possible to copy content (including resources like fonts) from one page to another, what about merging two pages together?
IP: 192.168.0.71
8 years 10 months ago #12376
by nermeen
Replied by nermeen on topic How to Copy Page Content
This is not supported, you can only use the suggested APIs to copy/merge the page text content.
You can open a support ticket addressed to (RadaeePDF Support) as handler, and ask for this feature.
You can open a support ticket addressed to (RadaeePDF Support) as handler, and ask for this feature.
Time to create page: 0.424 seconds