Image Cleanup using JavaScript

Discussions about image processing and document imaging.
Post Reply
SMOsama
Posts: 18
Joined: Tue Aug 10, 2021 8:17 pm

Image Cleanup using JavaScript

Post by SMOsama » Wed Sep 01, 2021 11:52 am

Hi team,

Hope you all are doing good. There is project "asp.net-mvc_razor_app" in your Sample DocuVieware in which I see image Clean and libraries that were using in it was DeleteBlackBorders, AutoDeskew, RemoveHolePunch and many other by the help of GdPictureImaging.

How can I use this at Client Side in JavaScript using DocuViewareAPI or something like that.

User avatar
Fabio
Posts: 173
Joined: Thu Aug 27, 2020 9:57 am

Re: Image Cleanup using JavaScript

Post by Fabio » Wed Sep 01, 2021 3:26 pm

Hello,

You will need to use the same logic as the razor sample:
- Implement custom buttons in the client
- These buttons call a PostCustomServerAction to ask the server to launch a method
- In your Global.asax.cs you will need to get the actionName parameter of the PostCustomServerAction
- Depending on the actionName you will need to launch the associated method
And in the method, you will need to get the client's loaded document, apply the modification on it, and load it back to the client.
Here are the needed methods:
Create a custom button: https://www.docuvieware.com/guides/aspn ... utton.html
Create a custom snap-in: https://www.docuvieware.com/guides/aspn ... napIn.html
PostCustomServerAction: https://www.docuvieware.com/guides/aspn ... ction.html
Get the loaded PDF server-side: https://www.docuvieware.com/guides/aspn ... vePDF.html
Get the loaded image server-side: https://www.docuvieware.com/guides/aspn ... Image.html
All the image modifications documentation: https://www.gdpicture.com/guides/gdpict ... ments.html
Load your modified image on the viewer: https://www.docuvieware.com/guides/aspn ... Image.html
Load your modified PDF on the viewer: https://www.docuvieware.com/guides/aspn ... rePdf.html

If you need any help, let me know.

With best,
Fabio

SMOsama
Posts: 18
Joined: Tue Aug 10, 2021 8:17 pm

Re: Image Cleanup using JavaScript

Post by SMOsama » Wed Sep 01, 2021 8:56 pm

Hi Fabio,

I am facing problem during PostCustomServerAction call to server. At FrontEnd, I clicked on Twain Acquisition button(at toolbar) and then click on acquire button. Until now everything works perfect. Now, when I click on my custom button which calls PostCustomServerAction and when it comes to server side, I am unable to read multiple pages that were scanned. I am only able to read one image.

How can I read all pages at once?

User avatar
Fabio
Posts: 173
Joined: Thu Aug 27, 2020 9:57 am

Re: Image Cleanup using JavaScript

Post by Fabio » Thu Sep 02, 2021 10:11 am

Hello,

That is because the Image ID relates to only one image/page. If you want to apply a modification on your multipage image, you need to loop on every page and apply the modification.

With best,
Fabio

SMOsama
Posts: 18
Joined: Tue Aug 10, 2021 8:17 pm

Re: Image Cleanup using JavaScript

Post by SMOsama » Thu Sep 02, 2021 10:21 am

Hi,

So, If I want to save that tiff image (all pages) to my local path then which method needs to be called?

User avatar
Fabio
Posts: 173
Joined: Thu Aug 27, 2020 9:57 am

Re: Image Cleanup using JavaScript

Post by Fabio » Thu Sep 02, 2021 10:27 am

Hi,

You can directly call the js dedicated Save method: https://www.docuvieware.com/guides/aspnet/Save.html
You can also call the server method to save it as a Tiff: https://www.docuvieware.com/guides/aspn ... sTIFF.html

With best,
Fabio

User avatar
Fabio
Posts: 173
Joined: Thu Aug 27, 2020 9:57 am

Re: Image Cleanup using JavaScript

Post by Fabio » Thu Sep 02, 2021 11:16 am

Hi again,

I developed an example of a simple method to let you check the image mechanism:

Code: Select all

int pagesNb = e.docuVieware.PageCount;
                int pageToProcess = 1;

                GdPictureStatus status = e.docuVieware.GetNativePDF(out GdPicturePDF gdpicturePDF);

                if (status != GdPictureStatus.OK)
                {
                    throw new Exception("Unable to obtain native PDF. Status: " + status.ToString());
                }
                while (pageToProcess <= pagesNb)
                {
                    status = gdpicturePDF.SelectPage(pageToProcess);

                    if (status == GdPictureStatus.OK)
                    {
                        int pageImageId = gdpicturePDF.ExtractPageImage(1);

                        status = gdpicturePDF.GetStat();

                        if (status == GdPictureStatus.OK)
                        {
                                using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
                                {
                                    status = gdpictureImaging.FxNegative(pageImageId);

                                    if (status == GdPictureStatus.OK)
                                    {
                                        string imageResName = gdpicturePDF.GetPageImageResName(0);
                                        status = gdpicturePDF.ReplaceImage(imageResName, pageImageId, false);
                                    }
                                GdPictureDocumentUtilities.DisposeImage(pageImageId);
                            }
                        }
                        else
                            throw new Exception("Unable to process the PDF page. Status: " + status.ToString());
                    }
                    e.docuVieware.RedrawPages(new int[] { pageToProcess });
                    pageToProcess++;
                }
With best,
Fabio

SMOsama
Posts: 18
Joined: Tue Aug 10, 2021 8:17 pm

Re: Image Cleanup using JavaScript

Post by SMOsama » Wed Sep 08, 2021 2:06 pm

Thanks for your response. It helps me alot

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest