9 Answers, 1 is accepted
About the grayscale conversion - you may import the PDF file and iterate its content by changing the colors to gray. I am attaching a sample project showing how to import PDF file with colors, change the colors of the Path, TextFragment and Image instances and finally view the modified file.
As for the compression - when you import and then export some existing PDF file with RadPdfProcessing the exported file is always compressed the best way RadPdfProcessing can. So if the original file has uncompressed content RadPdfProcessing will compress it on export. The only property that allows you to change the default RadPdfProcessing compression is PdfExportSettings ImageQuality property. Using this property you may export images in the PDF file with better compression at the expense of image quality.
I hope this is helpful. If you have any other questions or concerns please do not hesitate to contact us again.
Regards,
Deyan
Telerik by Progress
Hi
Is there a way using pdf processing to list images inside a pdf document and get the type/size of each one ? Just to block certain pdfs that do not fit in our needs ( huge sizes ). I already coded (using another library) an utility that calculates the ratio Kb/page. We could use that to block if they are bigger than what we think is reasonable but it would be better if we could point an image that has an excessive size.
Thanks
static void Main()
{
PdfFormatProvider provider = new PdfFormatProvider();
PdfExportSettings settings = new PdfExportSettings();
settings.ImageQuality = ImageQuality.Low;
using (Stream stream = File.OpenRead("d:\\sample.pdf"))
{
RadFixedDocument document = provider.Import(stream);
provider.ExportSettings = settings;
Stream saida = File.Create("d:\\output.pdf");
provider.Export(document,saida);
}
}
"As for the compression - when you import and then export some existing PDF file with RadPdfProcessing the exported file is always compressed the best way RadPdfProcessing can. So if the original file has uncompressed content RadPdfProcessing will compress it on export. The only property that allows you to change the default RadPdfProcessing compression is PdfExportSettings ImageQuality property. Using this property you may export images in the PDF file with better compression at the expense of image quality."
I tried the code above but unfortunately the size remained the same
You can iterate the content elements in the pages and check the properties of the ImageSource for the Images, for example:
foreach
(var page
in
this
.pdfDocument.Pages)
{
foreach
(ContentElementBase contentElement
in
page.Content)
{
var image = contentElement
as
Telerik.Windows.Documents.Fixed.Model.Objects.Image;
if
(image !=
null
)
{
var width = image.ImageSource.Width;
var byteSize = image.ImageSource.GetEncodedImageData().Data.Length;
var filters = image.ImageSource.GetEncodedImageData().Filters;
}
}
}
To the ImageQuality property - it would only affect the quality of the newly created images, the images imported from the PDF document will be left intact. This was not so clear in the ImageQuality documentation article, but I'll make sure to fix this.
Regards,
Boby
Progress Telerik
Hey Deyan,
I tried to run the sample project but its missing few ddl's like
Telerik.Windows.Documents.Core
Telerik.Windows.Documents.Fixed
Telerik.Windows.Zip
Can you please guide from where i can get this dll's ?
The size of the exported file pretty much depends on the content that is inside the document. With that said, I am afraid that I cannot say what might be causing the increase of the file size without testing a particular document. If you would like, you could open a support ticket and share an example document so we can provide you with a more appropriate answer.
Regards,
Tanya
Progress Telerik