Telerik Forums
Telerik Document Processing Forum
10 answers
1.7K+ views

Hi,

Is there any way to convert/rasterize an existing PDF file to JPG file(s) using PDFProcessing library?

Regards

Blas

JeffSM
Top achievements
Rank 2
Iron
Veteran
Iron
 answered on 16 Feb 2022
1 answer
1.2K+ views

As explained in https://www.telerik.com/forums/size-of-pdf-document

RadPdfProcessing does not embed the whole font but instead embeds only the font subset of the used characters which guarantees minimum font size

 

I want to use a docx as a template for PDF,  so from your sample github https://github.com/telerik/document-processing-sdk/tree/master/WordsProcessing/ContentControls

I use Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider.ExportToFixedDocument to create a RadFixedDocument

then use Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider to export to final PDF.

The problem is the docx is using non standard font, so when I embed the font set (normal, italic, bold, italic bold) the final PDF size reached 3MB with just simple text and no image. This PDF is definitely embedding the full font sets, not the subset.

Is this scenario unsupported or bug?

 

I modified your DocumentGenerator.cs in ContentControls_NetStandard project. Must copy the segoeui.ttf and seguili.ttf to the SampleData folder.


 //overwrite this
        private void Save(RadFlowDocument document)
        {
            IFormatProvider<RadFlowDocument> formatProvider = new DocxFormatProvider();

            string path = "CVTemplate.docx";
            using (FileStream stream = File.OpenWrite(path))
            {
                formatProvider.Export(document, stream);
            }

            Console.WriteLine("Document generated.");

            ProcessStartInfo psi = new ProcessStartInfo()
            {
                FileName = path,
                UseShellExecute = true
            };

            Process.Start(psi);

            //modification
            ExportToFixedDocumentPdfFromRadFlowDocumentDocx(document);
        }

        private void ExportToFixedDocumentPdfFromRadFlowDocumentDocx(RadFlowDocument document)
        {
            //handle png image for NetStandard
            Telerik.Windows.Documents.Extensibility.JpegImageConverterBase jpegImageConverter = new Telerik.Documents.ImageUtils.JpegImageConverter();
            Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.JpegImageConverter = jpegImageConverter;

            using (FileStream stream = File.Create("ExportedToFixedDocumentPdfFromRadFlow_with_embeddedFont.pdf"))
            {
                // Read the font file -- copy these 2 ttf to sample folder
                byte[] fontDataNormal = File.ReadAllBytes($"{SampleDataFolder}segoeui.ttf");
                byte[] fontDataLight = File.ReadAllBytes($"{SampleDataFolder}seguili.ttf");

                // Register the font set 
                Telerik.Documents.Core.Fonts.FontFamily fontFamily = new Telerik.Documents.Core.Fonts.FontFamily("Segoe UI");
                Telerik.Documents.Core.Fonts.FontFamily fontFamily2 = new Telerik.Documents.Core.Fonts.FontFamily("Segoe UI Light");

                Telerik.Windows.Documents.Fixed.Model.Fonts.FontsRepository.RegisterFont(
                    fontFamily,
                    Telerik.Documents.Core.Fonts.FontStyles.Normal,
                    Telerik.Documents.Core.Fonts.FontWeights.Normal, fontDataNormal);
                Telerik.Windows.Documents.Fixed.Model.Fonts.FontsRepository.RegisterFont(
                    fontFamily2,
                    Telerik.Documents.Core.Fonts.FontStyles.Normal,
                    Telerik.Documents.Core.Fonts.FontWeights.Normal, fontDataLight);

                //export the docx RadFlowDocument to RadFixedDocument
                var radFixedDocument = (new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider()).ExportToFixedDocument(document);

                var fixedFormatProvider = new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider();
                fixedFormatProvider.Export(radFixedDocument, stream);
            }
        }

 

 

 

 

 

Martin
Telerik team
 answered on 15 Feb 2022
4 answers
250 views

Hello,

I have the following code that loads a PDF :

byte[] file = File.ReadAllBytes(@"c:\big.pdf");
RadFixedDocument doc = null;
var prov = new PdfFormatProvider();
using (var input = new MemoryStream())
{
   input.Write(file, 0, file.Length);
   doc = prov.Import(input);
}

 

On import I am getting the following exception :

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

 

I attached the pdf used to this. Could you please let me know what the problem is? (Telerik version used is 2017.1.116.40)

Thank you.

Eric
Top achievements
Rank 1
Iron
 answered on 11 Feb 2022
1 answer
202 views
Hi,

We are creating a document with multiple tables using RadFlowDocument and exporting to byte array through DocxFormatProvider. Later converting to PDF document.

We are facing the problem to set the width of the table to align with complete document. Please refer the attached DocxFormatProvider_Export_toBytes.pdf which is having the tables(consider from second table) with right side space is left out.

The same is working fine when we export the RadFlowDocument to byte array through PdfFormatProvider (PDFFormatProvider_Export_toBytes.pdf).  The attached PDF documents are created through below code. 

----- Code -----

RadFlowDocument Targetdoc = new RadFlowDocument();

//Added Contents to Targetdoc 

DocxFormatProvider rfDocxProvider = new DocxFormatProvider();
byte[] docxoutput = rfDocxProvider.Export(Targetdoc);

var rPdfProvider = new PdfFormatProvider();
byte[] pdfoutput = rPdfProvider.Export(Targetdoc);

//PDF Files created

Version: 2021.1.322

We need to export from DocxFormatProvider only as we need to repeat the table header row for next pages.
Please help us to resolve table width issue.
Dimitar
Telerik team
 answered on 09 Feb 2022
1 answer
456 views

Hi All,

I'm new to Telerik. This is the first time I'm working on Telerik.

What I need to achieve is to populate a report as a pdf.

To get the report content, I will query the database,  get all the necessary fields and add them to radFlowDocument Table.

I Need to Add images as header and Footer too.

The content is generated dynamically. I'm not saving it anywhere.

Im using webforms.

Please guide me with your valuable comments.

 

Dimitar
Telerik team
 answered on 01 Feb 2022
0 answers
83 views

Hi,

empty asp net core project

when trying to export a empty file (code from examples) and always get the error:

"Index and count must refer to a location within the string (Parameter 'count')" (see on screenshot)

 

(the export logic is bound to the "Privacy" route in the "Home" controller)

windows 7, visual studio 2022, telerik asp net core 2021.3.1109

project attachet

 

alex
Top achievements
Rank 2
Iron
 updated question on 28 Jan 2022
1 answer
141 views

Hi,

I'm using the Telerik spreadsheet component to open an excel file embedded in a Winforms page.

I notice that dependent dropdowns do not work anymore, they show as empty.

What's the best way to have a dependent dropdown shown with Telerik?

I've tried multiple methods like https://www.contextures.com/xldataval02.html or with Index/Match combination in the Data Validation, all work directly in Excel .. but once opened in the embedded page with Telerik these dependent dropdowns  don't work anymore and show as empty.

I notice the named ranges dissappear once opened with the component.

Any advice / suggestions on this?

Thx in advance!

Svilen
Telerik team
 answered on 26 Jan 2022
1 answer
391 views
Hi,

We are creating a document with multiple tables using RadFlowDocument and exporting to PDF format through PdfFormatProvider. 

We are facing the problem to repeat the table heading row in every page in which corresponding table contents got added. We had set the RepeatOnEveryPage property of the header row, but it’s not working.

Version: 2021.1.322

Please help us to resolve this.
Tanya
Telerik team
 answered on 25 Jan 2022
1 answer
104 views
I am using the telerik document format providers to read an RTF and convert it to a DOCX format. the document contains embedded images in PNG format, but looking at the output of the DOCX it looks like the images have been converted to WMF format. Is there a way to preserve the original image type?
Dimitar
Telerik team
 answered on 20 Jan 2022
1 answer
688 views

Hey there,

I have tried to use RadFixedDocumentEditor in order to have a continuous flow on the document. Before that, I was using FixedContentEditor and changing the position of the elements with the FixedContentEditor:

Ex: pageEditor.Position.Translate(351, 915) -- where pageEditor is FixedContentEditor instance which takes 2 arguments: offSetX and offSetY.

However, I can't seem to figure out how should I change the position of the elements (blocks, tables etc) when using RadFixedDocumentEditor?

Any advice would be much appreciated.

Thanks ever so much


Dimitar
Telerik team
 answered on 20 Jan 2022
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?