Save over the original editable pdf?
As the topic, is that possible to save some inputs to editable pdf?
@shieer Would you were able to do it?
very much needed... or otherwise need a method to pass form xml to PDF Doc so that it populates all the values before rendering
Is there any progress on this? @paresh-navadiya @yasirmturk
Saving inputs means be able to save a PDF with AcroForms. CoreGraphics desn't support AcroForms writing so a proper low level PDF writing functionality is needed. It may be very difficult to implement on top of CoreGraphics ...
how these guys are handling it? http://www.pdftron.com/pdfnet/downloads.html https://pspdfkit.com/
They use a proprietary PDF writer
I'm about 3 days into the iOS/AcroForm/Edit/SaveBackAsAcroForm attempt. :) ILPDFKit is great if client is cool with flat PDF, but unfortunately mine isn't. What direction did you guys go?
same situation here... @back-40 this app https://itunes.apple.com/us/app/mupdf/id482941798?mt=8&ign-mpt=uo%3D4 does it perfectly and they claim to be open source.. but their forms are not overlay
@yasirmturk Thanks I'll take a look at it. Have you used it before?
nops i m still trying to use @ILPDFKit
Still digging on this. Does ILPDFKit have the ability to create a PDF with AcroForms?
no
Careful: muPDF is open source but AGPL - you can't use that in the App Store and it's also viral. It's has commercial licensing options.
At https://pspdfkit.com (our commercial PDF SDK) we've spent a few years with around 15 people to get forms working, including a lot of edge cases, drawing appearance streams, nested fields and of course also JavaScript validations and all related event logic. It's a lot of work and we have a few thousand test cases that run on our CI. To write the data back you need to fully parse the PDF (especially fun if it has a user or owner password defined and is encrypted)
We're only today launched Forms on Android, that project also took a year and we leveraged a lot of code that we share between iOS and Android. Next up: Forms on our Web SDK.
Here's all the documentation you need to write your own parser. Check out Chapter 12.7 "Interactive Forms" of the PDF32000_2008.pdf and to generate the object tree work through Chapter 7 (Page 11 to 108). To generate the appearance streams you need to read most of Chapter 8/9 (Page 110-292; Fonts are hard). If you skip that than there'll be many documents where you fill in the form content but they either don't render at all or render invalid content. (Preview on macOS is especially bad on that) https://pspdfkit.com/guides/ios/current/features/rendering-pdf/
we don't need it for the app store.. thanks for the info
I ended up writing my own parser from scratch and then recreating the PDF with the form values put in. I maintained the acroforms so it is still editable via PDF viewers. Not an easy job, but I've done similar in the past. A few years back I wrote software that made extremely large PDFs with vector objects and serialized text for digital printing press systems.
great.. can did u made it available?
Sorry, but I've too many hours in it make it free.
I suggest to save values in dictionary with key as formName and populate the PDF back after loading it.
like , I have PDF with TextField , its formName is "firstName" , then i enter some Text in it say "Saurabh" and while click on save button , i get the value from pdf , which i stored in dictionary! Now while loading same form again i will iterate through dictionary keys to get all saved values.
//saving values
NSDictionary *dict = [[NSMutableDictionary alloc]init];
for (ILPDFForm *form in pdf.document.forms)
{
if(form.value.length)
[dict setObject:form.value forKey:form.name];
}
//retrive values
for(NSString *strKey in dict.allKeys)
{
[pdf.document.forms setValue:[dict objectForKey:strKey] forFormWithName:strKey];
}
Also you can save this dictionary to database if there is multiple PDF files to save & populate PDF back as per selection. However the SDK i am using is Old.Hope it will help.