13 Answers, 1 is accepted
You should be aware that currently, RadPdfViewer has an implementation of the CCITTFaxDecoder (that opens tiff images). We are using a third party Tiff decoder in order to decode the bytes. However there are some limitations in it and not all the features that PDF supports are implemented in this decoder. Unfortunately, we could not find a lot of information and good specification how to implement this filter better.
When it comes to creating a custom decoder for tiff images, you can do so by implementing the IPdfFilter interface and registering the new class by calling FiltersManager.RegisterFilter () method. RadPdfViewer uses the the Name property in order to recognize the filter. It must return one of following values:
If you register a PDF filter, it will override the default one.
Greetings,
Kammen
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
I just stumbled upon this thread and got really excited about the fact that the RadPdfViewer can show TIF-files. Though, I don't really understand how you're supposed to do to achieve this.
I'm quite new when it comes to these document files programatically.
Could you perhaps give me an example on how you guys implement this IPdfFilter and use it?
I just tried to do following code but the filter doesn't seem to run it's code at all i.e. no exception is thrown.
public partial class DocumentView : UserControl
{
private PDFAndTiffFilter _filter;
public DocumentView()
{
_filter = new PDFAndTiffFilter();
FiltersManager.RegisterFilter(_filter);
InitializeComponent();
}
}
public class PDFAndTiffFilter : IPdfFilter
{
public byte[] Encode(PdfObject encodedObject, byte[] inputData)
{
throw new NotImplementedException();
}
public byte[] Decode(PdfObject decodedObject, byte[] inputData, DecodeParameters parms)
{
throw new NotImplementedException();
}
public string Name { get { return "CCITTFaxDecode"; } }
}
Am I missing something?
Cheers!
A possible reason why you are not seeing the exception is that it is handled internally in order to prevent a crash.
However, if you've tried debugging and your project never entered the Decode method, this is most likely due to the fact that the file you are opening does not need the CCITTFaxDecode filter in order to be shown. You can verify the latter by clicking the two buttons in the sample I am attaching.
As for an actual implementation of the filter - unfortunately, we do not have such. My sample only shows how to plug a custom filter, but the filter itself is up to you to implement. You should be aware that this is not a trivial task.
Regards,
Petya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
I am using IPdfFilter to create a Filter for JBIG2Decode, most of our PDF documents contain this type of image.
My question is:
When creating the custom filter for JBIG2Decode what is PDFViewer expecting to be returned in the byte array.
A different Byte [] of a simplar image? (e.g. jpg or png)
Just the decoded Byte[]?
Thank you.
As it is described in our online help, the result that custom filter should return depends on the type of the filter. For the binary filters it is enough to decode the byte array into a decoded byte array using the respective algorithm. As for the filters listed in the article, additional transformation is required.
RadPdfViewer expects these filters to return data that depends on the decoded object's color space and bits per component (there are such properties in the decodedObject). The resulting byte array should contain exactly BitsPerComponent bits for each color component in the color space.
I hope this makes things clear!
Kammen
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
I have a 3rd party GDPicture I use for converting PDFs, but I haven't found out how to decode yet. I think it's possible, but I'm still trying to figure out how. I haven't found any decode methods yet. Converting from 1 document type to another is different than what the telerik viewer wants. If you were converting from 1 format to another it would take too long anyway. This isn't super high on my priority list, but I'll post a reply if I find anything out.
We are not quite sure we properly understand what you are saying. Filters in PDF format are used to decode data from the PDF document. Different filters are used for different types of data. More information about filters can be found in the PDF format specification, 3.3 Filters.
Regards,
Kammen
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
I'm a little confused with the Encoder. I downloaded the sample code attached to this thread. Run the code and use my pdf file with tiff images embedded on it. The pdf document displayed perfectly, now I implement my the class to my own project and tested it. The same pdf file loads on the RadPDFViewer control but doesnt show the tiff files. Just the pdf files with some text inside the file, it doesn't show the tiff embedded on the file.
Im guessis that this is related to the fact that when I view my pdf, i download it as a blob file then stream it to the pdf viewer. Also, the decode method on the class PDFAndTiffFilter does not fire.
Any help would be appreciated.
Regards,
Erc
The sample project demonstrates how to implement the IPdfFilter interface, it is not meant to open tiff files. The decode method of the class will be executed only when the document contains tiff files. If this method is not executed, then your document does not require CCITTFaxDecode.
I hope this helps. Please, get back to us if you need further assistance.
Alexander
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
The thing is, with the sample code. I run it and use my .pdf file with Tiff embedded on it. Then, why i tried to apply the class to my project and use the same pdf file. The PdfViewer loads and shows the document but without the tiff files. just blank white pages with the text from the document, no images.
Any ideas?
Regards,
Eric
The tiff files are not being displayed, because the sample project only demonstrates how to implement a custom decoder, it is not actually implementing one. It is up to you to implement the Encode and Decode methods of the IPdfFilter interface.
Regards,
Alexander
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>