Telerik Forums
Telerik Document Processing Forum
9 answers
717 views

Is it possible to create an index page with bookmarks to various other pages.  For example

 

PDF TITLE

1. Background

2. Contents

3. Summary

 

Where click on 1 would go to Page 5, click on 2 would go to page 10, etc... ?

Martin
Telerik team
 answered on 22 Jul 2021
1 answer
662 views

Hi Team,

1.I want to load css file when import css file(bootstrap) and then export to a pdf file, but I find I lost all the css style, my code is below, did I miss something?

                    Telerik.Windows.Documents.Flow.FormatProviders.Html.HtmlFormatProvider htmlProvider
                        = new Telerik.Windows.Documents.Flow.FormatProviders.Html.HtmlFormatProvider();
                    // Create a document instance from the content. 
                    HtmlImportSettings importSettings = new HtmlImportSettings();
                    importSettings.LoadImageFromUri += (s, e) =>
                    {
                        // Load the data representing the resource  
                        SystemNet.WebClient webClient = new SystemNet.WebClient();
                        byte[] data = webClient.DownloadData(e.Uri);

                        // Pass the loaded data to the arguments 
                        string extension = SystemIO.Path.GetExtension(e.Uri).Substring(1); // Get the extension without the dot 
                        e.SetImageInfo(data, extension);
                    };
                    importSettings.LoadStyleSheetFromUri += (s, e) =>
                    {
                        string styles = fs.File.ReadAllText(Server.MapPath("~") + e.Uri);
                        e.SetStyleSheetContent(styles);
                    };
                    htmlProvider.ImportSettings = importSettings;
                    htmlProvider.ImportSettings.DefaultStyleSheet = string.Empty;
                    RadFlowDocument document = htmlProvider.Import(htmlStr);
                    Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider pdfProvider
                        = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
                    // Export the document. The different overloads enables you to export to a byte[] or to a Stream. 
                    byte[] pdfBytes = pdfProvider.Export(document);

2. Can I use the code like below to set the default style to empty?

                    htmlProvider.ImportSettings.DefaultStyleSheet = string.Empty;
 

'

 

 

Ivan Ivanov
Telerik team
 answered on 19 Jul 2021
1 answer
2.4K+ views

When writing an application to convert HTML documents to PDF documents on the server side, my HTML document gets resized and becomes weirdly formatted. The before and after conversion is depicted below. I believe its because the original HTML page is much larger than the resulting PDF, causing some formatting issues when it is squished. Is there a way I can resize the HTML page before it is added to the PDF so that this does not happen? Or does anyone have any ideas about what is causing this in the first place?

It is not a problem with importing the HTML file itself, as importing to HTML and exporting back to HTML leaves a near identical result.

Thank you for your help.

 

Dimitar
Telerik team
 answered on 30 Jun 2021
1 answer
456 views

This code creates a document with 3 tables of increasing height. However, when measured each has the same height. How can a table's height be measured in a way that will account for text that wraps onto multiple lines?

Thanks,

Tim

 

        protected void AddTable(string header, string text, RadFixedDocumentEditor editor)
        {
            Table table = new Table();
            RgbColor bordersColor = new RgbColor(149, 179, 215);
            Border border = new Border(1, Telerik.Windows.Documents.Fixed.Model.Editing.BorderStyle.Single, bordersColor);
            table.Borders = new TableBorders(border);
            table.DefaultCellProperties.Borders = new TableCellBorders(border, border, border, border);
            table.DefaultCellProperties.Padding = new Thickness(5);
            table.Margin = new Thickness(10);

            TableRow tableRow = table.Rows.AddTableRow();
            TableCell tableCell = tableRow.Cells.AddTableCell();
            tableCell.Borders = new TableCellBorders(new Border(BorderStyle.None));

            Block block = tableCell.Blocks.AddBlock();
            block.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;

            block.InsertText(header);

            tableRow = table.Rows.AddTableRow();
            tableCell = tableRow.Cells.AddTableCell();
            block = tableCell.Blocks.AddBlock();
            block.InsertText(text);

            double th = table.Measure().Height;
            editor.InsertTable(table);
            block = new Block();
            block.InsertText(th.ToString());
            editor.InsertBlock(block);
        }

        protected void btnTest_Click(object sender, EventArgs e)
        {
            RadFixedDocument radFixedDocument = new RadFixedDocument();
            using (RadFixedDocumentEditor editor = new RadFixedDocumentEditor(radFixedDocument))
            {
                AddTable("Table 1", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore", editor);

                AddTable("Table 2", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", editor);

                AddTable("Table 3", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", editor);
            }

            PdfFormatProvider pdfFormatProvider = new PdfFormatProvider();
            using (FileStream fileStream = File.Open(@"C:\Temp\Test.pdf", FileMode.Create))
            {
                pdfFormatProvider.Export(radFixedDocument, fileStream);
            }
        }

                
Dimitar
Telerik team
 answered on 23 Jun 2021
2 answers
384 views
As a continuation of this forum post (which seems to be archived):

https://www.telerik.com/forums/png-merge

All the given examples show how merging two images can be done in JavaScript.  I need this to happen in ASP.NET Core MVC 5.0.

I assume this will look something like how we marge PDF files.  I merge two PDF files like this:

            MemoryStream newStream = new MemoryStream();
            using (PdfStreamWriter fileWriter = new PdfStreamWriter(newStream, true))
            {
                using (PdfFileSource fileSource = new PdfFileSource(primaryStream))
                {
                    foreach (PdfPageSource pageSource in fileSource.Pages)
                    {
                        fileWriter.WritePage(pageSource);
                    }
                }

                using (PdfFileSource fileSource = new PdfFileSource(appendStream))
                {
                    foreach (PdfPageSource pageSource in fileSource.Pages)
                    {
                        fileWriter.WritePage(pageSource);
                    }
                }
            }


Joel
Top achievements
Rank 2
Iron
Iron
Iron
 answered on 17 Jun 2021
1 answer
120 views

I am attaching a simple sample app to show the problem.  I have an app that makes a catalog of images.  somewhere between 4000 and 4500 images, the docx is created, but I get an OutOfMemoryException when creating the pdf.  Also if the pdf is created, it is larger than the docx.  The docx was around 483MB.  

in the app load an image (one is provided), select number of images from spineditor and hit create catalog button and wait for the process to complete.  

1. why is pdf larger than docx

2. What to do about the OutofMemoryException.

I have clients that will have > 10,000 images.  

 

app if too large to attach (46MB)

 

temp link to dropbox is here:  https://www.dropbox.com/t/0gHCjVvo2gNNN3id

Martin
Telerik team
 answered on 16 Jun 2021
5 answers
533 views

I'm working with SpreadStreamProcessing. I want to set the background color for each of the cells in a specific row.

Created an excel mockup and like the "Blue, Accent 5, Lighter 40%". How can I find the RGB code for this?

Also is there somewhere one can find a color converter to RGB or visa versa?

Dimitar
Telerik team
 answered on 07 Jun 2021
1 answer
549 views

Hi team Telerik

Now, I using RadFixedDocument to export PDF include html,

sample

            row1TableCell.Borders = new TelerikEditting.Tables.TableCellBorders(tableBorder, tableBorder, tableBorder, tableBorder);
            Block row1TableCellBlock = row1TableCell.Blocks.AddBlock();
            row1TableCellBlock.InsertText("<a href="google.com" taget="_blank"> Click</a>");

Block can insert only text,

How can I insert html,
Please help me,
Thanks

 

Dimitar
Telerik team
 answered on 03 Jun 2021
1 answer
139 views

When I am on the Telerik site I request a trial of Document Processing.

It provides the Progress Trial Installer as the download.

Is the set of Products to Install, I cannot find Telerik Document Processing listed.  All the products listed are either UI tools or reporting tools. 

Confused about how to obtain a trial install of the Document processing libraries...

 

EDIT: Ok I found in the docs. 

The Telerik Document Processing libraries are available in .NET Standard and .NET Core compatible versions. You can download the assemblies of these libraries from the UI for XamarinUI for ASP.NET Core and UI for Blazor suites, respectively.

 

 

Martin
Telerik team
 answered on 17 May 2021
1 answer
187 views

Hi, I use RadFlowDocument to generate the PDF and some of the characters are not displayed,

i.e. Âge is displayed as ge; no matter which font I choose.

How can I setup the RadPdfDocument to make this work?

 

Regards

Martin
Telerik team
 answered on 12 May 2021
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?