truthz03 wrote:
Hi,
until today I used PdfShard from this repository:
https://github.com/myvas/PdfSharpCore/t ... .0-beta5-3Today I found out that the official PdfSharp now also supports .Net6 and so I updated to the new 6.0.0 version.
After fixing some behaviour changed I can start and test everything but I miss a feature.
The repository from above has support to add pdf as image to a section.
I compared the source of the forked repo and the official repo and found the difference.
Code:
public static XImage FromStream(Stream stream)
{
if (stream == null)
throw new ArgumentNullException("stream");
if (PdfReader.TestPdfFile(stream) > 0) // This row is new
return new XPdfForm(stream); // This row is new
return new XImage(stream);
}
Is it possible to also add the check if the stream is a pdf and than return an XPdfForm instead of an XImage?
Without this check there will be an error inside the generated pdf wich says that the image has a wrong form
I don't want to use the forked repository anymore because the last changes where made some years ago.
It would be nice to be able to use the official repo.
Thanks
Ok, I now downloaded the source code from the Branch "Branch_v6.0.0" and the code looks totally different in comparison to the decompiled version of the Nuget "PDFsharp-MigraDoc (6.0.0)" from VisualStudio.
SourceCode of the Branch "Branch_v6.0.0":
Code:
public static XImage FromStream(Stream stream)
{
if (stream == null)
throw new ArgumentNullException(nameof(stream));
if (PdfReader.TestPdfFile(stream) > 0)
return new XPdfForm(stream);
return new XImage(stream);
}
Decompiled source code of the Nuget "PDFsharp-MigraDoc (6.0.0)":
Code:
public static XImage FromStream(Stream stream)
{
if (stream == null)
{
throw new ArgumentNullException("stream");
}
return new XImage(ImageImporter.GetImageImporter().ImportImage(stream) ?? throw new InvalidOperationException("Unsupported image format."))
{
_stream = stream
};
}
How is this possible????