I have a PDF document with a single page I am trying to setup as a layer.
So I can put a second layer with text over the top then hide the first layer.
I figured the best way would be to take an image of the first PDF doc and have it as a full page image to ensure that the location of text is acurate when printed.
however I am struggling to get the top left corner of the image in the top left corner of the document...
I tried setting margins to 0 but no matter what I try the image is offset, and even though I set the image size to the height and width of the page canvas it does not appear to be the correct size...
not sure what I am missing.
I also tried setting the image as a page background but that didn't work at all, just provided a white background.
The layer portion is working as I want (able to toggle the image viability on and off), so if I can just figure out the sizing, positioning and margins issue I should be good
- Code: Select all
//Setup PDF
PdfDocument MyPDF = new PdfDocument();
PdfPageBase MyPage = MyPDF.Pages.Add();
//Load 1500 form background
Spire.Pdf.Graphics.Layer.PdfLayer Layer1500 = MyPDF.Layers.AddLayer("1500");
PdfCanvas PageCanvas = Layer1500.CreateGraphics(MyPDF.Pages[0].Canvas);
Image image = Image.FromFile(@"D:\CMS-1500.png");
PdfImage pdfimage = PdfImage.FromImage(image);
PointF position = new PointF(0, 0);
int width = image.Width;
int height = image.Height;
PageCanvas.DrawImage(pdfimage, position);.DrawImage(pdfimage, position);