Welcome Guest Search | Active Topics | Sign In | Register

Flatten out PDF Options
S-H
Posted: Monday, May 3, 2021 6:13:13 AM
Rank: Newbie
Groups: Member

Joined: 3/2/2017
Posts: 8
Hi, I have a requirement for "flattening out" an existing PDF.

That is, to convert filled-in form fields into either just "decorated text".

Or, if that is not easy, to convert the pages into images that I can put into a new resulting PDF.
In a way, to accomplish what gets done when printing-to-pdf.
I've been looking for an API-verb to render a page into an image, but haven't been lucky so far.

Regards
Sven
eo_support
Posted: Monday, May 3, 2021 11:12:43 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,067
Hi,

You can use our PdfRender class for this purpose:

https://www.essentialobjects.com/doc/eo.pdf.pdfrender.aspx

Once you get a list of images (one image per page), you will need to use our API to create new PDF file with these images. One way for you to do so is to create a simple HTML file with all those images and then use our HTML to PDF converter to generate the result PDF file. Another way is to use PDF creator API. The code will be something like this:

Code: C#
PdfDocument doc = new PdfDocument();

for (int i = 0; i < image_count; i++)
{
    PdfPage page = doc.Pages.Add();

    AcmRender render = new AcmRender(page, 0);

    System.Drawing.Image image = System.Drawing.Image.FromFile(image_file_for_page_i);
    AcmImage acmImage = new AcmImage(image);

    render.Render(acmImage);
}

doc.Save(result_file_name);


In either method, you may need to explicitly set page margins in order to override the default margins. You can look into the documentation for either method for more details on how to do that. If you still have any questions after that please feel free to ask.

Thanks
S-H
Posted: Monday, May 3, 2021 1:13:44 PM
Rank: Newbie
Groups: Member

Joined: 3/2/2017
Posts: 8
Thanks, I'll try that!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.