Cut and Paste

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v10)  /  Cut and Paste

DynamicPDF CoreSuite for .NET (v10) Forum

 Jul 11 2019 4:37 AM
Hello.

We are evaluating Dynamic PDF and it's set of modules.  Our issue is as follows,

A 3rd party is supplying a PDF but we need to manipulate it before we create the end PDF. Is there a way / module / tool in Dynamic PDF which will let me copy a "specific" part of an existing PDF (giving start / finish points) and paste it into a either a DLEX or another PDF.

Appreciate any input or advice.

Thanks

Sunny Patel.
 Jul 11 2019 10:18 AM
Posted by a ceTe Software moderator
Hello Sunny,

You can import the contents from an existing PDF and clip off the unwanted contents and then add the modified imported contents to new page of a Document. You will need to use ImportedPageArea or ImportedPageData classes of DynamicPDF Merger product to do this. You can refer to the documentation on importing pages here. Also below is the code sample to import first page contents using ImportedPageArea class and clipping off the unwanted contents.

            PdfDocument pdf = new PdfDocument(@"File path for a input PDF");
            PdfPage page = pdf.Pages[0];
            ImportedPageArea area = new ImportedPageArea(page, 0, 0);
            area.Contents.ClipBottom = 100;
            area.Contents.ClipLeft = 200;
            area.Contents.ClipRight = 200;
            area.Contents.ClipTop = 100;
            Document document = new Document();
            Page newPage = new Page();
            document.Pages.Add(newPage);
            newPage.Elements.Add(area);
            document.Draw(@"File path to save the PDF");

You can download fully functional evaluation edition of DynamicPDF Merger product from our website here. Also refer to the documentation on referencing assembly and deployment here.

Thanks,
ceTe Software Support Team
 Jul 11 2019 4:10 PM
Hi

Thanks for the help - this is what I am looking for and your answer has helped to move along with our requirements.
Follow up question if I may. It seems you add the trimmed doc to a new page with the command.

      newPage.Elements.Add(area);

However, if I wanted to add it in a particular position, can this be done.
For example I have a PDF which I will trim with  SectionA and SectionB. Then paste it into a new PDF page as SectionB and SectionA.

Can this be done?

Also the line

            ImportedPageArea area = new ImportedPageArea(page, 0, 0);
            area.Contents.ClipBottom = 100;

What is the unit for 0 and 100. Pixels, mm, cm .... Sorry to keep asking question, but we have a particular requirement and really need to find a tool that meet our needs.

Thanks in advance,

Sunny Patel.
 Jul 12 2019 10:25 AM
Posted by a ceTe Software moderator
Hello Sunny,

Yes, you can add the imported contents at desired positions on the page by specifying X and Y position coordinates. Below is the code sample.

            PdfDocument pdf = new PdfDocument(@"Path for input PDF");
            PdfPage page = pdf.Pages[0];
            float xPosition = 0;
            float yPosition = 400;
            ImportedPageArea sectionA = new ImportedPageArea(page, xPosition, yPosition);
            sectionA.Contents.ClipBottom = 100;
            sectionA.Contents.ClipLeft = 200;
            sectionA.Contents.ClipRight = 200;
            sectionA.Contents.ClipTop = 0;

            ImportedPageArea sectionB = new ImportedPageArea(page, 0, 0);
            sectionB.Contents.ClipBottom = 0;
            sectionB.Contents.ClipLeft = 200;
            sectionB.Contents.ClipRight = 200;
            sectionB.Contents.ClipTop = 100;

            Document document = new Document();
            Page newPage = new Page();
            document.Pages.Add(newPage);
            newPage.Elements.Add(sectionA);
            newPage.Elements.Add(sectionB);

            document.Draw(@"Path to save output PDF");

DynamicPDF Generator for .NET uses a coordinate system based on points. You can refer to the documentation on coordinate system  here.

Thanks,
ceTe Software Support Team
 Jul 12 2019 10:56 AM
Hi CeTe Support

Many thanks for your valuable input and expertise.  Really appreciate it.
I'll give this a go in my environment - but on the face of it, it looks good.

Once again, many thanks.

Regards

Sunny Patel.

All times are US Eastern Standard time. The time now is 2:46 AM.