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 create a new pdf file from a template pdf

More
IP: 192.168.0.71 11 years 4 months ago #7402 by Dotzler
Hi,

I want to use a pdf file which includes forms like edit fields and checkboxes as a template. The pdf file has to be read, partially filled and written to a new file. This has to be done without user interaction, the pdf is not displayed at this step. The newly created pdf file will be read and displayed at a later stage.
How can this be done? Is there existing sample code?

Regards,
Josef
More
IP: 192.168.0.71 11 years 4 months ago #7403 by radaee
if the PDF run as fill fields:
1. copy template file to another file.
2. open the pdf file copied.
3. get page, and invoke page.ObjsStart();
4. fill the fields, by field name.
using Annotation.GetFieldFullName2() or Annotation.GetFieldFullName()
5. close the page and save the document.
6. close document

you can check filed full name one by one.
using loop:
for (index = 0; index < page.GetAnnotCount(); index++ )
{
Annotation annot = page.GetAnnot(index);
if( annot.GetFieldFullName2() == find_name ) ....
}
More
IP: 192.168.0.71 11 years 4 months ago #7412 by Dotzler
Thank you very much for your fast response!

But I still have problems to fill an edit field. If I open a pdf from sdcard, the method setEditText returns true and the text appears in the edit field. But when I open the same pdf from the assets folder, the method setEditText returns false and the edit field remains emtpy.

Here is the code to open the pdf from sdcard:
Code:
m_doc.Open("/mnt/sdcard/test.pdf", null);

And this is the code to open the same pdf from the assets folder:
Code:
PDFAssetStream stream = new PDFAssetStream(); stream.open(getAssets(), "test.pdf"); m_doc.OpenStream(stream, null);

Interestingly, there is now problem to set checkbox states, only the edit field is affected. I didn't try other forms.

Is this a bug or have I missed something?

Regards,
Josef
More
IP: 192.168.0.71 11 years 4 months ago #7414 by radaee
PDF file open from assets are read-only.
so you can extract PDF file from assets to sdcard.
then edit fields.
Time to create page: 0.394 seconds
Powered by Kunena Forum