Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Mon Feb 20, 2023 4:39 pm

Hi, is it possible to write one PdfAttachmentAnnotation link into Grid cellule ?

Thanks

ronancreativeit
 
Posts: 2
Joined: Wed Feb 03, 2021 10:08 am

Tue Feb 21, 2023 10:33 am

Hi,

Thanks for your inquiry.
Please see the following code for reference.
Code: Select all
            PdfDocument pdf = new PdfDocument();
            PdfPageBase page = pdf.Pages.Add();
            PdfGrid grid = new PdfGrid();

            grid.Columns.Add(3);
            float x = 50;
            float y = 100;

            float width = 100;
            float height = 20;

            //Set the width
            for (int j = 0; j < grid.Columns.Count; j++)
            {
                grid.Columns[j].Width = width;
            }

            //Add rows
            PdfGridRow row0 = grid.Rows.Add();
            PdfGridRow row1 = grid.Rows.Add();

            //Set the height
            for (int i = 0; i < grid.Rows.Count; i++)
            {
                grid.Rows[i].Height = height;
               
            }

            grid.Draw(page, new PointF(x, y));

            x = x + width + 18;
            y = y + 2;
 
            byte[] data = File.ReadAllBytes("SalesReportChart.png");
            PdfTrueTypeFont font2 = new PdfTrueTypeFont(new Font("Arial", 14f, FontStyle.Bold));
            PointF location = new PointF(x, y);
            String label = "Report";
           
            SizeF size = font2.MeasureString(label);
            RectangleF bounds = new RectangleF(location, size);
            page.Canvas.DrawString(label, font2, PdfBrushes.DarkOrange, bounds);
            bounds = new RectangleF(bounds.Right, bounds.Top, font2.Height, font2.Height);

            //Create a PdfAttachmentAnnotation
            PdfAttachmentAnnotation annotation1
                = new PdfAttachmentAnnotation(bounds, "SalesReportChart.png", data);
            annotation1.Color = Color.Teal;
            annotation1.Flags = PdfAnnotationFlags.ReadOnly;
            annotation1.Icon = PdfAttachmentIcon.Graph;
            annotation1.Text = "Report";
            //Add the annotation1
            page.AnnotationsWidget.Add(annotation1);

            pdf.SaveToFile("out.pdf");


If the code does not meet your requirement, please provide us with your document and describe the effect you want clearly. Thanks for your assistance.

Sincerely,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Wed Feb 22, 2023 9:29 am

Thanks a lot for the assistance.

Another question :

is it possible to custom the PdfAttachmentIcon with pdfImage for example ?

Thanks again !

ronancreativeit
 
Posts: 2
Joined: Wed Feb 03, 2021 10:08 am

Thu Feb 23, 2023 6:32 am

Hi,

Thanks for your inquiry.
Our Spire.PDF follows the rules of Adobe PDF, since Adobe PDF does not support custom PdfAttachment icon at present, for your requirement, our Spire.PDF does not support it either. Thanks for your understanding.

Sincerely,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Return to Spire.PDF

cron