1

Flattening a PDF means multiple layers of the content will be merged into a single layer. However, the results vary from one service to another as what each service sees in the layers differs.

Basically, by flattening a PDF the image of the page of a PDF content is taken and replaced on that same page. This means the texts in that PDF will no longer be editable as they will become an image. Similarly, if there are any annotations, etc., they will become an image and no longer be editable or selectable.

https://www.sejda.com/flatten-pdf does this job by using the human interface. What is required is an API similar to this functionality so that applications can flatten the PDFs. Checked and confirmed with Sejda that they do not offer any API services even if it is on a paid basis.

Requesting anyone to share who knows any API service or .Net library that can flatten a PDF.

1 Answer 1

1

The company I work for has the LEADTOOLS PDF library which simplifies doing this using .NET classes (and other platforms if needed).

Here's the needed C# code to convert any type of PDF to flat-image PDF that doesn't contain searchable text:

RasterCodecs codecs = new RasterCodecs();
//specify the desired loading DPI. Increase it to improve quality
codecs.Options.RasterizeDocument.Load.XResolution = 200;
codecs.Options.RasterizeDocument.Load.YResolution = 200;
//load all pages
RasterImage pdfPages = codecs.Load(inputPdfName, 24, CodecsLoadByteOrder.Bgr, 1, -1);
//save all pages
codecs.Save(pdfPages, flatPdfName, RasterImageFormat.RasPdfJpeg411, 24, 1, -1, 1, CodecsSavePageMode.Overwrite);

The code shows one of the useful options, which is selecting the DPI resolution used when converting the pages to images. The library offers many other features that allow optimizing or customizing the conversion process.

If you would like to try the SDK, there's a free evaluation here. The evaluation comes with full documentations, sample projects and free technical support through email and chat.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.