Telerik Forums
Telerik Document Processing Forum
0 answers
65 views
public static void SignPDFSynfusion(SignatureInfo signInfo, byte[] inDocByte, Cert objCert, string customSignatureDetails, out byte[] outDocPdf)
{
    // Dimensions and positions for the signature field
    double signatureFieldWidth; // Width of the signature field
    double signatureFieldHeight;
    double signaturePositionLeft;
    double signaturePositionTop;
   
    // Getting TimeStamp Details from Database..
    TimeStampSettings objTimeStampSettings = new TimeStampSettings();
    TimeStampInfo objTimeStampInfo = (TimeStampInfo)objTimeStampSettings.GetTimeStamp();
    PfxSettings objPfxSettings = new PfxSettings();

    // Params to take account in the input
    bool displaySignature = Convert.ToBoolean(HttpContext.Current.Session["showSign"]);

    bool needTimeStamp = false;
    string TsaServerUrl = "";
    string TsaServerUser = "";
    string TsaServerPassword = "";
    string strPasswrd = string.Empty;
    double imageWidth = 0;

    if (objTimeStampInfo != null)
    {
        needTimeStamp = (bool)objTimeStampInfo.TimeStampNeeded;
        TsaServerUrl = objTimeStampInfo.TimeStampUrl;

        if ((bool)objTimeStampInfo.AuthNeeded)
        {
            TsaServerUser = objTimeStampInfo.UserName;
            strPasswrd = SecurQueryString.decryptQueryString(objTimeStampInfo.Password);
            TsaServerPassword = strPasswrd;
        }
    }
    // Load the certificate
    X509Certificate2 certificate = new X509Certificate2(objCert.CertArray, objCert.Password);

    // Create a SignatureField and assign the digital signature to it
    SignatureField pdfSignature = new SignatureField("SignatureField");
    pdfSignature.Signature = new Telerik.Windows.Documents.Fixed.Model.DigitalSignatures.Signature(certificate);

    // Set signature details
    string strNotAvailable = HttpContext.GetGlobalResourceObject("GlobalResources", "lblNotAvlbl").ToString();
    pdfSignature.Signature.Properties.Reason = strNotAvailable;
    pdfSignature.Signature.Properties.ContactInfo = strNotAvailable;
    pdfSignature.Signature.Properties.Location = strNotAvailable;

    // Create a new form to place the signature field
    Form pdfForm = new Form();
    pdfForm.FormSource = new FormSource();

    // Load the existing PDF from the byte array using PdfFormatProvider
    using (MemoryStream inputStream = new MemoryStream(inDocByte))
    {
        // Create PdfFormatProvider and load the existing document
        PdfFormatProvider provider = new PdfFormatProvider();
        RadFixedDocument document = provider.Import(inputStream);

        int pageNo = (signInfo.DigitalSignPage() == 0 ? 1 : document.Pages.Count);
        try
        {
            if (needTimeStamp)
            {
                //.TimeStampServer = new TimeStampServer(new Uri(TsaServerUrl), TsaServerUser, TsaServerPassword);
            }
        }
        catch (Exception ex)
        { }

        // Path to the image (ensure this is correct)
        System.Drawing.Image signatureImage = null;
        if (signInfo.DigitalSignMode() == 2 && HttpContext.Current.Session["imagesyncfusion"] != null)
        {
            signatureImage = (System.Drawing.Image)HttpContext.Current.Session["imagesyncfusion"];
        }
        //var signatureImage = (System.Drawing.Image)HttpContext.Current.Session["imagesyncfusion"];

        if (signInfo.UseDigitalSign())
        {
            if ((signInfo.DigitalSignMode() == 1) || (signInfo.DigitalSignMode() == 2))
            {
                signaturePositionLeft = (double)signInfo.DigitalSignLeftInPoints();
                signaturePositionTop = (double)signInfo.DigitalSignTopInPoints();
                signatureFieldWidth = (double)signInfo.DigitalSignWidthInPoints();
                signatureFieldHeight = (double)signInfo.DigitalSignHeightInPoints();
                RadFixedPage radFixedPage = document.Pages[pageNo - 1];
                if (!string.IsNullOrEmpty(customSignatureDetails))
                {
                    //Movable case:
                    signatureFieldWidth = signaturePositionLeft + (double)signInfo.DigitalSignWidthInPoints();
                    signatureFieldHeight = signaturePositionTop + (double)signInfo.DigitalSignHeightInPoints();

                    string[] separator = new string[] { "!_!" };
                    string[] offsetArray = customSignatureDetails.Split(separator, StringSplitOptions.RemoveEmptyEntries);

                    if (offsetArray.Length >= 9)
                    {
                        float offsetLeft = returnFloatWithCultureValue(offsetArray[0]);
                        float offsetTop = returnFloatWithCultureValue(offsetArray[1]);
                        float docHeight = returnFloatWithCultureValue(offsetArray[2]);
                        float greenDivHeight = returnFloatWithCultureValue(offsetArray[3]);
                        float greenDivWidth = returnFloatWithCultureValue(offsetArray[4]);
                        float dpi_x = returnFloatWithCultureValue(offsetArray[6]);
                        float dpi_y = returnFloatWithCultureValue(offsetArray[7]);
                        pageNo = int.Parse(offsetArray[8]);

                        // Calculate positions for drawing the text div;
                        signaturePositionLeft = (offsetLeft / dpi_x) * 72;
                        signaturePositionTop = (offsetTop / dpi_y) * 72;
                        signatureFieldWidth = (greenDivWidth / dpi_y) * 72;
                        signatureFieldHeight = (greenDivHeight / dpi_x) * 72;

                        pdfForm.FormSource.Size = new Telerik.Documents.Primitives.Size(signatureFieldWidth, signatureFieldHeight);

                    }
                }
                else
                {
                    //Non-movable case:
                    radFixedPage = document.Pages[pageNo - 1];
                    Tuple<double, double> k = null;

                    if (signatureImage != null)
                    {
                        k = calculateAspectRatioFit(signatureImage.Width, signatureImage.Height, signatureFieldWidth, signatureFieldHeight);
                        signatureFieldWidth = k.Item1;
                        signatureFieldHeight = k.Item2;
                    }

                    signaturePositionLeft = radFixedPage.Size.Height - (double)(signatureFieldWidth + signatureFieldHeight + 1);
                    signaturePositionTop = signaturePositionTop + 1; // +1 For border size
                    pdfForm.FormSource.Size = new Telerik.Documents.Primitives.Size(signatureFieldWidth, signatureFieldHeight);
                }
                FixedContentEditor editor = new FixedContentEditor(pdfForm.FormSource);
                // Drawing the image at the starting position (left side of the signature field)
                imageWidth = signatureFieldWidth / 2;  // Half the width for the image
                double imageHeight = signatureFieldHeight;  // Use full height of the signature field

                if (signatureImage == null)
                {

                }
                else
                {
                    // Create a memory stream to hold the image
                    using (MemoryStream ms = new MemoryStream())
                    {
                        // Save the image to the memory stream
                        signatureImage.Save(ms, signatureImage.RawFormat);

                        // Reset the stream position to the beginning
                        ms.Position = 0;

                        // Pass the memory stream to the DrawImage method
                        editor.DrawImage(ms, new Telerik.Documents.Primitives.Size(imageWidth, imageHeight));
                    }
                }
                string textToDraw = $"Digitally signed by {certificate.FriendlyName} \nDate: {DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss zzz")} \nReason: {pdfSignature.Signature.Properties.Reason} \nLocation: {pdfSignature.Signature.Properties.Location}";
                // Set the width of the text area (remaining space after the image)
                double textWidth = signatureFieldWidth - imageWidth;
                double dsd = CalculateFontSize(textWidth, signatureFieldHeight, textToDraw);

                // Now, draw the text next to the image (on the right side), within the remaining space
                Telerik.Windows.Documents.Fixed.Model.Editing.Block textBlock = new Telerik.Windows.Documents.Fixed.Model.Editing.Block();
                double textPositionLeft = signaturePositionLeft + imageWidth;  // Adding a 5px gap after the image
                textBlock.TextProperties.FontSize = 8;
                textBlock.InsertText($"Digitally signed by {certificate.FriendlyName}");
                textBlock.InsertText($" Date: {DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss zzz")}");
                textBlock.InsertText($" Reason: {pdfSignature.Signature.Properties.Reason}");
                textBlock.InsertText($" Location: {pdfSignature.Signature.Properties.Location}");
                Rect boundingRect = new Rect(textPositionLeft - 8, signaturePositionTop - 12, textWidth, signatureFieldHeight);
                textBlock.Draw(editor, boundingRect);

                // Create the SignatureWidget and position it on the PDF page
                SignatureWidget signatureWidget = pdfSignature.Widgets.AddWidget();
                signatureWidget.Content.NormalContentSource = pdfForm.FormSource;
                signatureWidget.Rect = new Rect(signaturePositionLeft, signaturePositionTop, signatureFieldWidth, signatureFieldHeight);
                signatureWidget.RecalculateContent();

                // Add content from the form to the page at the specified position
                RadFixedPage pdfPage = document.Pages[0];  // Assuming you're adding it to the first page
                FixedContentEditor pageEditor = new FixedContentEditor(pdfPage);
                pageEditor.Position.Translate(signaturePositionLeft, signaturePositionTop);
                pageEditor.DrawForm(pdfForm.FormSource);

                // Add the signature field to the document's AcroForm
                document.AcroForm.FormFields.Add(pdfSignature);
            }
        }

        // Use MemoryStream to capture the PDF output and return as a byte array
        using (MemoryStream memoryStream = new MemoryStream())
        {
            // Export the document to the memory stream as a PDF
            Telerik.Documents.ImageUtils.ImagePropertiesResolver defaultImagePropertiesResolver = new Telerik.Documents.ImageUtils.ImagePropertiesResolver();
            Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.ImagePropertiesResolver = defaultImagePropertiesResolver;
            var settings = new PdfExportSettings();
            settings.ImageQuality = ImageQuality.High;
            provider.ExportSettings = settings;
            provider.Export(document, memoryStream);
            // Return the byte array of the PDF
            outDocPdf = memoryStream.ToArray();
            //return memoryStream.ToArray(); // Return the byte array of the signed PDF
        }
    }
}
       private static double CalculateFontSize(double textWidth, double signatureFieldHeight, string text)
       {
           // Start with a base font size for better precision
           double baseFontSize = 12.0;  // Starting font size

           // Calculate width scale factor to adjust the font size based on text length
           double widthScaleFactor = textWidth / text.Length;
           double widthFontSize = baseFontSize * widthScaleFactor;

           // Calculate height scale factor to adjust the font size based on the number of lines
           int numLines = text.Split('\n').Length;
           double heightScaleFactor = signatureFieldHeight / (numLines * baseFontSize);
           double heightFontSize = baseFontSize * heightScaleFactor;

           // Return the smaller font size to fit both dimensions
           return Math.Min(widthFontSize, heightFontSize);
       }

       public static Tuple<double, double> calculateAspectRatioFit(double srcWidth, double srcHeight, double maxWidth, double maxHeight)
       {
           var ratio = Math.Min(maxWidth / srcWidth, maxHeight / srcHeight);
           return new Tuple<double, double>(srcWidth * ratio, srcHeight * ratio);
       }
1 answer
75 views

firstly loading the document i have use 
  // Load the PDF document
  var provider = new PdfFormatProvider();
  var loadedDocument = provider.Import(inDocByte,null);

and after some functinality to export the document i have used below 

 Telerik.Documents.ImageUtils.ImagePropertiesResolver defaultImagePropertiesResolver = new Telerik.Documents.ImageUtils.ImagePropertiesResolver();
 Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.ImagePropertiesResolver = defaultImagePropertiesResolver;
 provider.Export(document, memoryStream, null);
 outDocPdf = memoryStream.ToArray();

what was the problem can you tell me the solution for that exception

Unable to cast object of type 'Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Types.PdfLiteralString' to type 'Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Types.PdfName'.

Dess | Tech Support Engineer, Principal
Telerik team
 answered on 09 Dec 2024
1 answer
105 views
the below method i got the exception i don't know what's wrong  can  anyone tell me 
the exception is occurred in below line 
  // Create PdfFormatProvider and load the existing document
 PdfFormatProvider pdfFormatProvider = new PdfFormatProvider();
 RadFixedDocument document = pdfFormatProvider.Import(inputStream);


static byte[] GenerateSignedPdf(Cert objCert, byte[] inDocByte)
{
    // Dimensions and positions for the signature field
    int signatureFieldWidth = 200; // Width of the signature field
    int signatureFieldHeight = 50;
    int signaturePositionLeft = 10;
    int signaturePositionTop = 10;

    // Load the certificate
    X509Certificate2 certificate = new X509Certificate2(objCert.CertArray, objCert.Password);

    // Create a SignatureField and assign the digital signature to it
    SignatureField pdfSignature = new SignatureField("SignatureField");
    pdfSignature.Signature = new Telerik.Windows.Documents.Fixed.Model.DigitalSignatures.Signature(certificate);

    // Set signature details
    string strNotAvailable = HttpContext.GetGlobalResourceObject("GlobalResources", "lblNotAvlbl").ToString();
    pdfSignature.Signature.Properties.Reason = strNotAvailable;
    pdfSignature.Signature.Properties.ContactInfo = strNotAvailable;
    pdfSignature.Signature.Properties.Location = strNotAvailable;

    // Load the existing PDF from the byte array using PdfFormatProvider
    using (MemoryStream inputStream = new MemoryStream(inDocByte))
    {
        // Create PdfFormatProvider and load the existing document
        PdfFormatProvider pdfFormatProvider = new PdfFormatProvider();
        RadFixedDocument document = pdfFormatProvider.Import(inputStream);

        // Create a new form to place the signature field
        Form pdfForm = new Form();
        pdfForm.FormSource = new FormSource();
        pdfForm.FormSource.Size = new Telerik.Documents.Primitives.Size(signatureFieldWidth, signatureFieldHeight);
        FixedContentEditor editor = new FixedContentEditor(pdfForm.FormSource);

        // Path to the image (ensure this is correct)
        var signatureImage = (System.Drawing.Image)HttpContext.Current.Session["imagesyncfusion"];

        // Drawing the image at the starting position (left side of the signature field)
        int imageWidth = signatureFieldWidth / 2;  // Half the width for the image
        int imageHeight = signatureFieldHeight;  // Use full height of the signature field

        // Create a memory stream to hold the image
        using (MemoryStream ms = new MemoryStream())
        {
            // Save the image to the memory stream
            signatureImage.Save(ms, signatureImage.RawFormat);

            // Reset the stream position to the beginning
            ms.Position = 0;

            // Pass the memory stream to the DrawImage method
            editor.DrawImage(ms, new Telerik.Documents.Primitives.Size(imageWidth, imageHeight));
        }

        string textToDraw = $"Digitally signed by {certificate.FriendlyName} \nDate: {DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss zzz")} \nReason: {pdfSignature.Signature.Properties.Reason} \nLocation: {pdfSignature.Signature.Properties.Location}";
        // Set the width of the text area (remaining space after the image)
        int textWidth = signatureFieldWidth - imageWidth;
        double dsd = CalculateFontSize(textWidth - 23, signatureFieldHeight, textToDraw);

        // Now, draw the text next to the image (on the right side), within the remaining space
        Telerik.Windows.Documents.Fixed.Model.Editing.Block textBlock = new Telerik.Windows.Documents.Fixed.Model.Editing.Block();
        int textPositionLeft = signaturePositionLeft + imageWidth;  // Adding a 5px gap after the image
        textBlock.TextProperties.FontSize = dsd;
        textBlock.InsertText($"Digitally signed by {certificate.FriendlyName}");
        textBlock.InsertText($" Date: {DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss zzz")}");
        textBlock.InsertText($" Reason: {pdfSignature.Signature.Properties.Reason}");
        textBlock.InsertText($" Location: {pdfSignature.Signature.Properties.Location}");
        Rect boundingRect = new Rect(textPositionLeft - 8, signaturePositionTop - 12, textWidth, signatureFieldHeight);
        textBlock.Draw(editor, boundingRect);

        // Create the SignatureWidget and position it on the PDF page
        SignatureWidget signatureWidget = pdfSignature.Widgets.AddWidget();
        signatureWidget.Content.NormalContentSource = pdfForm.FormSource;
        signatureWidget.Rect = new Rect(signaturePositionLeft, signaturePositionTop, signatureFieldWidth, signatureFieldHeight);
        signatureWidget.RecalculateContent();

        // Add content from the form to the page at the specified position
        RadFixedPage pdfPage = document.Pages[0];  // Assuming you're adding it to the first page
        FixedContentEditor pageEditor = new FixedContentEditor(pdfPage);
        pageEditor.Position.Translate(signaturePositionLeft, signaturePositionTop);
        pageEditor.DrawForm(pdfForm.FormSource);

        // Add the signature field to the document's AcroForm
        document.AcroForm.FormFields.Add(pdfSignature);

        // Use MemoryStream to capture the PDF output and return as a byte array
        using (MemoryStream memoryStream = new MemoryStream())
        {
            // Export the document to the memory stream as a PDF
            pdfFormatProvider.Export(document, memoryStream);
            return memoryStream.ToArray(); // Return the byte array of the signed PDF
        }
    }
}
Dess | Tech Support Engineer, Principal
Telerik team
 answered on 09 Dec 2024
1 answer
83 views
If you reference the Telerik.Reporting and Telerik.Documents.Flow packages, you cannot use the Telerik.Documents.Core.Fonts.Fontfamily. Reports that it exists in both the packages. Even when aliasing or fully qualifying, it reports the same message that FontWeights and FontFamily exists in both the packages.
Yoan
Telerik team
 answered on 05 Dec 2024
1 answer
49 views

Hi,

1) i want to add and image and text in the signature field with specified size and i want to do that in the existing pdf with signature field ?
2) how to add any type of image [jpg, jpeg , png, etc.] in extsting pdf 
 static byte[] GenerateSignedPdf(Cert objCert)
 {
     // Dimensions and positions for the signature field
     int signatureFieldWidth = 200;
     int signatureFieldHeight = 50;
     int signaturePositionLeft = 10;
     int signaturePositionTop = 10;

     // Load the certificate
     X509Certificate2 certificate = new X509Certificate2(objCert.CertArray, objCert.Password);

     // Create a SignatureField and assign the digital signature to it
     SignatureField pdfSignature = new SignatureField("SignatureField");
     pdfSignature.Signature = new Telerik.Windows.Documents.Fixed.Model.DigitalSignatures.Signature(certificate);

     // Create a new form to place the signature field
     Form pdfForm = new Form();
     pdfForm.FormSource = new FormSource();
     pdfForm.FormSource.Size = new Telerik.Documents.Primitives.Size(signatureFieldWidth, signatureFieldHeight);
     FixedContentEditor editor = new FixedContentEditor(pdfForm.FormSource);

     // Draw the text with certificate holder's name and current date
     string textToDraw = $"{certificate.GetNameInfo(X509NameType.SimpleName, false)} {DateTime.Now:yyyy.MM.dd HH:mm}";
     editor.DrawText(textToDraw, new Telerik.Documents.Primitives.Size(5, 5)); // Adjust position as needed

     // Path to the image (ensure this is correct)
     string imagePath = "C:/Vaibhav/ProjectVaibhav/PdfProcessing_InsertImageInExistingPdf/image.png"; // Change path as needed

     // Ensure the image exists and can be accessed
     if (File.Exists(imagePath))
     {
         using (var imageStream = new FileStream(imagePath, FileMode.Open, FileAccess.Read))
         {
             var imageSource = new ImageSource(imageStream);
             editor.DrawImage(imageSource, new Telerik.Documents.Primitives.Size(100, 50)); // Adjust image size and position as needed
         }
     }
     else
     {
         throw new FileNotFoundException("Image file not found at: " + imagePath);
     }

     // Create the SignatureWidget and position it on the PDF page
     SignatureWidget signatureWidget = pdfSignature.Widgets.AddWidget();
     signatureWidget.Content.NormalContentSource = pdfForm.FormSource;
     signatureWidget.Rect = new Rect(signaturePositionLeft, signaturePositionTop, signatureFieldWidth, signatureFieldHeight);
     signatureWidget.RecalculateContent();

     // Create a RadFixedDocument and add a page
     RadFixedDocument document = new RadFixedDocument();
     RadFixedPage pdfPage = document.Pages.AddPage();
     pdfPage.Annotations.Add(signatureWidget);

     // Add content from the form to the page at the specified position
     FixedContentEditor pageEditor = new FixedContentEditor(pdfPage);
     pageEditor.Position.Translate(signaturePositionLeft, signaturePositionTop);
     pageEditor.DrawForm(pdfForm.FormSource);

     // Add the signature field to the document's AcroForm
     document.AcroForm.FormFields.Add(pdfSignature);

     // Use MemoryStream to capture the PDF output and return as a byte array
     using (MemoryStream memoryStream = new MemoryStream())
     {
         var pdfFormatProvider = new PdfFormatProvider();
         pdfFormatProvider.Export(document, memoryStream);
         return memoryStream.ToArray(); // Return the byte array of the PDF
     }
 }

1 answer
154 views
System.InvalidOperationException: 'FixedExtensibilityManager.ImagePropertiesResolver and FixedExtensibilityManager.JpegImageConverter cannot be both null. The .NET Standard does not define APIs for decoding images. That`s why in order to export images different than Jpeg and Jpeg2000 and ImageQuality different than High you will need to reference the Telerik.Documents.ImageUtils assembly/NuGet in your project and to set its basic implementation to the ImagePropertiesResolver/JpegImageConverter property or to create a custom one inheriting the ImagePropertiesResolverBase/JpegImageConverterBase class. For more information go to: https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/cross-platform/images'
Dess | Tech Support Engineer, Principal
Telerik team
 answered on 28 Nov 2024
1 answer
189 views

How can i add borders to the first page or section?

I find the property borders in Paragraph, but i cant find it in Section, how can i add the border to the full page or section?

Example attached.

 

Regard

Yoan
Telerik team
 updated answer on 28 Oct 2024
0 answers
88 views

I am trying to programmatically reproduce a header, and nothing I've tried will add a background color or shading.  How do you format a table in a header?


HtmlFormatProvider provider = new HtmlFormatProvider();
RadFlowDocument html = provider.Import(sb.ToString());
Section section = html.Sections[0];
section.PageMargins = new Telerik.Windows.Documents.Primitives.Padding(24);
ThemableColor gray = new ThemableColor(new System.Windows.Media.Color {R = 220, G = 220, B = 220});

Header header = section.Headers.Add();
Table table = header.Blocks.AddTable();
TableRow row1 = table.Rows.AddTableRow();
TableCell Title = row1.Cells.AddTableCell();
TableCell Version = row1.Cells.AddTableCell();

Title.PreferredWidth = new TableWidthUnit(384);
Title.Shading.BackgroundColor = gray;
Title.Blocks.AddParagraph().Inlines.AddRun("Executive Summary");

Version.PreferredWidth = new TableWidthUnit(384);
Version.Shading.BackgroundColor = gray;
Version.Blocks.AddParagraph().Inlines.AddRun("Version Name:");

TableRow row2 = table.Rows.AddTableRow();
TableCell Incident = row2.Cells.AddTableCell();
TableCell Period = row2.Cells.AddTableCell();
                    
Incident.Blocks.AddParagraph().Inlines.AddRun("Incident:");
Period.Blocks.AddParagraph().Inlines.AddRun("Period:");

PdfFormatProvider pdf = new PdfFormatProvider();

return pdf.Export(html);

The attached Header.png is an example of what I'm trying to reproduce.

Darwin
Top achievements
Rank 1
 asked on 22 Oct 2024
2 answers
77 views

Hi,

I have: Telerik UI for ASP.NET AJAX

I test SplitDocumentPages from PDF example. from https://github.com/telerik/document-processing-sdk/blob/master/PdfProcessing/ManipulatePages/Program.cs

net.framework: 4.8

test pdf is: https://github.com/telerik/document-processing-sdk/blob/master/PdfProcessing/ManipulatePages/InputFiles/MultipageDocument.pdf

Not working well. see picture split1.pdf, only large rectangle without any data.

Please help.

Thx

Richard
Top achievements
Rank 1
Iron
 answered on 16 Oct 2024
1 answer
63 views

Hi,

 

I have an existing xlsx file that contains graphics (drawing)

I simply open the workbook, 


var workbook = CreateWorkbook();

byte[] bytes;

using (var output = new MemoryStream())
{
    new XlsxFormatProvider().Export(workbook, output);
    bytes = output.ToArray();
}

File.WriteAllBytes("c:\\Logs\\test.xlsx", bytes);


private Workbook CreateWorkbook()
{
    Workbook workbook;
    IWorkbookFormatProvider formatProvider = new XlsxFormatProvider();
    FileStream? stream = null;
    try
    {
        stream = File.Open("AnalyseImpayeTemplate.xlsx", FileMode.Open);
        workbook = formatProvider.Import(stream);
    }
    catch (IOException ex)
    {
        throw new IOException("The file cannot be opened. It might be locked by another application.", ex);
    }
    finally
    {
        stream?.Dispose();
    }

    return workbook;
}

When I open the result file, with release 2024.3.806, I got an error. It delete drawing parts :

Partie supprimée: /xl/drawings/drawing1.xml partie.  (Forme de dessin)

With release 2024.2.426, it works fine.

Any ideas why?

Yoan
Telerik team
 answered on 08 Oct 2024
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?