Convert XFA forms to AcroForms in C++
Contents
[
Hide
]
Convert a dynamic XFA form
- Open the input PDF as a Document.
- Get Aspose::Pdf::Forms::Form and set its Type to FormType::Standard.
- Save the PDF with Save().
#include <Aspose.PDF.Cpp/Document.h>
#include <Aspose.PDF.Cpp/InteractiveFeatures/Forms/Form.h>
#include <Aspose.PDF.Cpp/InteractiveFeatures/Forms/FormType.h>
using namespace System;
using namespace Aspose::Pdf;
using namespace Aspose::Pdf::Forms;
void FormExamples::ConvertDynamicXfaToAcroform(String inputFile, String outputFile)
{
auto document = MakeObject<Document>(inputFile);
document->get_Form()->set_Type(FormType::Standard);
document->Save(outputFile);
}
Convert with an XFA rendering-flag check
Review the converted fields and appearance for your input, especially when ignoring a rendering requirement.
- Open the input PDF as a Document.
- Get Aspose::Pdf::Forms::Form and check that it is not null.
- When HasXfa and NeedsRendering are true, set IgnoreNeedsRendering to true.
- Set Type to FormType::Standard.
- Save the PDF with Save().
#include <Aspose.PDF.Cpp/Document.h>
#include <Aspose.PDF.Cpp/InteractiveFeatures/Forms/Form.h>
#include <Aspose.PDF.Cpp/InteractiveFeatures/Forms/FormType.h>
using namespace System;
using namespace Aspose::Pdf;
using namespace Aspose::Pdf::Forms;
using namespace Aspose::Pdf::Annotations;
using namespace Aspose::Pdf::Text;
void FormExamples::ConvertXfaFormWithIgnoreNeedsRendering(String inputFile, String outputFile)
{
auto document = MakeObject<Document>(inputFile);
auto form = document->get_Form();
if (form != nullptr)
{
if (form->get_HasXfa() && form->get_NeedsRendering())
{
form->set_IgnoreNeedsRendering(true);
}
form->set_Type(FormType::Standard);
}
document->Save(outputFile);
}