Comments (15)
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.
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.
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.
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.
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.
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.
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.
Have you tried using the GDI build with "net8.0-windows7.0"?
from pdfsharp.
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.
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.
from pdfsharp.
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.
from pdfsharp.
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.
from pdfsharp.
Related Issues (20)
- unable to check if a PdfDocument has an AcroForm inside
- cannot open pdf created by PdfSharp HOT 7
- .NET 6 end of support is November 12, 2024 HOT 5
- MigraDoc: Support different margins for first page in PageSetup HOT 3
- incorrect image path concatenation under Linux HOT 1
- MigraDoc: LeftPadding seems to be negated when drawing Table HOT 3
- BeginContainer crashes when XGraphics was created from a pdf page
- how to extract data from this kine of pdf? HOT 3
- Query for PDFsharp v1.50 beta 5 (ECCN) HOT 1
- How to split page into multiple columns like MS WORD in MigraDoc? HOT 2
- DrawImage draws allways the same (first) image HOT 21
- Wrong page number when reading a simple pdf HOT 6
- Document links don't work with Adobe Acrobat on startup HOT 1
- AddDocumentLink incompatible with named destinations generated by Chrome PDF printer when opened in Acrobat/macOS/iOS HOT 1
- How to convert pdf page to image
- Does anyone know how to remove image from a PDF? HOT 2
- When I reference PdfSharp, why is a directory named de created in the output directory? HOT 7
- Working with coordinates HOT 1
- Corrupted File Error HOT 4
- Deleted page not "really" deleted HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pdfsharp.