I am currently using GroupDocs.Viewer for .NET and have encountered an issue where certain PDF files are rendered with all pages completely black, even though the file size is not large and the PDFs open correctly in other viewers such as Adobe Acrobat.
Hi @prapapra
We’re sorry for such inconvenience, it seems that you have encountered a bug in the GroupDocs.Viewer. Please share the sample PDF file and a source code, so we can reproduce the same rendering options, as on your side.
Sorry for the inconvenience once again.
With best regards,
Denis Gvardionov
Hi @denisgvardionov ,
Thank you for your response.
I have attached a sample PDF file containing only the specific page(s) where the issue occurs.
Could you please review it and advise how to resolve this problem?
Regards,
prapapra
P18.pdf (463.3 KB)
@prapapra
Hi Prapas,
Thank you for sharing a file. I have successfully reproduced and confirm the issue with a “P18.pdf” file, this is a bug in the GroupDocs.Viewer for .NET, when rendering a file to HTML format, and I’ve already logged it for our developers under the “VIEWERNET-5378” ticket. We will notify you, when this bug will be fixed.
Sorry for the inconvenience. If this is acceptable for your purposes, you can temporarily render this file to the PNG and/or JPEG, in such case this PDF is rendered correctly.
With best regards,
Denis Gvardionov
I would like to follow up on the status of the issue logged under ticket “VIEWERNET-5378”. May I know if there has been any progress?
Regards,
Prapas
Hi @prapapra
The ticket “VIEWERNET-5378” is attached to this forum thread, so you will receive updates for sure. At this moment, unfortunately, there are no news: bug was reproduced, described, logged and assigned to the development team. When developers will fix it, we will notify you.
Thanks for the understanding.
With best regards,
Denis Gvardionov
Hi @denisgvardionov ,
While waiting for a proper solution, I’ll try rendering the PDF as jpeg as recommended.
However, I’m facing a challenge because my viewer handles mixed document types (Word, Excel, Email, etc.). Currently, all files are rendered using HtmlWithEmbeddedResources, but now I would like to render only PDF files as Viewtype.jpg, while keeping other file types rendered as HTML.
I’m using the code example from the following repository:
Could you kindly advise how to modify the logic so that:
– PDF files are rendered as Jpeg
– All other file types remain rendered as HtmlWithEmbeddedResources
Regards,
Prapas
Hi Prapas,
When assuming that you don’t know the format of the input document, which you should view using the using GroupDocs.Viewer (for example, the document was uploaded by the user or obtained from database as a byte array or a stream), this is quite easy to detect its format and apply an appropriate view options using the GroupDocs.Viewer for .NET, code example is below:
// 1. Obtain document content somewhere -
// just a stream without knowing what document type it is
Stream documentContent = new MemoryStream();
// 2. Prepare different options with different parameters
HtmlViewOptions htmlOpt = HtmlViewOptions.ForEmbeddedResources("embedded-page{0}.html");
JpgViewOptions jpegOpt = new JpgViewOptions("page{0}.jpeg");
// 3. initialize the Viewer instance
using (Viewer viewer = new Viewer(documentContent))
{
// 4. detect actual format of loaded document
GroupDocs.Viewer.Results.FileInfo format = viewer.GetFileInfo();
// 5. select the appropriate options according to the detected format
ViewOptions destinationOptions;
if (format.FileType == FileType.PDF)
{
destinationOptions = jpegOpt;
}
else
{
destinationOptions = htmlOpt;
}
// 6. View() the document
viewer.View(destinationOptions);
}
However, when talking in context of the ASP.NET Web Forms Demo project on GitHub — it is impossible, because the viewing options are specified in the Global.asax, which is called on the project startup, before the first document will be loaded. Viewing options are hard-coded once at the line #33 - by default the viewerType
variable has a ViewerType.HtmlWithEmbeddedResources
value. You can modify it by setting its value to Jpg
, but this will apply to all loaded documents. The ASP.NET Web Forms Demo is a complex wrapper around the “pure” GroupDocs.Viewer for .NET and it is just not intended to have such functionality with adjustable viewing (rendering) mode.
With best regards,
Denis Gvardionov