Giter Club home page Giter Club logo

Comments (15)

ThomasHoevel avatar ThomasHoevel commented on August 16, 2024

How do you define "does not work"?

The source code 6.0.0 can be compiled against .NET 8 and works fine as far as we tested it.

from pdfsharp.

MarianoJP avatar MarianoJP commented on August 16, 2024

My apologies. I am using the Nuget Package in Visual Studio and when I attempt to load it, it tells me that it cannot be used with .net 8.0.

Error NU1202 Package PDFsharp-MigraDoc-GDI 6.0.0 is not compatible with net8.0 (.NETCoreApp,Version=v8.0). Package PDFsharp-MigraDoc-GDI 6.0.0 supports: net6.0-windows7.0 (.NETCoreApp,Version=v6.0)

I can download the code and use it as a reference.

Thanks.

P.D. I have modified from the older 1.50 version samples a function that will create an image of the first page of the pdf to use as a thumbnail/preview of the document that will be stored in my Blazor app. Below is the function.

public static Image CreatePerview(PdfDocumentRenderer pdfr) { PageInfo pageInfo = pdfr.DocumentRenderer.FormattedDocument.GetPageInfo(1); PdfDocument pdfDoc = pdfr.PdfDocument; PdfPage pdfPage = pdfDoc.Pages[0]; int dpi = 300; int dx, dy; if (pageInfo.Orientation == PdfSharp.PageOrientation.Portrait) { dx = (int)(pageInfo.Width.Inch * dpi); dy = (int)(pageInfo.Height.Inch * dpi); } else { dx = (int)(pageInfo.Height.Inch * dpi); dy = (int)(pageInfo.Width.Inch * dpi); } System.Drawing.Image image = new Bitmap(dx, dy, PixelFormat.Format32bppRgb); Graphics graphics = Graphics.FromImage(image); graphics.Clear(System.Drawing.Color.White); float scale = dpi / 72f; graphics.ScaleTransform(scale, scale); XGraphics gfx = XGraphics.FromGraphics(graphics, new XSize(pageInfo.Width.Point, pageInfo.Height.Point)); pdfr.DocumentRenderer.RenderPage(gfx, 1); gfx.Dispose(); return image; }

from pdfsharp.

TH-Soft avatar TH-Soft commented on August 16, 2024

Have you tried using "net8.0-windows7.0" instead of "net8.0".
The GDI build requires Windows.

Use the Core build for "net8.0", I think this will work. But the sample code you are showing requires GDI and will not work with the Core build.

from pdfsharp.

MarianoJP avatar MarianoJP commented on August 16, 2024

That is correct. I need to use the GDI in order to build the image preview, but the GDI Nuget Package does not work with net8.0.

from pdfsharp.

MarianoJP avatar MarianoJP commented on August 16, 2024

Or using the Core, how would I render the PDF page to an image in memory? I tried using the XImage but it resulted in an empty png file.

from pdfsharp.

TH-Soft avatar TH-Soft commented on August 16, 2024

Have you tried with "net8.0-windows7.0"?

The GDI package cannot be used with "net6.0" either because it requires "net6.0-windows7.0".

from pdfsharp.

MarianoJP avatar MarianoJP commented on August 16, 2024

I have used the Core with net 8 and it works. I can create pdf files and save them. I want to use the GDI in net 8 to create the image preview. I have tried doing it with an XImage in Core, but I get only a blank PNG.

from pdfsharp.

TH-Soft avatar TH-Soft commented on August 16, 2024

Have you tried using the GDI build with "net8.0-windows7.0"?

from pdfsharp.

MarianoJP avatar MarianoJP commented on August 16, 2024

I cannot find a NuGet Package for PdfSharp-MigraDoc-GID for "net8.0-windows7.0" in NuGet Gallery or from within Visual Studio. Has it been published?

from pdfsharp.

TH-Soft avatar TH-Soft commented on August 16, 2024

Have you tried using the GDI build compiled for "net6.0-windows7.0" with a Blazor project that targets "net8.0-windows7.0"?

The GDI package cannot be used if the Blazor project targets "net8.0" without "-windows7.0" and the error you are showing above will occur.

from pdfsharp.

MarianoJP avatar MarianoJP commented on August 16, 2024

from pdfsharp.

ThomasHoevel avatar ThomasHoevel commented on August 16, 2024

As I understand it, the packages that target "net6.0-windows7.0" should also work with projects that target "net8.0-windows7.0".

There is no NuGet package that targets "net8.0-windows7.0", but you can download the source code, change the target frameworks, and create such NuGet packages yourself.

from pdfsharp.

MarianoJP avatar MarianoJP commented on August 16, 2024

from pdfsharp.

ThomasHoevel avatar ThomasHoevel commented on August 16, 2024

OK, I took the MigraDoc sample console application, changed the target to "net8.0-windows", compiled it, started it, got a PDF.
As far as I can tell, it works as expected.

How do you define "does not work"?

from pdfsharp.

MarianoJP avatar MarianoJP commented on August 16, 2024

from pdfsharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.