QLPreviewController and UIWebView do not display filled PDFs - c#

I have a PDFthat has text boxes in it. My program uses Xfinium PDF software to fill the text boxes. When I view the filled in PDF the document shows up with no data in the fields. I have tried using QLPreviewController and UIWebView and they both do not display the filled in fields; however, if I email the document to myself and open it in Adobe DC on the iPad all the data shows up correctly. It may be important to note that even the mail app does not show the PDF correctly filled in.
Here is the PDF opened in Adobe on iPad
Here is the PDF opened in UIWebView in my app (also shows same way in QLPreviewController

PDF forms may bring along appearances or may rely on the viewer to create an appearance for the value of the field.
Fairly complete PDF viewers (like Adobe Reader or Foxit) can get along with both variants well. Incomplete viewers, though, like many so called previewers, require an existing appearance and display empty documents for forms which do not bring along appearances.
Thus, if you want your forms to be visible on incomplete viewers, too, provide appearances.

The QLPreviewController use the CGPDF* API to display the PDF files. The CGPDF* API has some limitations, it displays only the page content and it does not display annotations, no matter if they have appearances or not. Form fields use widget annotations to display the field content so they are also not displayed.
The solution here is to flatten the form fields. This operation will transform the form fields into page content and QLPreviewController will display the final file correctly. The downside of this operation is that the form fields are no longer editable.

The XFINIUM.PDF library creates apearance objects for field values. The problem is related to iOS PDF rendering engine which does not display annotations and form fields. The solution is to flatten the form fields if you want to view the files using the QLPreviewController.
The form fields are flattened with this line of code:
pdfDocumentObject.Form.FlattenFormFields();
Disclaimer: I work for the company that develops the XFINIUM.PDF library.

Both QuickLook and UIWebView/WKWebView uses Apple's internal and undocumented CorePDF framework, which has no code that would render PDF AcroForms (doesn't matter if backed by appearance streams or not)
You can either
1) Flatten the document on the server or with a client-side library.
2) Re-implement everything from scratch and add support for PDF forms. (See Page 431ff in Adobe's PDF Specifications - "Interactive Form Dictionary")
We did (2) in the commercially available PSPDFKit SDK. It doesn't use Apple's rendering engine as you do not have a way here to render appearance streams for PDF form widgets, so even with a lot of code you'll not be able to get the representation that is encoded in the document. For this you'll either have to result to private API or re-implement everything yourself. We also support (1) using the PSPDFProcessor class.

Thanks,
It works for me.
pdfDocumentObject.Form.FlattenFormFields();
Bala.

Related

Is it possible to create text field in pdf form which can grow in size as per text bind to it?

I have a task where i have to bind text dynamically to pdf form text field. The form must be flowed as well as text field also should be flowed. is it possible?. The text size is not fixed and i want to bind it to that text field.
That is impossible with AcroForm technology, so if you want pure PDF forms, the answer is no: the position and size of every field are fixed at absolute coordinates on the page.
It is only possible with XFA technology (XML Forms Architecture), but in this case, the form is defined using XML wrapped in a PDF file. XFA is deprecated in PDF 2.0. There aren't many tools available to create an XFA form. You can create such a form with Adobe LiveCycle Designer (although it's not easy to use), and you can fill and flatten such a form using iText's pdfXFA add-on.
Summarized; the short answer is "No". The long answer is: if you want to use deprecated technology and find the right tools, the answer is "Yes, but I would not recommend it."
It's a better idea to create a template using HTML and CSS, populate the HTML with data, and then use iText's pdfHTML tool to convert the HTML and CSS to PDF.

Generating fillable PDF as web form that can be submitted

I am trying to generate a fillable PDF document that can be viewed in the web browser and filled up so after pushing a "Submit" button the data from the fields can be received on the server.
I am reading an article related with the iTextSharp but i still can not find a way of getting my mission accomplished. The example there is with a HTML form that after submitted the fields get binded to a pdf Template.
Is this my only option?
There are a few online options.
formsite - unlimited pdf generation for about $50, but you have to manually connect the fields.
doculicious - automated creation of embed-able pdf form
logiforms - same as formsite, but a little nicer and more options in other areas
seamlessdocs - very nice email/web pdf automated (still checking them out, but so far so good)
If you want to display a fillable form, and then store the values when the user submits it, you might be better off with just an HTML form. A basic HTML form doesn’t require any extra tools, and won’t get PDF involved. This is the simplest solution to your question. If you need to use PDF, and have to provide the user with a copy of the filled out form, please clarify in the OP, and I can provide you with a mode detailed solution.

box viewer for microsoft office documents

I have a quiz website, where user will select the topic and can read contents.
So I have contents in various formats like video, textfile, pdf reports.
For contents to show them in box I am using http://viewerjs.org/.
since it supports limited extensions and doesn't fill up my all requirements for file type- .docx,.doc, .xlsx,.pptx.
Is there any open source box viewer that supports office document?
Although I can read their contents through c# and display them back as plain text but my primarily requirement is to show them in box as viewer.js does it for pdf.
I think you are conflating http://viewerjs.org/ with the Box View API, which has an open-source viewer component that is also called viewer.js.
The View API will convert Office file formats as well as .pdf.
The View API does not have a C# SDK available yet (as far as I know), but there are a bunch of open source ones in other languages.

Generate PDF based on a Word document for each data item

There're a data list with hundreds of data items (suppose each item is a customer), and a predefined word document as template, the requirement is - for each data item, fill corresponding data into template fields, and generate a readonly PDF file as result.
Prefered platform is ASP.NET with C#.
I found two solutions:
Change the word document into a PDF form, and use iTextSharp to fill the form fields. But create the PDF form with correct format (font, layout, etc.) is a difficult work, and it needs particular tool and new skill when system user wants to add new template (unless the PDF form is always created by developer).
Add text placeholder in the word file, and the program can read word file, replace text, and convert into PDF. But I'm not sure which components should be used.
I'd like to get some advices on this problem. tks.
Update 20130416:
After some searching & experiments, my conclusion is below:
Client solution: use Microsoft.Office.Interop.Word (Office2007+plugin or Office2012) to read data, convert to pdf, etc. But this method running on server side may be unsafe.
Server solution:
Make PDF form, and use iTextSharp to fill the form fields. The disadvantage has been mentioned above.
Make HTML template, and replace field placeholders, and use iTextSharp+XMLWorker to convert HTML to PDF. The difficulty is create the HTML template manually and optimize the PDF effect.
MS SharePoint Office Automation Service is a server solution based on MS Office, perhaps this method will be easier, but it needs license and SharePoint server cost.
Finally, I chose the HTML template solution for this request. QED.
Another option would be to use Tx Text Control for ASP.NET. They have a
mailmerge feature that allows you to fill data into a word template.
The merged document can easily be saved as a pdf.
For the second option you can use iTextsharp or Aspose which supports the placeholder replacement and generation PDF, it supports creating files based on templates of MSWord and Openoffice which could be usefull for user who do not want to buy MSWord only to create a template.
Another option, you can use nustache templates, fill them with list data and then use xmlworker from ItextSharp to render to pdf.

Filling out a PDF / form using Winform application

I have a 2-page PDF that I want to overlay information on (think of a form that someone manually fills out) using a C#/.NET Windows application. After this form is generated, it will need to be previewed and printed (exported into a graphic or PDF is nice, but not a requirement).
At first glance, I'm thinking of two ways to do this:
Use a PDF manipulator like iTextSharp, take a copy of the blank PDF form, and add text to the PDF. Then, launch Adobe Reader to do a print or preview.
Convert the PDF into a graphic, and put the graphic into a C# Report. Then, overlay text fields onto the report, and use a .NET ReportViewer control to preview and print the report.
The text does not need to be searchable or copyable or have any of the cool things that PDF gives me, so I'm leaning towards the second option. Am I missing anything, or is there something I'm not thinking of? Thanks in advance.
We use #1 extensively and it works perfectly. You shouldn't have any problems, it's rather easy (just need to make the fields writeable and use a FDF file and merge it with the PDF file). At least that's how we did it.

Categories

Resources