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 Aug 10, 2016 6:57 pm
I am getting 'out of memory' exception at
- Code: Select all
PdfImage pdfI = PdfImage.FromFile("layer.pdf");
could you help me resolve this.
Last edited by
spirepap on Thu Apr 13, 2017 10:15 pm, edited 2 times in total.
-

spirepap
-
- Posts: 17
- Joined: Thu May 12, 2016 5:07 pm
Thu Aug 11, 2016 3:12 am
Dear spirepap,
Sorry that there is no way to add a layer using .pdf file. We suggest you save the PDF file as image and then create a layer with the image. Here is sample code to add a layer with image for your reference.
- Code: Select all
PdfDocument ImageDoc = new PdfDocument("Imatemp.pdf");
//save the first page as image
Image img = ImageDoc.SaveAsImage(0);
PdfDocument pdfdoc = new PdfDocument("sample.pdf");
//get the page for adding layer
PdfPageBase page = pdfdoc.Pages[0];
//add a layer named layer1
PdfPageLayer layer = page.PageLayers.Add("layer1");
//load the image used to add in the layer
PdfImage pdfI = PdfImage.FromImage(img);
//draw the image on the layer
layer.Graphics.DrawImage(pdfI, new PointF(0, 0));
pdfdoc.SaveToFile("8303.pdf",FileFormat.PDF);
Hope this can help you. If there is any question, please let me know.
Sincerely,
Betsy
E-iceblue support team
-


Betsy
-
- Posts: 802
- Joined: Mon Jan 19, 2015 6:14 am
Thu Aug 11, 2016 5:54 pm
If I convert that into image and add then it, layer is loosing its properties.
Last edited by
spirepap on Thu Apr 13, 2017 10:17 pm, edited 1 time in total.
-

spirepap
-
- Posts: 17
- Joined: Thu May 12, 2016 5:07 pm
Fri Aug 12, 2016 2:22 am
Dear spirepap,
Thanks for your reply.
Could you please provide us your sample document and the target result PDF( you can create it by Adobe) and the codes you were using ? So we will test it at our end and will provide you more information accordingly.
Thanks,
Betsy
E-iceblue support team
-


Betsy
-
- Posts: 802
- Joined: Mon Jan 19, 2015 6:14 am
Fri Aug 12, 2016 10:00 pm
Worked fine, thanks.
Last edited by
spirepap on Thu Apr 13, 2017 10:17 pm, edited 1 time in total.
-

spirepap
-
- Posts: 17
- Joined: Thu May 12, 2016 5:07 pm
Mon Aug 15, 2016 1:28 am
Dear spirepap,
Thanks for your feedback.
Welcome to write to us again for further question. We are here for help.
Sincerely,
Betsy
E-iceblue support team
-


Betsy
-
- Posts: 802
- Joined: Mon Jan 19, 2015 6:14 am
Wed Aug 24, 2016 6:17 pm
Is it possible to add a vector file as a layer?
Last edited by
spirepap on Thu Apr 13, 2017 10:18 pm, edited 1 time in total.
-

spirepap
-
- Posts: 17
- Joined: Thu May 12, 2016 5:07 pm
Thu Aug 25, 2016 2:34 am
Dear spirepap,
Thanks for your inquiry.
Sorry that Spire.PDF doesn't support to add .svg file as a layer to pdf document directly. But there is a way maybe meets your requirement, convert .svg file as image(e.g. png) using other tool, and then create a layer with the image.
Sincerely,
Betsy
E-iceblue support team
-


Betsy
-
- Posts: 802
- Joined: Mon Jan 19, 2015 6:14 am