Adding new pages to pdf onLoad

Hello , 
I'm currently using angular  pdf viewer with .netCore web API controller , Can I insert empty page at the start and the end on the fly inside the loading API .

Or if there any method to add pages on the fly for the angular pdf viewer

My code : 
public IActionResult Load([FromBody] Dictionary<string, string> jsonObject)
        {
            S
            Console.WriteLine("Load called");
            //Initialize the PDF Viewer object with memory cache object
            PdfRenderer pdfviewer = new PdfRenderer(_cache);
            MemoryStream stream = new MemoryStream();
            object jsonResult = new object();
            if (jsonObject != null && jsonObject.ContainsKey("document"))
            {
                if (bool.Parse(jsonObject["isFileName"]))
                {
                    string documentPath = GetDocumentPath("TEMPLATE_DIR_PATH" + jsonObject["document"]);
                    if (!string.IsNullOrEmpty(documentPath))
                    {
                        byte[] bytes = System.IO.File.ReadAllBytes(documentPath);
                        stream = new MemoryStream(bytes);
                    }
                    else
                    {
                        return this.Content(jsonObject["document"] + " is not found");
                    }
                }
                else
                {
                    byte[] bytes = Convert.FromBase64String(jsonObject["document"]);
                    stream = new MemoryStream(bytes);
                }
            }
            jsonResult = pdfviewer.Load(stream, jsonObject);
            
            return Content(JsonConvert.SerializeObject(jsonResult));
        }


Thanks,
Mohamed 

3 Replies

AA Akshaya Arivoli Syncfusion Team May 15, 2020 06:14 AM UTC

Hi Mohamed, 

Thank you for contacting Syncfusion support. 

We can add the extra pages in the PDF document using our PDF Base library in the Load() Web action method. We have created sample for the same and shared in the below link, 


Please refer to the below UG link for more details, 


Please try it and revert us if you need any further assistance. 


Regards, 
Akshaya 



MO Mohamed May 17, 2020 01:42 AM UTC

Thanks Akshaya, it worked. 

Can I send any extra parameters to the load function ? as In my angular code I set the service URL and the document Path and the function is triggered automatically. Like adding any extra input for the angular component that will be passed to the Load API. 

Thanks,
Mohamed 



AA Akshaya Arivoli Syncfusion Team May 18, 2020 11:02 AM UTC

Hi Mohamed, 

Thank for your update. 

We can pass the extra parameters from client to server using the setjsondata() API. ajaxRequestInitiate will be triggered before sending the request in that you can the necessary arguments which we need to send , then pass that date into setJsonData () to get it in server. Please refer to the below sample and the screenshot for reference. Kindly check with latest version 18.1.0.42. 





 



Please try it and if you still have concerns revert us with more details about issue, exception/console error details if any. These details will be helpful for us to investigate further and assist you better. 

Regards, 
Akshaya  


Loader.
Up arrow icon