Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed May 29, 2019 8:37 pm

I am working on creating a PDF file directly from the action result on click of a button in .NET core 2.0 . Any sample code is much appreciated!

anandhfeb89
 
Posts: 1
Joined: Wed May 29, 2019 8:24 pm

Thu May 30, 2019 4:01 am

Hi,

Thanks for your inquiry.
You could download our latest Spire.PDF from the following link. And note that the dlls for .Net Core is included in the .NET Standard 2.0 folder. Below sample code shows how to create a Pdf. In addition, you can refer to the tutorial Spire.PDF Program Guide Content for .NET on our website to better evaluate our Spire.Pdf. If there is any question, please feel free to write back.

Website link: Spire.PDF Pack(Hot Fix) Version:5.5.21
Nuget link: https://www.nuget.org/packages/Spire.PDF/5.5.21
Code: Select all
            PdfDocument pdf = new PdfDocument();
            PdfPageBase page = pdf.Pages.Add(PdfPageSize.A4);
            page.Canvas.DrawString("Hello World!", new PdfTrueTypeFont(new Font("Arial", 20f), true), PdfBrushes.Red, new Point(10, 15));
            pdf.SaveToFile("result.pdf", FileFormat.PDF);

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Mon Jun 03, 2019 3:56 am

Hi,

How is your issue now? Could you please give us some feedback at your convenience? Thanks in advance.

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Thu Mar 23, 2023 8:00 pm

How to implement the tool to Html to PDF in .Net Core?

jorgelux
 
Posts: 5
Joined: Thu Mar 23, 2023 7:58 pm

Fri Mar 24, 2023 9:42 am

Hi

Thank you for your message.
You can install Spire.PDF through NuGet for your . Net Core project, currently the latest version is Spire.PDF 9.3.4.Then you can refer to this tutorial (C #: Converting HTML to PDF) to convert your html to PDF. If you have any questions, please feel free to contact us.

Best Regards,
Hermann
E-commerce Support Team
User avatar

Herman.Yan
 
Posts: 115
Joined: Wed Mar 08, 2023 2:00 am

Fri Mar 24, 2023 8:03 pm

Hello Support , How to implement the property Display Header in Html to Pdf with plugin?

jorgelux
 
Posts: 5
Joined: Thu Mar 23, 2023 7:58 pm

Mon Mar 27, 2023 7:43 am

Hi,

Thank you for your message.
Kindly note that the plugin method uses third-party HtmlConverter.QT of the Chrome kernel, there is no direct way to add header when doing the conversion. However, you can refer to this tutorial (Add Header to Existing PDF in C#/VB.NET) to add the header on the converted PDF file. If you have any questions after the test, please share your input Html and desired output PDF file for further investigation. you can upload them here or provide to us by email (support@e-iceblue.com)

Best Regards,
Herman
E-iceblue support team
User avatar

Herman.Yan
 
Posts: 115
Joined: Wed Mar 08, 2023 2:00 am

Wed Mar 29, 2023 4:50 pm

Hello Support,
How can I know the measurements to adjust my pdf without margins using Html to pdf with plugin?

jorgelux
 
Posts: 5
Joined: Thu Mar 23, 2023 7:58 pm

Thu Mar 30, 2023 10:35 am

Hi,

Thanks for your message.
I checked your pdf document and found that there are no margins, as shown in the attached screenshot. What is your desired effect? Please provide us with your input Html document for further investigation, you can upload them here or provide to us by email (support@e-iceblue.com)

Best Regards,
Herman
E-iceblue support team
User avatar

Herman.Yan
 
Posts: 115
Joined: Wed Mar 08, 2023 2:00 am

Thu Mar 30, 2023 3:50 pm

hello, the desired effect for which I have not found a property is to adjust all the contents of the pdf almost completely on the left side, so you can see in the pdf that I send that the left side has a very large space between the information and the beginning from the sheet on the left side, could there be a setting in this code that I use to reduce that and make it look more proportional?
I share the code...

var memoryStream = new MemoryStream();
HtmlConverter.Convert(htmlDocument, memoryStream,
true, 100000, new SizeF(993,1133),
new Spire.Pdf.Graphics.PdfMargins(0,0),
LoadHtmlType.SourceCode);

jorgelux
 
Posts: 5
Joined: Thu Mar 23, 2023 7:58 pm

Thu Mar 30, 2023 3:51 pm

the desired effect is all at the root of the sheet so that not so much space is seen

jorgelux
 
Posts: 5
Joined: Thu Mar 23, 2023 7:58 pm

Fri Mar 31, 2023 10:45 am

Hi,

Thank you for your message.
When converting Html to PDF,there is no direct way to reduce the blank space part. However, you can refer to the following code to process the converted PDF file. The attachment is my testing result. If you have other questions, just feel free to write back.
Code: Select all
 PdfDocument doc = new PdfDocument();
 // Read a pdf file
 doc.LoadFromFile(@"ADM10-PANOVO ALIMENTARIA S DE RL de CV,Panovo -20_mar._23 (5).pdf");
 // Creates a new page
 PdfDocument newDoc = new PdfDocument();
 // Get page margins of source pdf page
 PdfMargins margins = doc.PageSettings.Margins;
 float top = margins.Left;
 float bottom = margins.Bottom;
 float left = margins.Left;
 float right = margins.Right;

 foreach (PdfPageBase page in doc.Pages)
 {
     // Adds a new page to the new document
     PdfPageBase newPage = newDoc.Pages.Add(new SizeF(page.Size.Width - left-50 - right, page.Size.Height - top - bottom), new PdfMargins(0));
     // Draws the content of the source page onto the new document page
     newPage.Canvas.DrawTemplate(page.CreateTemplate(), new PointF(-left-50, -top));
 }
 String result = @"out.pdf";
 //Save the document
 newDoc.SaveToFile(result);


Best Regards,
Herman
E-iceblue support team
User avatar

Herman.Yan
 
Posts: 115
Joined: Wed Mar 08, 2023 2:00 am

Return to Spire.PDF