The following example shows the most common use case for converting PDF document to DOCX. The source PDF file is loaded from a current folder. The converted file is saved to the same folder.
usingSystem;usingGroupDocs.Conversion.LowCode;// Load license keysvarpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");varprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");// Apply the licenseLicense.Set(publicKey,privateKey);// Create a converter for the PDF filevarconverter=newPdfToDocxConverter("business-plan.pdf");// Convert PDF to DOCXconverter.Convert("business-plan.docx");
ImportsSystemImportsGroupDocs.Conversion.LowCodeModuleProgramSubMain()' Load license keys
DimpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")DimprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")' Apply the license
License.Set(publicKey,privateKey)' Create a converter from file path
DimconverterAsNewPdfToDocxConverter("business-plan.pdf")' Convert PDF to DOCX
converter.Convert("business-plan.docx")EndSubEndModule
openSystemopenGroupDocs.Conversion.LowCode[<EntryPoint>]letmain_=// Load license keys
letpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")letprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")// Apply the license
License.Set(publicKey,privateKey)// Create a converter from file path
letconverter=newPdfToDocxConverter("business-plan.pdf")// Convert PDF to DOCX
converter.Convert("business-plan.docx")0
This section covers only the main scenarios. You can also refer to the API references for the PdfLoadOptions for a complete list of options that you can specify.
Convert Protected PDF to DOCX
The following example shows how to convert protected PDF file and save it to unprotected DOCX file.
In case you do not specify password for protected document PasswordRequiredException is going to be thrown.
usingSystem;usingGroupDocs.Conversion.LowCode;// Load license keysvarpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");varprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");// Apply licenseLicense.Set(publicKey,privateKey);// Provide password through load optionsvarconverter=newPdfToDocxConverter("protected.pdf",options=>{options.Password="12345";});// Convert PDF to DOCXconverter.Convert("unprotected.docx");
ImportsGroupDocs.Conversion.LowCodeModuleProgramSubMain()' Load license keys
DimpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")DimprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")' Apply license
License.Set(publicKey,privateKey)' Provide password through load options
DimconverterAsNewPdfToDocxConverter("protected.pdf",Sub(options)options.Password="12345"EndSub)' Convert PDF to DOCX
converter.Convert("unprotected.docx")EndSubEndModule
openSystemopenGroupDocs.Conversion.LowCode[<EntryPoint>]letmain_=// Load license keys
letpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")letprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")// Apply the license
License.Set(publicKey,privateKey)// Create a converter from file path
letconverter=newPdfToDocxConverter("protected.pdf",funoptions->options.Password<-"12345")// Convert PDF to DOCX
converter.Convert("unprotected.docx")0
The following example shows how to convert a form‑fillable PDF into static content by flattening form fields.
usingSystem;usingGroupDocs.Conversion.LowCode;// Load license keysvarpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");varprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");// Apply licenseLicense.Set(publicKey,privateKey);// Flatten form fields through load optionsvarconverter=newPdfToDocxConverter("form-fields.pdf",options=>{options.FlattenAllFields=true;});// Convert PDF to DOCXconverter.Convert("flattened.docx");
ImportsGroupDocs.Conversion.LowCodeModuleProgramSubMain()' Load license keys
DimpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")DimprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")' Apply license
License.Set(publicKey,privateKey)' Flatten form fields through load options
DimconverterAsNewPdfToDocxConverter("form-fields.pdf",Sub(options)options.FlattenAllFields=TrueEndSub)' Convert PDF to DOCX
converter.Convert("flattened.docx")EndSubEndModule
openSystemopenGroupDocs.Conversion.LowCode[<EntryPoint>]letmain_=// Load license keys
letpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")letprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")// Apply license
License.Set(publicKey,privateKey)// Flatten form fields through load options
letconverter=newPdfToDocxConverter("form-fields.pdf",funoptions->options.FlattenAllFields<-true)// Convert PDF to DOCX
converter.Convert("flattened.docx")0
Convert PDF with Annotations to DOCX without Annotations
By default, annotations are added to the output DOCX file, see this with-annotations.pdf (text HOME BASED PROFESSIONAL SERVICES is highlighted) as an example of PDF file with annotations.
The following example shows how to convert a PDF file that contains annotations and save a DOCX file without annotations.
usingSystem;usingGroupDocs.Conversion.LowCode;// Load license keysvarpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");varprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");// Apply licenseLicense.Set(publicKey,privateKey);// Hide annotations using HidePdfAnnotationsvarconverter=newPdfToDocxConverter("with-annotations.pdf",options=>{options.HidePdfAnnotations=true;});// Convert PDF to DOCXconverter.Convert("no-annotations.docx");
ImportsSystemImportsGroupDocs.Conversion.LowCodeModuleProgramSubMain()' Load license keys
DimpublicKeyAsString=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")DimprivateKeyAsString=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")' Apply license
License.Set(publicKey,privateKey)' Hide annotations using HidePdfAnnotations
DimconverterAsNewPdfToDocxConverter("with-annotations.pdf",Sub(options)options.HidePdfAnnotations=TrueEndSub)' Convert PDF to DOCX
converter.Convert("no-annotations.docx")EndSubEndModule
openSystemopenGroupDocs.Conversion.LowCode[<EntryPoint>]letmainargv=// Load license keys
letpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")letprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")// Apply license
License.Set(publicKey,privateKey)// Hide annotations using HidePdfAnnotations
letconverter=newPdfToDocxConverter("with-annotations.pdf",funoptions->options.HidePdfAnnotations<-true)// Convert PDF to DOCX
converter.Convert("no-annotations.docx")0//returnanintegerexitcode