empira / pdfsharp.samples Goto Github PK
View Code? Open in Web Editor NEWPDFsharp 6.0 and MigraDoc Foundation samples
Home Page: https://docs.pdfsharp.net/PDFsharp/Samples/About.html
License: Other
PDFsharp 6.0 and MigraDoc Foundation samples
Home Page: https://docs.pdfsharp.net/PDFsharp/Samples/About.html
License: Other
Hello,
I cannot find any example, how to read the Conformance level from document;
And I need example how to generate simple pdf/a1a "Hello world" document.
Can you guide me how to to that?
Hello, I'm trying to update my project to the Net6.0 version. It is going pretty well. I ran into in a couple of spots.
The lines in question:
document.DefaultPageSetup.Orientation = Orientation.Portrait;
document.DefaultPageSetup.BottomMargin = Unit.FromCentimeter(4);
The error:
'DefaultPageSetup must not be changed.'
Should my code be changed? Or is this a bug?
Hi,
I copied the code of hello world:
// See https://aka.ms/new-console-template for more information
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using System.Diagnostics;
// Create a new PDF document.
var document = new PdfDocument();
document.Info.Title = "Created with PDFsharp";
document.Info.Subject = "Just a simple Hello-World program.";
// Create an empty page in this document.
var page = document.AddPage();
// Get an XGraphics object for drawing on this page.
var gfx = XGraphics.FromPdfPage(page);
// Draw two lines with a red default pen.
var width = page.Width;
var height = page.Height;
gfx.DrawLine( XPens.Red, 0, 0, width, height );
gfx.DrawLine( XPens.Red, width, 0, 0, height );
// Draw a circle with a red pen which is 1.5 point thick.
var r = width / 5;
gfx.DrawEllipse( new XPen( XColors.Red, 1.5 ), XBrushes.White, new XRect( width / 2 - r, height / 2 - r, 2 * r, 2 * r ) );
// Create a font.
var font = new XFont("Times New Roman", 20, XFontStyleEx.BoldItalic);
// Draw the text.
gfx.DrawString( "Hello, PDFsharp!", font, XBrushes.Black,
new XRect( 0, 0, page.Width, page.Height ), XStringFormats.Center );
// Save the document...
var filename = "HelloWorld_tempfile.pdf";
document.Save( filename );
// ...and start a viewer.
Process.Start( new ProcessStartInfo( filename ) { UseShellExecute = true } );
and get
Exception thrown: 'System.InvalidOperationException' in PdfSharp.dll
An unhandled exception of type 'System.InvalidOperationException' occurred in PdfSharp.dll
No appropriate font found for family name "Times New Roman". Implement IFontResolver and assign to "GlobalFontSettings.FontResolver" to use fonts.
Is it normal?
When I try using my endpoint in the swagger, I can generate the PDF, But it's work just once.
If I try again, I get this error: "error": "You must not change font resolver after is was once used."
To get it working again, I need to run the application again in VisualStudio.
What do I need to do to resolve this?
As the title suggests.
-- deepl translator.
When trying to render the PDF, it's having issues with the founts.
pdfRenderer.RenderDocument();
Error:
'No appropriate font found for family name "Verdana".'
We have a define styles method. So it should be there to use.
private void DefineStyles()
{
// Get the predefined style Normal.
Style style = document.Styles["Normal"];
// Because all styles are derived from Normal, the next line changes the
// font of the whole document. Or, more exactly, it changes the font of
// all styles and paragraphs that do not redefine the font.
style.Font.Name = "Verdana";
style = document.Styles[StyleNames.Header];
style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right);
style = document.Styles[StyleNames.Footer];
style.ParagraphFormat.AddTabStop("8cm", TabAlignment.Center);
// Create a new style called Table based on style Normal
style = document.Styles.AddStyle("Table", "Normal");
style.Font.Name = "Verdana";
//style.Font.Name = "Times New Roman";
style.Font.Size = 10;
style.ParagraphFormat.SpaceBefore = "2mm";
style.ParagraphFormat.SpaceAfter = "2mm";
// Create a new style called Reference based on style Normal
style = document.Styles.AddStyle("Reference", "Normal");
style.ParagraphFormat.SpaceBefore = "5mm";
style.ParagraphFormat.SpaceAfter = "5mm";
style.ParagraphFormat.TabStops.AddTabStop("16cm", TabAlignment.Right);
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.