PDFSharp | NET Standard 2.0 library | Document Editor library
kandi X-RAY | PDFSharp Summary
kandi X-RAY | PDFSharp Summary
A .NET Standard 2.0 library for reading, writing and editing PDF files. DISCLAIMER: This is a modified fork based on several OSS projects. For more information see Licenses or LICENSE.md.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of PDFSharp
PDFSharp Key Features
PDFSharp Examples and Code Snippets
Community Discussions
Trending Discussions on PDFSharp
QUESTION
Until recently I have been stuck on how to achieve the goal of "exporting" a report from a StackLayout into a PDF in a project I somehow pulled out of Dev Limbo.
--BackStory--
Previously I have tried to continue the use of the already placed (in the project) PDFSharp package to convert the data presented in the XAML to a PDF for a client. Long story short, I was unable to get PDFSharp to do what I needed it to do and turned to Syncfusion. They seemed to have the features I needed to make this happen. Going based off the code samples they had, I was able to get close to my goal, but not quite. They have the capture portion and they have the pagination portion, but not a combination of the two. I essentially needed to paginate the screenshot that CaptureAsync() saves to make a pdf of the entire report.
...ANSWER
Answered 2021-Jun-01 at 19:51--How was this resolved?--
After doing some digging, I came across an answer in this article (I am forever grateful) and forged a solution using it.
Here's a sample of my XAML content page for context:
QUESTION
I'm using TheArtOfDev's HtmlRenderer.PdfSharp to convert an HTML string to PDF in a ASP.NET web application. The HTML contains Japanese characters. The Japanese symbols are converted to ☐ ascii characters.
How can I enable UTF-8 or use a custom Japanese font? I tried the following without results:
- Adding
to the HTML string.
- Adding
to the HTML string and then settings the font style on the element with Japanese text.
- Try a CSS file with
@font-face
and callingTheArtOfDev.HtmlRenderer.PdfSharp.PdfGenerator.ParseStyleSheet
ANSWER
Answered 2021-Jan-26 at 04:23I gave up on HTMLRenderer and PDFSharp and solved all my issues with TuesPechkin, a wrapper for wkhtmltopdf.
QUESTION
When filling a pdf document with pdfsharp (pdfsharpcore), the filled form doesn't show the values in the acrobat reader unless the fields are clicked on.
...ANSWER
Answered 2021-Feb-16 at 15:24In order to make the values visible, I've inserted.
QUESTION
How can I convert a byte[]
of an Office document (.doc, .docx, .xlsx, .pptx) to a byte[]
of a PDF document assuming Office is installed and Microsoft.Office.Interop
is used?
I fetch the files' byteArray from the database as well as their name. I would like to first convert each file to a PDF and then combine all of the PDFs to one single PDF using PDFSharp (this part is already implemented).
Code:
...ANSWER
Answered 2021-Feb-16 at 12:10If you check the documentation for Documents.Open there is no mentioning of opening a document directly from a stream. This is unfortunately an all to common problem in libraries. But there might be other libraries you could use that allow this.
I would not expect saving to a file to be a major performance issue since the conversion will probably be the dominating factor. But it might cause permission issues if your program is running in a very restrictive environment.
If you are keeping the file save method you should add some exception handling to ensure the temporary files are deleted even if an exception occurs. I have also seen issues where external programs release the file locks after some time, so it might be useful to try to delete the file multiple times.
QUESTION
I want to convert a jpg to a pdf. After some research, I found that you can do this using PdfSharp, and since I'm using C# .Net 5.0, I Nugot PdfSharpCore 1.2.11.
After some research I come up with the following code:
...ANSWER
Answered 2021-Feb-13 at 12:38XImage.FromFile(inputFilePath)
specifies the default quality level of 75.
If instead you call ImageSource.FromFile
(passing in the quality level) then
XImage.FromImageSource
then you can increase the quality level.
The image is unlikely to look exactly the same - but bumping it up to 85 or 90 will likely improve its rendering.
QUESTION
In my quest to learn ASP.net core I've created a simple CRUD application using asp.net core 3.1. I want to print my Details page as a Invoice. I have looked around and it seems like printing PDF in full .Net Framework was more available.
Can anyone point me in the right direction? I have come across free libraries like SelectPDF, WKHTMLTOPDF, PDFSharp but quiet frankly the samples are pre- asp.net core and cannot quiet integrate it with asp.net core Razor Pages. Actually, if I'm not mistaken some of the libraries mentioned above are not compatible with Razor Pages Core.
...ANSWER
Answered 2021-Jan-25 at 08:36I have come across free libraries like SelectPDF, WKHTMLTOPDF, PDFSharp but quiet frankly the samples are pre- asp.net core and cannot quiet integrate it with asp.net core Razor Pages.
I suggest that you could use client side library.Because what you metioned are all server side libraries,they all need to find the view and convert to string.As far as I known,it seems no such direct method to convert razor pages to string.So I suggest that you could use jsPDF
library.
Here is a whole working demo:
QUESTION
I want to fill an existing PDF file in my web application (developed in ASP.NET MVC 5). The PDF file has a field named "Text1". In this field I want to write the value "abc". I am currently trying to use PdfSharp for this purpose.
This is how I am currently trying to set a value in a field in the PDF:
...ANSWER
Answered 2021-Jan-16 at 07:01You have to use PdfString
from PDFSharp library like this document.AcroForm.Elements.SetValue("/FieldName", new PdfString("yourstring"));
You also need this if you are attempting to populate PDF form fields, you also need to set the NeedsAppearances element to true. Otherwise, the PDF will "hide" the values on the form.
QUESTION
As the title says, I want to consume all of PDFSharp's source code into my own project. But let me explain why I came to this scenario, so if there is something else I can do, maybe there are other options.
Goal: Compile my project into a single .exe file to use. No installers. Problem: It uses PDFSharp.dll which is causing me issues.
What I am trying to do, is use ILMerge to create the .exe. I've used this successfully in the past for other projects.
The issue I think is that ILMerge is requiring references to other assemblies that PDFSharp uses. The first being Microsoft.ApplicationInsights. So to by-pass this, I installed Microsoft.ApplicationInsights into my project via Nuget. Then removed the actual reference from the project, but referenced the library in my ILMerge command as below:
...ANSWER
Answered 2021-Jan-12 at 21:38I have this working now, so I just wanted to place my results here since it is already posted.
My initial problem was that I mistakenly thought the PDFSharp.dll was causing the issue, but it was actually another group of 3rd Party dlls I was referencing.
I tried for hours to get iLMerge to work with the only success being it would kick out a single .exe file but it would have runtime errors.
Errors that I encountered:
Error: Unresolved assembly reference not allowed: Custom.Assembly.
Solution: Reference the assembly if possible. If you have many, you can reference a folder with the /lib:"C:\folderpath" switch.
Error: Unresolved assembly reference not allowed: ADotNetFramework.dll.
Solution: You can reference the desired .Net Framework path where iLMerge will search for missing references. Example: /targetplatform:"v4,C:.NETFramework\v4.8"
Error: The assembly 'xyz.dll' was not merged in correctly. It is still listed as an external reference in the target assembly.
Solution: You can get past this error with the /closed switch. However, I don't think I should even have gotten this error because 'xyz.dll' was a referenced dll to be combined.
Also - use the /log switch, it is extremely helpful in seeing exactly what iLMerge is doing and figuring out your issue. Example: /log:mylog.txt
This allowed me to see that iLMerge was finding duplicate namespaces, in the 3rd Party assemblies and automatically renaming them. Here is an example from my log:
Merging assembly 'My.Assembly.Name' into target assembly. Duplicate type name: modifying name of the type '<>f__AnonymousType0
2' (from assembly 'My.Assembly.Name') to 'My.Assembly.Name.<>f__AnonymousType0
2' Duplicate type name: modifying name of the type '<>f__AnonymousType12' (from assembly 'My.Assembly.Name') to 'My.Assembly.Name.<>f__AnonymousType1
2' Duplicate type name: modifying name of the type '' (from assembly 'My.Assembly.Name') to 'My.Assembly.Name.
Finally - the solution that I found was not to use iLMerge. I found this Answer: https://stackoverflow.com/a/40786196/2596309 which used Costura.Fody I installed the nuget package with:
QUESTION
I have several pdf files. and I want to combine all of them in one which I can do using PDFSharp.
But I also want Table Of Contents at the top with DocumentLink.
Table of content is separately created using Migradoc which looks as below.
My question is is there any way in pdfsharp using which I can add Document link on the Document name like Document1, Document2 which redirects to respective pages.
...ANSWER
Answered 2021-Jan-07 at 07:54Mixing MigraDoc and PDFsharp you can get it done.
You can add a Tag
to the paragraphs that you want to link. While the created PDF and the MigraDoc document are still open, you can combine the PDFs and add the links. In PDFsharp you specify the rectangle you want to turn into a link. If you want a special look for the links, you have to set the look in MigraDoc already.
Finding the tagged paragraphs in the document to add the links is tricky and I don't have a sample at hand.
Here is code that adds the pages one by one:
https://forum.pdfsharp.net/viewtopic.php?f=8&t=3172
Add the links after adding each MigraDoc page with the table of contents.
See this post on the PDFsharp forum to get started:
https://forum.pdfsharp.net/viewtopic.php?p=9694#p9694
QUESTION
I currently build a PDF file with MigraDoc, I then render the document which creates a PdfDocument (PDFSharp) so I can ad external pages from other PDFs (because from my understanding MigraDoc does no have the "notion" of pages and thus cannot add external pages)
My current PDF file format is:
...ANSWER
Answered 2020-Dec-17 at 12:21MigraDoc can add pages from PDF files using AddImage
. You pass the desired page number (zero-based) after the filename - "test.pdf#5" will take the fifth page from that PDF file.
You can simply add a page break to a section, add the image, then add another page break. Images can be positioned at absolute positions, so they fill the whole page.
Automatic page breaks are added when rendering a document to PDF, but you can always add manual page breaks as needed.
If you use that approach then all pages will be created by MigraDoc and page numbers will work.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install PDFSharp
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page