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.

Fri May 21, 2021 5:22 pm

Hi, i'm trying to put an imagem using Spire.PDF, on the top left corner, but it seems like I'm having some issues, even when i'm setting the location to 0,0, it wont go to the top of the page

infordoc
 
Posts: 2
Joined: Tue Sep 29, 2020 4:33 pm

Mon May 24, 2021 5:49 am

Hello,

Thanks for your inquiry and sorry for the late reply as weekend.
Please note that by default, the PDF created by our Spire.PDF has margins. Please set the page margin to 0 like the following code to achieve your needs.
Code: Select all
            PdfDocument doc = new PdfDocument();
            PdfPageBase page = doc.Pages.Add( new SizeF(), new PdfMargins(0,0,0,0));

If there are still any problems, please provide your complete test code and your expected results, then we will do further investigation.

Sincerely,
Brian
E-iceblue support team
User avatar

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

Mon May 24, 2021 1:08 pm

Here's my code

Code: Select all

PdfImage pdfImage = PdfImage.FromFile("QRCode.png");
            PdfDocument pdfDocument;
            PdfPageBase page;
            float width;
            float height;
            pdfDocument = new PdfDocument(filename);
            width = pdfImage.Width * 0.2f;
            height = pdfImage.Height * 0.2f;
            pdfDocument.Pages.Insert(1);
            page = pdfDocument.Pages[1];
            page.Canvas.DrawImage(pdfImage, 0, 0, width, height);
            pdfDocument.SaveToFile(filename);




And the QRCode.png is on the attach

infordoc
 
Posts: 2
Joined: Tue Sep 29, 2020 4:33 pm

Tue May 25, 2021 1:32 am

Hello,

Thanks for providing your test code.
Please refer to the following modified code to meet your needs. If there are still any issues, please provide us with your input file and your desired output for reference. Thanks in advance.
Code: Select all
            ...
            //pdfDocument.Pages.Insert(1);
            pdfDocument.Pages.Insert(1,new SizeF(),new PdfMargins(0,0,0,0));
            ...


Sincerely,
Brian
E-iceblue support team
User avatar

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

Tue Jun 01, 2021 10:07 am

Hello,

How is your issue now? Could you please give us some feedback at your convenience?

Sincerely,
Brian
E-iceblue support team
User avatar

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

Return to Spire.PDF