Export Searchable PDF as stream

  • Last Post 21 August 2018
Nirmal Boopalan posted this 20 August 2018

I used the following snippet to export the pdf params to memory

PDFExportParams exportParams = engine.CreatePDFExportParams();
            exportParams.TextExportMode = PDFExportModeEnum.PEM_ImageOnText;
            exportParams.Colority = PictureColorityModeEnum.PCM_KeepColority;
            exportParams.Resolution = 200;
            exportParams.ResolutionType = PDFResolutionTypeEnum.PRT_Desired;
            exportParams.MRCMode = PDFMRCModeEnum.MRC_Auto;
            exportParams.PDFAComplianceMode = PDFAComplianceModeEnum.PCM_None;
            exportParams.Scenario = PDFExportScenarioEnum.PES_Balanced;
            var searchablePdfFileWriter = new FileWriter();
            document.ExportToMemory(searchablePdfFileWriter, FileExportFormatEnum.FEF_PDF, exportParams);
File.WriteAllBytes("d:/test.pdf", Encoding.UTF8.GetBytes(searchablePdfFileWriter.FileContent.ToString()));

When i tried to save and open the filewriter object to a physical path, "There was an error opening this document. The file is damaged and could not be repaired"

Can anyone help to create a searchable PDF as stream?

Helen Osetrova posted this 21 August 2018

Hello Nirmal!


Can you please clarify why using the IFRDocument::Export() method is not suitable for you? Could you also post here your implementation of the IFileWriter interface? The sample implementation for C# language can be found in Developer's Help - API Reference - IFileWriter Interface


If it possible, please try to apply export to the memory in one of our code samples. (The samples are located under the C:\ProgramData\ABBYY\SDK\11\FineReader Engine\Samples directory.) Then please tell us  about the results.


Please note that PDF file is a binary file in fact, so encoding methods may not be appropriate for working with it.


If you have the additional questions which are beyond of this topic, please send them to sdk_support@abbyy.com. Please specify in the message your License Serial number and attach a sample of a source document to it. We will be glad to assist.