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.

Tue Nov 03, 2020 3:20 pm

Hi,

We are finding some issues while trying to set a water mark image on spire pdf using .net core. Here is the code to attach the water mark. The images are embedded as a resource in a DLL file. I have attached a sample PDF as a reference. The highlighted code seems to have some issue with dynamic height and width. We are using latest spire version 5.10.0.

We have a working code as a .net DLL with old spire version and now we are trying to convert that code to .net core


Stream wpWatermarkStream = null;
System.Drawing.Image wpWatermark = null;

wpWatermarkStream = GetImageStream(watermarkImage);
wpWatermark = GetImage(watermarkImage);
int imgWidth = wpWatermark.Size.Width;
int imgHeight = wpWatermark.Size.Height;
if (wpWatermark != null)
{
foreach (PdfPageBase loPage in loPDF.Pages)
{
loPage.BackgroundImage = wpWatermarkStream;
loPage.BackgroundRegion = new RectangleF(foatWatermarkPositionX, foatWatermarkPositionY, imgWidth, imgHeight);
}

}

private System.Drawing.Image GetImage(string image)
{
Assembly assembly = Assembly.GetExecutingAssembly();
System.Drawing.Image retImage = null;

foreach (var resourceName in assembly.GetManifestResourceNames())
{
if (!string.IsNullOrEmpty(resourceName) && resourceName.Contains(image))
{
using (var stream = assembly.GetManifestResourceStream(resourceName))
{
retImage = System.Drawing.Image.FromStream(stream, true);
break;
}
}
}
return retImage;
}

private Stream GetImageStream(string image)
{
Assembly assembly = Assembly.GetExecutingAssembly();
Stream streamImg = null;

foreach (var resourceName in assembly.GetManifestResourceNames())
{
if (!string.IsNullOrEmpty(resourceName) && resourceName.Contains(image))
{
streamImg = assembly.GetManifestResourceStream(resourceName);
}
}
return streamImg;
}


Regards,
Prashant

padalja2
 
Posts: 5
Joined: Mon Oct 12, 2020 4:41 pm

Wed Nov 04, 2020 9:34 am

Hello,

Thank you for your inquiry,
You mean you can't dynamically set the width and height of the background image? I tried setting different widths and heights for the background image but found that everything works fine. In order to help us further investigate, could you please provide us with your input files and a runnable project for reference? You could upload your project to the DropBox or OneDrive and then share the download link with us. Also, please tell us your OS information (e.g. Win7, 64bit) and region setting (e.g. China, Chinese). Thanks in advance.

Or if I misunderstood, please provide more detailed information to help us better understand your requirements, such as your desired output.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Wed Nov 04, 2020 11:55 am

Hello Brian,

We have uploaded the source code at https://drive.google.com/file/d/1T8xumpHvtTMMXceggOLec9ePvzEldaME/view?usp=sharing

Inside the zip you should Read Me - Steps.docx file which has steps to reproduce the problem. See the watermark image on the PDF file.

Regards,
Prashant

padalja2
 
Posts: 5
Joined: Mon Oct 12, 2020 4:41 pm

Thu Nov 05, 2020 11:58 am

hello,

Thanks for your sharing.
I tested your project and found that compared to your original image, the background image is stretched. This issue has been logged into our bug tracking system with the ticket SPIREPDF-3749. If there is any update, we will let you know.
Apologize for the inconvenience caused.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Tue Nov 10, 2020 10:39 am

Hello Brian,

Can someone please confirm about the probable time this issue may take to resolve. Is there any way we can see the updates on the ticket (SPIREPDF-3749) you have mentioned here.

Thanks in advance !

Regards,
Prashant

padalja2
 
Posts: 5
Joined: Mon Oct 12, 2020 4:41 pm

Wed Nov 11, 2020 6:24 am

Hello,

Thanks for your following up.
Sorry our bug tracking system is not available to customers. Our Dev team is now still fixing this issue due to its complexity, and we are unable to give you an estimated time at this moment.
Anyway, once there is any progress, we will notify you here immediately .

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Thu Nov 12, 2020 9:59 am

Hello,

Hope you are doing well.
Regarding the issue SPIREPDF-3749, I got news from our Dev team that the issue is very complicated, sorry, they need more time to find the solution. But there is another method to add image watermark in PDF document, as shown below. We have verified that this method works well, please give it a try on your end. Attached is the complete code for your reference.
Moreover, our Dev team will continue to work on the issue SPIREPDF-3749. Once it is resolved, we will inform you ASAP.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Thu Sep 29, 2022 4:42 am

Hii ,

Iam trying to covert PDF to Word document using Spire.PDF.
this is the code I have implemented.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PDFtoWORDfreeSpire
{
class Program
{
static void Main(string[] args)
{
pdftowordbyfreespire();
}
public static void pdftowordbyfreespire()
{
var doc = new Spire.Pdf.PdfDocument();
System.IO.FileInfo licenseFile = new System.IO.FileInfo(@"C:\Users\IT\Downloads\license.elic.xml");

Spire.License.LicenseProvider.SetLicenseFile(licenseFile);


doc.LoadFromFile(@"C:/Users/IT/Downloads/$1M_ComparisonDoc_28832.pdf");



doc.SaveToFile(@"C:/Users/IT/Downloads/1M_ComparisonDoc_28832byfreespire7865.docx", Spire.Pdf.FileFormat.DOCX);
System.Diagnostics.Process.Start(@"C:/Users/IT/Downloads/1M_ComparisonDoc_28832byfreespire7865.docx");

}
}
}

i had refrences Spire.Office latest version dll.

while converting PDF to word iam missing background color for some table headers. Please give a solution.

sateeshreddy992
 
Posts: 2
Joined: Tue Sep 27, 2022 6:36 am

Thu Sep 29, 2022 7:58 am

Hello,

Thanks for your inquiry.
I did reproduce the behavior you mentioned when testing with our latest Spire.Office version. I have logged this issue into our tracking system with the ticket SPIREPDF-5514. Our Dev team will do more investigations. Once there is any update, I will inform you asap. Sorry for the inconvenience caused.

Sincerely,
Simple
E-iceblue support team
User avatar

Simple.Li
 
Posts: 248
Joined: Fri Jul 01, 2022 2:33 am

Fri Dec 02, 2022 10:11 am

Hello,

Thanks for your patience!
Glad to inform you that we just released Spire.Office 7.12.0 which fixes the issue with SPIREPDF-5598.
Please download the new version from the following links to test.

Website download link: https://www.e-iceblue.com/Download/down ... t-now.html
Nuget download link: https://www.nuget.org/packages/Spire.Office/7.12.0

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Tue Nov 25, 2025 3:18 am

Hello padalja2,

Thank you for your patience.
We're pleased to inform you that the issue SPIREPDF-3749 has been fixed in the latest version Spire.PDF for .NET (v11.11.5). Please update and test with it.
Website link: https://www.e-iceblue.com/Download/download-pdf-for-net-now.html
NuGet link: https://www.nuget.org/packages/Spire.PDFfor.NETStandard/11.11.5
https://www.nuget.org/packages/Spire.PDF/11.11.5

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1510
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.PDF

cron