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 Oct 26, 2018 3:43 pm

I am taking an image of a page and placing the image onto a into a new document page.

I create the new document with no margins
docImage = new PdfDocument();
docImage.PageSettings.Margins = new PdfMargins(0,0,0,0);

I save the page from the original doc image to disk.
Image image = originalDoc.SaveAsImage(x);
image.Save(sImageName);

I then load the image with PDFImage from disk

PdfImage pdfimage = PdfImage.FromFile(sImageName);
float fitWidth = pdfimage.PhysicalDimension.Width;
float fitHeight = pdfimage.PhysicalDimension.Height;

I create a new page based on the size of the originating document
PdfPageBase page = docImage.Pages.Add(originalDoc.Pages[x].Size);

Then draw the image on the new page.
page.Canvas.DrawImage(pdfimage, 0, 0, fitWidth, fitHeight);

ISSUE:
The image is padding left about about 10px.

If you check out the attached pdf, the evaluations should lay on top of each other and the doc is being cropped on the right...

How can I get the document to draw at top 0, left 0?

CANNOT ADD A 2.5MB ZIP, PLEASE SEND AN EMAIL REQUEST FOR DOC
(HOW ABSURD!)

DaveSD
 
Posts: 1
Joined: Fri Oct 19, 2018 6:06 pm
Location: San Diego, CA US

Mon Oct 29, 2018 6:33 am

Dear David,

Thanks for your inquiry and sorry for late reply as weekend.
After an initial test with the latest Spire.PDF Pack(Hot Fix) Version:4.10.3, I didn't reproduce the issue you mentioned, the image was drawn started at left 0, top 0. If you were using an old version, I suggest upgrading to the latest one to have a try. If the issue still troubles you, please provide your input and generated Pdf files for our reference. Note: size of attachment is limited to 2MB on our forum. Once your file exceeds the limitation, please provide it to us via email (support@e-iceblue.com).

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Tue Oct 30, 2018 6:10 am

Hi,

Greetings from E-iceblue!
How is your issue going? Could you please give us some feedback at your convenience? Thanks in advance.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.PDF