We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Extracting a complete page from one pdf document and put in a table cell of another document

I am creating a PDF document(target) based on the content specified by the user. The content could be some rich text, image and a pdf itself. The target PDF can have one column layout or two column layout.

Now for supporting two column layout, i have created a table with two columns (50% 50%) that will run through length of the document.

Q1) How can i extract the PDF specified by the user and put the content into table cell of my target document.
Q2) If first column of the row has some text which overflows to next page and second column has a image which remains in a page, then i see that image is being repeated in next page. How can i avoid this issue.

@anujshukla

Thank you for contacting support.

Please not that a table cell can not contain an instance of Page class. However, you may Convert PDF Page to Image and that image can be inserted in a table cell as explained in Add SVG Object to Table Cell.

Moreover, would you please share narrowed down code snippet along with source and generated file so that we may investigate the repetition of image and help you out.

I have tried to add image to a table row having 2 cell. Here is the code, I’m using.

var document = new Document();

        Page page = document.Pages.Add();

        Table documentTable = new Table();

        documentTable.ColumnWidths = "50% 50%";

        var row = documentTable.Rows.Add();

        Image img1 = new Image();
        img1.File = @"C:\temp\images\surfacemountains-studio.JPG";

        Image img2 = new Image();
        img2.File = @"C:\temp\images\surface-pro-6.JPG";

        //img.FixWidth = 250;
        //img.FixHeight = 200;

        var cell1 = row.Cells.Add();

        cell1.Margin = new MarginInfo(2, 2, 2, 2);

        cell1.Paragraphs.Add(img1);

        var cell2 = row.Cells.Add();

        cell2.Margin = new MarginInfo(2, 2, 2, 2);;

        cell2.Paragraphs.Add(img2);

        page.Paragraphs.Add(documentTable);

        try
        {
            document.Save(@"c:\temp\report.pdf");
        }
        catch (Exception ex)
        {
            
        }

The pdf shows images in the two table cell but does not look scaled down (just like resize option in MS Paint, there it works)

i will send another example for image repetition later.

Thanks,
Anuj
report.pdf (3.5 MB)

surface-pro-6.jpg (171.8 KB)
surfacemountains-studio.jpg (1.3 MB)

A post was split to a new topic: Image being repeated in next page

@anujshukla

Thank you for sharing requested data.

We always recommend posting separate issues as separate topics so that we may efficiently address your concerns. Therefore, we have split your other issue as a separate topic which will be taken care of separately.

About this scenario, we have tried to resize shared image surfacemountains-studio.jpg to 200*500 pixel image with Paint application and resultant image looks almost identical to the images resized by Aspose.PDF for .NET API in your PDF file report.pdf. A screenshot has been attached for your kind reference Paint.PNG.

In case you still notice differences then please elaborate further so that we may investigate accordingly.