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

Free Support Forum - aspose.com

Reference to CommonUtilities

Hi I just installed GroupDocs.Assembly via nuget in Visual Studio. In C#, I have added references to GroupDocs.Assembly amd

GroupDocs.Assembly.Data, but I couldn’t find reference to CommonUtilities, eg. assembler.AssembleDocument(CommonUtilities.GetSourceDocument

(strDocumentTemplate). Where can I find the component?

Please note that I’m following this example: https://blog.groupdocs.com/2021/03/20/generate-reports-from-json-data-in-csharp/

Thank you for your support.

@j2bmw

CommonUtilities is a custom class. Please download or clone this updated example project and let us know if you face any issue. You can further explore this developer guide.

Hi Atir_Tahir,
Thanks for your reply.
We are evaluating PDF tools for generating PDF reports with 10000 lines quickly. We tried your Aspose.Cells. It took about 8s. We’s like to achieve it within 2s. I should be grateful if you can shed light. An example code would be appreciated. Please see my test code using Aspose below. I wonder GraphDocs may be an option.

    private static void ExportToPdfFromJson(List<HistoryLogReportRow> report)
    {
        var startTime = DateTime.Now;
        
        // create a Workbook object
        var workbook = new Workbook();

        // access default worksheet
        var worksheet = workbook.Worksheets[0];

        // read JSON data from file
        string jsonInput = JsonSerializer.Serialize<List<HistoryLogReportRow>>(report);

        // set JsonLayoutOptions to treat Arrays as Table
        var options = new JsonLayoutOptions();
        options.ArrayAsTable = true;

        // Obtaining the reference of the PageSetup of the worksheet
        PageSetup pageSetup = worksheet.PageSetup;

        // Setting worksheet name at the left section of the header
        pageSetup.SetHeader(0, "&\"Times New Roman,Bold\"&20 WMS+ History Report");

        // Setting current date and current time at the right section of the header
        // and changing the font of the header
        pageSetup.SetHeader(2, "&D-&T");

        // Setting current file name at the right section of the header and changing the
        // font of the header
        //pageSetup.SetHeader(2, "&\"Times New Roman,Bold\"&12&F");

        // Setting a string at the left section of the footer and changing the font
        // of a part of this string ("Carrier")
        pageSetup.SetFooter(0, "&\"Courier New\"&14 Carrier");

        // Setting the current page number at the central section of the footer
        //pageSetup.SetFooter(1, "&P");

        // Setting page count at the right section of footer
        pageSetup.SetFooter(2, "Page &P of &N");

        // import JSON data to worksheet starting at cell A1
        JsonUtility.ImportData(jsonInput, worksheet.Cells, 0, 0, options);

        //worksheet.AutoFitColumns();
        worksheet.Cells.SetColumnWidth(0, 20);
        worksheet.Cells.SetColumnWidth(1, 20);
        worksheet.Cells.SetColumnWidth(2, 80);
        worksheet.Cells.SetColumnWidth(3, 20);
        worksheet.Cells.SetColumnWidth(4, 20);

        foreach (Worksheet item in workbook.Worksheets)
        {
            item.PageSetup.Orientation = PageOrientationType.Landscape;
        }

        PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
        pdfSaveOptions.AllColumnsInOnePagePerSheet = true;
        // convert imported JSON to PDF
        workbook.Save("historyReport.pdf", pdfSaveOptions);

        // convert imported JSON to PDF
        //workbook.Save("historyReport.pdf", SaveFormat.Auto);

        var elapsedTime = DateTime.Now.Subtract(startTime).TotalMilliseconds;
    }

@j2bmw,

It depends upon the number of columns also. But, I think it is reasonable time if it has complex data with more columns list. By the way, did you check which of the following line of code is taking more time to process:

JsonUtility.ImportData(jsonInput, worksheet.Cells, 0, 0, options);

or

pdfSaveOptions.AllColumnsInOnePagePerSheet = true;
(Please note this line might take more time if there is long list of columns to be pasted on page)

Anyways, if you still think it is an issue regarding performance, kindly do share a sample a standalone VS.NET console application with JSON data (file) to reproduce the issue on our end. We will check it soon.

PS. please zip the project with resource files prior attaching here (please exclude Aspose.Cells.Dll to minimize the size)

@Amjad_Sahi Thanks. The number of columns of the sample data is just 5. The data are very simple. Please see the attachment. The two methods you mentioned don’t take much time (within 123 ms or may be as low as a couple of ms). JsonUtility.ImportData(jsonInput, worksheet.Cells, 0, 0, options);

or

pdfSaveOptions.AllColumnsInOnePagePerSheet = true;

workbook.Save(“historyReport.pdf”, pdfSaveOptions); took most of the time. Changing pdfSaveOptions to SaveFormat.Auto from pdfSaveOptions.AllColumnsInOnePagePerSheet = true seems having no difference. Please shed light.

Please find Aspose ExportToPdfFromJson data and source.zip:

@j2bmw,

I tested your code using our latest version/fix Aspose.Cells for .NET v21.10.1 (attached), please try it:
Aspose.Cells21.10.1 For .Net2_AuthenticodeSigned.Zip (5.6 MB)
Aspose.Cells21.10.1 For .Net4.0.Zip (5.6 MB)
Aspose.Cells21.10.1 For .NetStandard20.Zip (5.6 MB)

it works normally and efficiently. See the output console for your reference:

  1. JsonUtility.ImportData elapsed time 119.0794
  2. SetColumnWidth elapsed time 121.0799
  3. PageSetup.Orientation elapsed time 121.0799
  4. set pdfSaveOptions.AllColumnsInOnePagePerSheet elapsed time 123.0825
  5. workbook.Save elapsed time 1355.9016

I changed your line of code (as I could not process it) by following:

    // Read File
    string jsonInput = File.ReadAllText("e:\\test2\\historyReport.json");

Please try our latest version and let us know if you still find any issue.

Hi Amjad,

This is good news. Can you please send me Aspose.Cells for .NET 5.0 v21.10.1?

I’ve tried the component for .NET 4.0 in my .NET 5.0 project, I got the following error:
Could not load file or assembly ‘Aspose.Cells, Version=21.10.1.0, Culture=neutral, PublicKeyToken=716fcc553a201e56’. The system cannot find the file specified.

Thanks and regards,

Outlook-rhlbtl4m.png (498 Bytes)

Hi Amjad, Yes, new Aspose cells is very good. Another question: if our PDF format is just simple reports, will Aspose cells be enough? Do we need to use Aspose.Pdf? I think groupdocs is also your product. Which product offers the best performance (fastest pdf generation), Aspose cells, Aspose.Pdf or groupdocs? Thanks for your support.

Hi Amjad,

Sorry I gave you a json data file with fewer than 10000 lines. The total PDF generation and saving time would be 4.5s for the attached json data file with 10000 lines. Is there any room for improvement? It seems the real issue is the number of the lines of the data source rather than the version of Aspose Cells.

Thanks for your support.

Outlook-rhlbtl4m.png (498 Bytes)

Outlook-rhlbtl4m.png (498 Bytes)

(Attachment historyReport.json is missing)

We will publish our next official release (Aspose.Cells for .NET v21.11) in Downloads/Nuget repos. around the mid of November, 2021, so you may get the .NET5.0 Dll from the release.

Yes, it will be enough. If you need to manipulate PDF files then you may consider using Aspose.PDF.

4.5s, I guess, this is reasonable time. Also, we could not find your JSON file data, you probably forgot to attach the attachment or there is something wrong with the archive.

historyReport.zip (55 KB)

@Amjad_Sahi Thanks for your reply. The json file I sent to you bounced back because it’s not the supported file format for this forum. Then I sent you a zip file through my email client. Maybe that’s not the way to share the file in this forum. Here is the link to the file https://drive.google.com/file/d/1QUgrg2QOq4PIS79bAABjXxgb6XuJePXy/view?usp=sharing

Can you please give another try?

Please share some tips on how to make the PDF file saving faster.

I think groupdocs is also your product. Do you think groupdocs can be faster? Do you recommend us to try it?

@j2bmw,

I tried your new JSON file and it takes a few seconds (8-10) to complete the process on my end. I guess it is reasonable considering the 10000 or more records. We might not improve on it.

You can try it if it works in lessor time. By the way, Aspose APIs are also used in GroupDocs in the backend.